Hi all!
I have been developing a BLE application using an EByte nRF52832 module and Black Magic Probe programmer running on STM32F108 "Bluepill" board.
Everything works just fine as long as the nRF52832 is running software that doesn't explicitly conserve power, but as soon as it is put into low power mode by issuing __WFE()
in the main loop the BMP fails to "wake it up" and recognise during SWD scan.
Working main.c
:
#include <nrf.h>
int main(void) {
for(;;) {
}
}
Failing main.c
:
#include <nrf.h>
int main(void) {
for(;;) {
__WFE();
}
}
Interestingly the nRF52832 module can be "resurrected" by attaching it to a Raspberry Pi and running mass_erase
command there using OpenOCD. After this, flashing using BMP again works as the target is not in the __WFE()
loop anymore.
I sniffed the SWD communication using a logic analyser and noticed that there seems to be no difference in BMP's behaviour between succeeding and failing flashing attempts. On the SWD bus the BMP first clocks out 64 '1's followed by 0xE79E magic value. After that 50 '1's are sent followed by 16 '0's. After the zeros IDCODE register is read, but the nRF doesn't respond to the request. As SWD is run on STM32 board using GPIO bit-banging the clock is not very stable, but otherwise the data seems fine to my eyes.
What could cause the SWD communication failure between the BMP and nRF when nRF is in the low power mode? Is there something special to be done to wake up/reset the nRF when it is in low power mode?