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 Reply Children
  • 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:

    }

  • To clear the LATCH register, you need to write '1' to the bits you want to clear. I used the following to clear the entire register:

    NRF_GPIO->LATCH = NRF_GPIO->LATCH;

  • Dear Jorgen,

    Thank you. I already try and it don't works. Perhaps I made a mistake and I will check it. But I found this documents, dou you think it could explain why LATCH REGISTER is always to "1" even if I use this comand : "

    NRF_GPIO->LATCH = NRF_GPIO->LATCH;

    https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev2/ERR/nRF52832/Rev2/latest/anomaly_832_210.html

    Thank you.

    BR

    [210] GPIO: Bits in GPIO LATCH register are incorrectly set to 1

    This anomaly applies to IC Rev. Revision 2, build codes CIAA-Ex0, QFAA-Ex0, QFAB-Ex0.

    It was inherited from the previous IC revision Revision 1.

    Symptoms

    The GPIO.LATCH[n] register is unexpectedly set to 1 (Latched).

    Conditions

    Set GPIO.PIN_CNF[n].SENSE at low level (3) at the same time as PIN_CNF[n].INPUT is set to Connect (0).

    Consequences

    The GPIO.LATCH[n] register is set to 1 (Latched). This could have side effects, depending on how the chip is configured to use this LATCH register.

    Workaround

    Always configure PIN_CNF[n].INPUT before PIN_CNF[n].SENSE.

  • It could be related. Which bits are set in the LATCH? Have you checked if the corresponding pin is configured to meet the conditions for the errata?

Related