Question
STM32F303 Timer - Count Mismatch
Hi
Im using TIM6 on the STM32F303 MCU with clock 64 MHz and PSC 63999.
If the ARR set to 65000 and in non- interrupt mode, the below code
HAL_TIM_Base_Start(&htim6);
HAL_Delay(500);
HAL_TIM_Base_Stop(&htim6);
results in CNT value of ~500 as expected.
However in interrupt mode and using the below code and callback,
HAL_TIM_Base_Start_IT(&htim6);
HAL_Delay(500);
HAL_TIM_Base_Stop_IT(&htim6);
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* Prevent unused argument(s) compilation warning */
if(htim->Instance==TIM6)
{
ms_timer_count++;
}
}
the ms_timer_count is at 251. The timer in this case is configured to generate interrupt at 1ms (ARR=1).
The expected result for ms_timer_count is ~500.
What is wrong with the code/configuration?
