TIM_ClearFlag() function in stm32f10x library
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-07-07 12:02 AM
Posted on July 07, 2012 at 09:02
The content of this function is
/* Clear the flags */ TIMx->SR = (uint16_t)~TIM_FLAG; But I think it must be in this format: /* Clear the flags */ TIMx->SR &= (uint16_t)~TIM_FLAG; a & is needed for correct clear operation on flags, is this correct?
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-07-07 3:30 AM
Posted on July 07, 2012 at 12:30
a & is needed for correct clear operation on flags, is this correct?
Wouldn't that introduce hazards by being non-atomic?''This flag is set by hardware only when the corresponding channel is configured in inputcapture mode. It is cleared by software by writing it to ‘0.'' I can't find a better cite quickly, but the inferred operation is that only a write of a zero bit will stick, and thus the operation is self masking and atomic.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-07-13 6:23 AM
Posted on July 13, 2012 at 15:23
In page 394 of RM0008 we see:
Bit 15:13 Reserved, must be kept at reset value. (for TIMx status register (TIMx_SR) ) but we write 1 to reserved bits! what is the problems of non atomic clear operation?Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-07-13 8:08 AM
Posted on July 13, 2012 at 17:08
what is the problems of non atomic clear operation?
That you'd clear an interrupt that asserts in the middle of your non-atomic RMW operation, and you'd never know. Consider for a second what the AND operator does, and now spread that over at least 4-8 cycles.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
