2015-11-10 08:34 AM
Hello every one! How can i check if the timer is already running.. which flag to use I am trying this
if (TIM2 -> CR1 == TIM_CR1_CEN){// turn led on blue} else{// turn led red on}but it does not work, please help me #!stm32f4-disco #discovery #stm32f4 #timers2015-11-10 09:56 AM
I'd presume it's looking for a bit level mask, not a comparison.
2015-11-10 10:11 AM
I dont know, but my task is to check if the timer is enabled or disabled. Please tell me how can i do that
2015-11-10 10:17 AM
It's a bit, mask it and check if it's zero or not
if (TIM2->CR1 & TIM_CR1_CEN) // test the enable BIT
{
// turn led on blue
}
else
{
// turn led red on
}
2015-11-10 10:21 AM
Hello,
I have a solution proposal: You can set an Update event by Software juste before enabling the timer ( timer when enabled it will generate an UEV ) /* Set th UG bit to enable UEV */ TIM1->EGR |= TIM_EGR_UG; Then, you should manage by reading the UIF (update interrupt flag) and cheking if it's set : if ( (TIM2 -> SR & TIM_SR_UIF) != RESET ) { // turn led on blue } else { // turn led red on } Good luck2015-11-10 10:28 AM
The problem with Update interrupt flag is it is always triggered even when the timer is not started.
2015-11-11 04:06 AM