This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Possible alternative workaround for Erratum 246: "System: Intermittent extra current consumption when going to sleep"

In my previous question concerning nRF52805 Erratum 246, user hmolesworth suggested an alternative workaround using a data synchronisation barrier for this erratum:

As an improved workaround for errata 246 could we simply precede the __WFE() with a __DSB()? This would ensure no high-speed CPU memory access is in progress (including no stack access) and any peripheral 16MHz accesses are then safe to occur during execution of WFE thereby removing the conditions for the bug.

#define __WFE() __ASM volatile ("wfe")
// Ensure all explicit memory accesses before this instruction complete
#define __DSB() __ASM volatile ("dsb 0xF":::"memory")
  
ENABLE_WAKEUP_SOURCE -> SEVONPEND -> DISABLE_INTERRUPTS -> __DSB -> __WFE -> WAKEUP inside __WFE -> ENABLE_interrupts -> WAKEUP_SOURCE_ISR

Note the __DSB() should be redefined as a macro and not the current inline function definition which may not execute as desired under some compiler settings; a non-inline function call would mess up the intent of this workaround with an unwanted memory-accessing stack pop.

Edit: If running code from RAM instead of FLASH an __ISB() should probably be added immediately before __DSB(); this does not apply to cache I don't think as that is separate memory

If IRQs are disabled properly (as described in hmolesworth's code) this looks like a feasible solution. I'm not sure whether it's much of a power saver.

How do the engineers at Nordic rate this workaround?

Related