TIMx Link TIMX to Measure External Frequency
Am using NUCLEO-STM32H723 Nucleo-144 board.
Sorry, but I have no experience with the above MCU/TIMx.
My goal is to measure external frequency as accurately as possible.
I'm interested to know how to Link between two timers.
Example : TIM3 ( Master ) TIM2 ( Slave ).
TIM3 receive ETR2 (External clock) as clock source, and should Triger every 40 pulse to TIM2.
TIM2 should be Triger by TIM3 after 40 pulse ETR2 CLK , And capture Internal clock and calculating the frequency.
Do I need use TIM->CNT Or TIM2-CCR1 ?
Anyway this is the code I use.
main()
{
HAL_TIM_Base_Start(&htim3);
HAL_TIM_Base_Start_IT(&htim2);
....
....
while()
{
}
}
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef* htim)
{
if(gu8_State == IDLE)
{
gu32_T1 = TIM2->CCR1;
gu16_TIM2_OVC = 0;
gu8_State = DONE;
}
else if(gu8_State == DONE)
{
gu32_T2 = TIM2->CCR1;
gu32_Ticks = (gu32_T2 + (gu16_TIM2_OVC * 65536)) - gu32_T1;
gu32_Freq = (uint32_t)(F_CLK/gu32_Ticks);
gu8_State = IDLE;
}
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim)
{
if(htim->Instance == TIM23)
{
gu16_TIM2_OVC++;
}
}

I