Hallo ST, i am programming with the stm32l476 and with stmcubeide. My question is timer related.
I want to implement a timer which would elapse in 3s and gives me an interrupt then. But i want to build a kind of software watchdog which will be always reseted from an external clock 1s. So my idea is, when the external 1s clock is off then after 3s elapse my timer will fire an interrupt which i will use in further processing.
My configurations done in cube:
TIM_SlaveConfigTypeDef sSlaveConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
/* USER CODE BEGIN TIM2_Init 1 */
/* USER CODE END TIM2_Init 1 */
htim2.Instance = TIM2;
htim2.Init.Prescaler = 64000;
htim2.Init.CounterMode = TIM_COUNTERMODE_DOWN;
htim2.Init.Period = 3000;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
{
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_RESET;
sSlaveConfig.InputTrigger = TIM_TS_TI1FP1;
sSlaveConfig.TriggerPolarity = TIM_TRIGGERPOLARITY_RISING;
sSlaveConfig.TriggerFilter = 0;
if (HAL_TIM_SlaveConfigSynchro(&htim2, &sSlaveConfig) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_ENABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM2_Init 2 */
__HAL_TIM_ENABLE_IT(&htim2, TIM_IT_TRIGGER);
__HAL_TIM_DISABLE_IT(&htim2, TIM_IT_UPDATE);
/* USER CODE END TIM2_Init 2 */
i was playing with does enable disable ...IT but i always got both interrupts either the 1s or the 3s after elapsed counter. I thought i can reset the counter without doing an interrupt. Or any ideas who i can implement such behavior.
Thanks