2017-02-26 05:43 AM
2017-02-26 07: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
2017-02-26 08: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.
2017-02-27 01: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...
2017-02-27 02:12 AM
Hi Max,
Thanx buddy, I got your point.