cancel
Showing results for 
Search instead for 
Did you mean: 

stm32l476 clearing pending bit via bit banding alias

kor9
Associate
Posted on December 07, 2015 at 09:27

Hi All,

Attempting to clear a pending bit in the EXTI_PR1 register via its bit banding alias clears another pending bit as well.

When I try to clear the bit20 (RTC periodic alarm) after wakeup by writing 1 to its alias address 0x422082d0 also clears bit5. 

This behaviour is may be specific to wakeup or RTC alarm interrupt. I havent tested if it clears all bits or some bits. Or it happens only after wakeup.

What I observed though when  I clear the bit20 via its direct address, i.e., ''EXTI_PR=1u<<20; '' it only clears bit20.

Any ideas or similar experiences?

Thanks

Kerem

#stm32l476
3 REPLIES 3
Posted on December 07, 2015 at 12:04

This is expected behaviour. Bit-banding from the point of view of the memories and peripherals is read-modify-write, whereas the EXTI_PR1 register's bits are rc_w1 i.e. cleared by writing 1.

Thus, you ought to clear Nth bit by writing 1<<N directly into the register.

JW

Posted on December 07, 2015 at 14:39

Bit banding has long standing, and long documented, issues with accessing peripheral space, especially when the hw has been designed to avoid race hazards.

TIMx->SR = ~1; being a classic example

Until such times as a RMW is faster than a simple Write the point of using bit-banding on these peripherals is hard to make.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kor9
Associate
Posted on December 07, 2015 at 16:07

Thanks for the clarification. Modified the code accordingly.