Timer interrupt works immediately
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-21 1:52 AM
Posted on June 21, 2016 at 10:52
Hello.
I have configured the timer 6 to interrupt every 3s, but immediately after initialize the timer the interrupt occurs.Why?1 - HAL_TIM_Base_Init (&htim6);2 - HAL_TIM_Base_Start_IT(&htim6);3 - ''immediately'' (almost) it goes to interrupt handler...How can I resolve this problem?Thank you.
This discussion is locked. Please start a new topic to ask your question.
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-21 2:57 AM
Posted on June 21, 2016 at 11:57
> Why?
Because > 1 - HAL_TIM_Base_Init (&htim6); forces update through setting TIMx_EGR.UG (the reason is to force the prescaler setting into the real prescaler counter). > How can I resolve this problem? Clear TIMx_SR.UIF before enabling the timer. JWOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-21 3:32 AM
Posted on June 21, 2016 at 12:32
Hello.
I had already done it ... but the result is the same.The interruption is immediate ...Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-21 3:45 AM
Posted on June 21, 2016 at 12:45
Clear the flag *before* HAL_TIM_Base_Start_IT().
JWOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-21 4:00 AM
Posted on June 21, 2016 at 13:00
Oh... sorry xD.
I think that the flag had changed in Start_IT, so I tried modify the flag after...In resume, the flag is changed in Timer Init...My mistake.It works!Thank you very much!