higher frequency

This commit is contained in:
Wolfgang Hottgenroth 2021-02-06 18:10:17 +01:00
parent 18d0cbe4c8
commit ccdbab6f01
2 changed files with 3 additions and 2 deletions

View File

@ -34,7 +34,7 @@ void MX_TIM1_Init(void)
TIM_IC_InitTypeDef sConfigIC = {0};
htim1.Instance = TIM1;
htim1.Init.Prescaler = 71;
htim1.Init.Prescaler = 35;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 65535;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

View File

@ -95,7 +95,8 @@ void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {
} else if (state == 1) {
show(DEBUG_2, OFF);
uint32_t captured = (savedV < v) ? (v - savedV) : ((htim->Init.Period - savedV) + v);
logMsg("CCR: %ld", captured);
double f = 1.0 / ((double)captured) * 1.0e6 * 2;
logMsg("CCR: %ld, %f", captured, f);
state = 0;
} else {
state = 0;