STM8S timer is working properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-02-26 5:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-02-26 7:57 PM
Hello,
First remark, I think you should not use READ-MODIFY-WRITE operation when you are clearing hardware register flags.
If another event happens between the READ operation and the WRITE operation, you will end up clearing the new event without knowing it (therefore missing it...).
For example, I recommend to replace :
TIM2_SR1 &=~(1<<0); // READ TIM2_SR1; AND with ~(1<<0) ; WRITE back to
TIM2_SR1
by
TIM2_SR1 =~(1<<0); // WRITE
~(1<<0) to TIM2_SR1
the register is described as rc_w0 meaning 'read and clear only by writing 0', it means that writing one wont change the content.
regards,
Max
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-02-26 8:16 PM
Hi Max,
Many many Thanx for your valuable suggestion. I have done the modification you have suggested, but unfortunately the problem still remains. Timer 1 stops responding when ever.any environmental disturbance occurs. Its very wired problem for me, I have never seen this kind of problem before.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-02-27 1:07 AM
With your code, it seems the same thing could happen with
TIM1_CR1 because it is being modified inside the interruption.
Ask yourself what would happen if the interruption happens in the middle of the
READ-MODIFY-WRITE operation...
I recommend to use the debug mode to understand the status of TIM1 when your problem happen (ON/OFF, pending bit...).
This kind of issue looks to me like one interrupt happening at the wrong time...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-02-27 2:12 AM
Hi Max,
Thanx buddy, I got your point.
