2015-03-05 05:53 AM
Hi,
I generated a project with stm32cube and I set timer TIM2 with follow conf, when I call HAL_TIM_Base_Start_IT the callback is called immediatly and not after a cycle ( as I expect). P.S. After firts callback it's works fine (cycling with configured period) MCU is STM32F207 void MX_TIM2_Init(void) { TIM_ClockConfigTypeDef sClockSourceConfig; TIM_MasterConfigTypeDef sMasterConfig; htim2.Instance = TIM2; htim2.Init.Prescaler = 60000; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 10; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; HAL_TIM_Base_Init(&htim2); sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig); sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig); } #stm32f2 #timer #stm32cube2015-03-05 07:56 AM
as I expect
Update = transition to zero count, see also reset2015-03-06 01:38 AM
Thanks for your quickly reply.
Sorry I don't understand very well the ans. Can you explain me? I see another thing during my test, under first callback(immediatly callback I mean) if I use HAL_TIM_Base_Stop() into the callback it doesn't work and I must use it on main{} function, after this if I use HAL_TIM_Base_Stop() into the callback during runtime operation it's works fine and stop htim->Instance.CNT2015-03-06 08:13 AM
Hello Marco
At the end of the timer initialization procedure, an update event is sent. So an Update IT is pending. I would suggest you to clear the Timer status register before calling HAL_TIM_Base_Start_IT (...) hope this helps Regards2015-03-09 01:31 AM
Thank you very much for your advice, now I try to clean pending bit on init.
Best Regards