Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To clear specific bits in TIMx_SR registers, libmaple code used to do TIMx_SR &= ~(events_handled); // wrong This is wrong. If a new event occurs between the read from TIMx_SR and the write to TIMx_SR, that new event will be cleared immediately without ever being noticed or handled. A better way to clear specific bits is TIMx_SR = ~(events_handled); // good This writes '0' to the bits to be cleared, and '1' to all other bits. The hardware will not allow software to change any SR bits from 0 to 1; only hardware events can do that. So bits written as '1' are effectively ignored and bits written as '0' are cleared. Exactly what we need.
- Loading branch information