cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_PWR_EnterSLEEPMode() needs to have a __DSB() before the __WFI() or __WFE() according to ARM documentation

pgspro1
Associate

According to ARM Cortex-A Series Programmer’s Guide for ARMv8-A:

15.1.2. Standby

...

This mode is entered using either the WFI (Wait For Interrupt) or WFE (Wait For Event) instructions. ARM recommends the use of a Data Synchronization Barrier (DSB) instruction before WFI or WFE, to ensure that pending memory transactions complete before changing state.

--> The HAL function HAL_PWR_EnterSLEEPMode() does not perform the DSB instruction before the WFE or WFI instruction. I believe that this is an error in the HAL code.

1 REPLY 1
Piranha
Chief II

While the main point is correct, one should refer to Cortex-M documentation, not Cortex-A.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHICBGB.html

ST's developers are systematically ignoring needed memory barriers everywhere. That's one of the reasons their ETH/lwIP drivers are so flawed that they are basically non-working. Now on a fast Cortex-M7 based MCUs it is showing off in it's full glory of instability. And it has been reported in this forum multiple times years ago...