2012-07-07 12:02 AM
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?2012-07-07 03:30 AM
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.
2012-07-13 06:23 AM
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?2012-07-13 08:08 AM
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.