2015-10-22 12:54 PM
The STML0 (and L1) manual says following about the register EXTI_PR:
''1: The selected trigger request occurred. This bit is set when the selected edge event arrives on the interrupt line. This bit is cleared by writing it to 1 or by changing the sensitivity of the edge detector.'' The bits are of type rc_w1, which corresponds to the description. But the Code Snippets (e.g., stm32snippetsl0\STM32L0xx_Snippets_Package_V1.1.1/Projects/RTC/02_ProgrammingTheWakeUpTimer/main.c) use following code: EXTI->PR |= EXTI_PR_PR20; /* clear exti line 20 flag */ This does ''Take all bits that are set in this register, set one more (even though it is usually set already at this place) and write it back''. And that translates to ''Clear all pending EXTI lines'', which is not the intention. It may clear additional, unwanted lines. Shouldn't the line be as follows, considering rc_w1? EXTI->PR = EXTI_PR_PR20; /* clear exti line 20 flag */ #clear-exti-pr2015-10-22 02:10 PM
2015-10-22 02:43 PM
> In first case: EXTI->PR |= EXTI_PR_PR20; you mask only that bit and write 1 to it.
> That would clear it. Thanks for your response but unfortunately I think that's not correct. That's an ''or'', not an ''and''. Let's assume that line 0 and 1 are set, so EXTI->PR reads:val = EXTI->PR; // val is now 3
we want to clear line 0 only, the first case would:val |= 1; // val is still 3 - note that's ''or''
this is written back:EXTI->PR = val; // This writes 3 and thus clears line 0 *and* line 1
Right?2015-10-22 09:21 PM
I'm not sure but I think in this case it isn't important if there is OR or AND. You only have to write 1 to the line you want to clear. if you write 1 to any of zeros, this will stay 0. If you write 0 to any of zeros, it will stay 0 too. And if you write 0 to any of 1, it will stay 1.
Not 100% sure, but 99... :)2015-10-23 03:19 AM
> Shouldn't the line be as follows, considering rc_w1?
> EXTI->PR = EXTI_PR_PR20; /* clear exti line 20 flag */
Yes, you are right. I have heard from ST that they are working on it and it will be corrected in the next version of manual and the Snippets. Thanks for reporting this. JW