Timer interrupting on MCU reset
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-14 6:12 AM
Hello I have set the timer7 for 1 minute interrupt. It is working at every minute as expected.
But the interrupt is also triggered as MCU is reset. I have set global counter for increment in timer7 callback. As soon MCU is reset , Timer7 callback is called and counter is incremented. Please suggest why it is happening.
static void MX_TIM7_Init(void)
{
/* USER CODE BEGIN TIM7_Init 0 */
/* USER CODE END TIM7_Init 0 */
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE BEGIN TIM7_Init 1 */
/* USER CODE END TIM7_Init 1 */
htim7.Instance = TIM7;
htim7.Init.Prescaler = 65400;
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
htim7.Init.Period = 44035;
htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
}
//**********************************
Solved! Go to Solution.
- Labels:
-
STM32F0 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-14 6:21 AM
Before you start the timer and enable interrupts, generate an update event and clear the UE bit. Timers being triggered immediately can be due to the ARR register being preloaded.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-14 6:21 AM
Before you start the timer and enable interrupts, generate an update event and clear the UE bit. Timers being triggered immediately can be due to the ARR register being preloaded.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-14 6:41 AM
thanks..
