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

Which GPIO is used to wake up NRF52832 from System_Off

Hi,

I use a board from Adafruit with NRF52832 to make a POC (Proff Of Concept) (Adafruit Feather nRF52 Bluefruit LE - nRF52832 - PRODUCT ID: 3406).

I use the Arduino IDE and a library "LOW POWER" for NRF52832 (https://github.com/mristau/Arduino_nRF5x_lowPower).

I have 5 push buttons connected to the GPIO pins : 16,15, 7, 11 and 27 which supports interrupts.

Today I use the "deep sleep mode" of the NRF52832 (System_Off) and I attach interrupts to the GPIO ports 16,15,7,11,27 to wake up the module NRF52832. And all running very well.

But now I need to go further, and I need to read/know what GPIO port has been used to wake up the system, the 16, 15,7, 11 or 27?

I tried to read the state of this digital port, but it runs only if you keep the button pushed a "long time" (the necessary time to wake up and setup the NRF52832). And in the real life, for my POC, it's not possible to keep the button pushed.

I need your help to know if it's possible with NFR52832 to know what GPIO:interrupt wake up the system when the device is in POWER_MODE_OFF?

And if it's possible, can you send me samples code to help me?

Thank you very much for your hepl.

Best regards.

Parents
  • Hi,

    There is no way to know this except to check the state of the GPIO after wakeup/reset. The startup time from OFF to CPU is 16.5 us, you should have a quick hand to release the button before you are able to check the state. What kind of startup time are you seeing? Maybe you need to move the GPIO checking earlier in the program? I'm not sure what kind of startup delay the Arduino libraries will add to the chip startup time.

    Best regards,
    Jørgen

  • I looked a bit further into this, and there may be a way to read out the GPIO that caused the wake.

    The GPIO registers are not reset at a wakeup from SYSTEM OFF. So if you clear the LATCH register before entering SYSTEM OFF mode, the LATCH register will indicate which pin was used to wake the chip (given that no other GPIOs have been set during the startup). 

  • Hi Jorgen,

    Thank you very much for your help. Today I success to read the latch register. But I don't know how to clear tis register before entering SYSTEM OFF mode. I have to chack how to do that with ARDUINO IDE....

    To read I use and obtain always all bits to "1":

    typedef volatile uint32_t REG32;
    #define pREG32 (REG32 *)

    #define LATCH (*(pREG32 (0x10000520)))

    I used this sample code to do that:

    #include <Arduino.h>

    typedef volatile uint32_t REG32;
    #define pREG32 (REG32 *)

    #define DEVICE_ID_HIGH (*(pREG32 (0x10000060)))
    #define DEVICE_ID_LOW (*(pREG32 (0x10000064)))
    #define MAC_ADDRESS_HIGH (*(pREG32 (0x100000a8)))
    #define MAC_ADDRESS_LOW (*(pREG32 (0x100000a4)))

    void setup() {
    Serial.begin(115200);
    while ( !Serial ) delay(10); // for nrf52840 with native usb

    Serial.println("Bluefruit 52 HW Info");
    Serial.println("");

    // MAC Address
    uint32_t addr_high = ((MAC_ADDRESS_HIGH) & 0x0000ffff) | 0x0000c000;
    uint32_t addr_low = MAC_ADDRESS_LOW;
    Serial.print("MAC Address: ");
    Serial.print((addr_high >> 8) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_high) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_low >> 24) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_low >> 16) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_low >> 8) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_low) & 0xFF, HEX); Serial.println("");

    // Unique Device ID
    Serial.print("Device ID : ");
    Serial.print(DEVICE_ID_HIGH, HEX);
    Serial.println(DEVICE_ID_LOW, HEX);

    // MCU Variant;
    Serial.printf("MCU Variant: nRF%X 0x%08X\n",NRF_FICR->INFO.PART, NRF_FICR->INFO.VARIANT);
    Serial.printf("Memory : Flash = %d KB, RAM = %d KB\n", NRF_FICR->INFO.FLASH, NRF_FICR->INFO.RAM);
    }

    void loop() {
    // put your main code here, to run repeatedly:

    }

Reply
  • Hi Jorgen,

    Thank you very much for your help. Today I success to read the latch register. But I don't know how to clear tis register before entering SYSTEM OFF mode. I have to chack how to do that with ARDUINO IDE....

    To read I use and obtain always all bits to "1":

    typedef volatile uint32_t REG32;
    #define pREG32 (REG32 *)

    #define LATCH (*(pREG32 (0x10000520)))

    I used this sample code to do that:

    #include <Arduino.h>

    typedef volatile uint32_t REG32;
    #define pREG32 (REG32 *)

    #define DEVICE_ID_HIGH (*(pREG32 (0x10000060)))
    #define DEVICE_ID_LOW (*(pREG32 (0x10000064)))
    #define MAC_ADDRESS_HIGH (*(pREG32 (0x100000a8)))
    #define MAC_ADDRESS_LOW (*(pREG32 (0x100000a4)))

    void setup() {
    Serial.begin(115200);
    while ( !Serial ) delay(10); // for nrf52840 with native usb

    Serial.println("Bluefruit 52 HW Info");
    Serial.println("");

    // MAC Address
    uint32_t addr_high = ((MAC_ADDRESS_HIGH) & 0x0000ffff) | 0x0000c000;
    uint32_t addr_low = MAC_ADDRESS_LOW;
    Serial.print("MAC Address: ");
    Serial.print((addr_high >> 8) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_high) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_low >> 24) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_low >> 16) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_low >> 8) & 0xFF, HEX); Serial.print(":");
    Serial.print((addr_low) & 0xFF, HEX); Serial.println("");

    // Unique Device ID
    Serial.print("Device ID : ");
    Serial.print(DEVICE_ID_HIGH, HEX);
    Serial.println(DEVICE_ID_LOW, HEX);

    // MCU Variant;
    Serial.printf("MCU Variant: nRF%X 0x%08X\n",NRF_FICR->INFO.PART, NRF_FICR->INFO.VARIANT);
    Serial.printf("Memory : Flash = %d KB, RAM = %d KB\n", NRF_FICR->INFO.FLASH, NRF_FICR->INFO.RAM);
    }

    void loop() {
    // put your main code here, to run repeatedly:

    }

Children
No Data
Related