2017-03-02 10:58 AM
Hello there,
I am having problems with Timers 6 and 7 configuration in STM32F0 device. What I am trying to do is to implement a way to start a timer, restart it (make it count from 0 without stopping) and stop it. Each of those actions should not trigger the update event. As for a test, I have setup my timer prescaller and period to 0xFFFF both. this should give me about 90 s time before the interrupt would trigger. I am resetting and disabling the timer in the meanwhile and even though I am getting an interrupt. What Am I doing wrong? Those are my restart and stop timer routines:
/*
* @brief Resets the rx timeout timer for specified generic struct * @param uart: generic struct pointer * @return HAL_OK if all ok. */HAL_StatusTypeDef mbg_ResetRxTimer(mbgUart_t* uart){ assert_param(uart); assert_param(uart->rxQ.toutTim); HAL_StatusTypeDef retVal = HAL_OK;retVal += HAL_TIM_Base_Stop_IT(uart->rxQ.toutTim); // turn off
uart->rxQ.toutTim->Instance->CNT = 0; // reset counter retVal += HAL_TIM_Base_Start_IT(uart->rxQ.toutTim); // turn onreturn retVal;
}/*
* @brief Turns off the rx timeout timer for specified generic struct * @param uart: generic struct pointer * @return HAL_OK if all ok. */HAL_StatusTypeDef mbg_DisableRxTimer(mbgUart_t* uart){ assert_param(uart); assert_param(uart->rxQ.toutTim); HAL_StatusTypeDef retVal = HAL_OK;retVal += HAL_TIM_Base_Stop_IT(uart->rxQ.toutTim); // turn off
uart->rxQ.toutTim->Instance->CNT = 0; // reset counterreturn retVal;
}I would appreciate all help
2017-03-02 11:14 AM
I have solved this by additionally clearing the interrupt flag:
__HAL_TIM_CLEAR_IT(uart->rxQ.toutTim, TIM_IT_UPDATE);
Does the flag trigger as soon as the timer is turned off?