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

nRF52832 system powers off and wakes up it

Hi everyone,

I am developing a remote control using nRF52832 chip. My prototype is currently developed in PC10040 board. The IDE is Eclipse Oxygen, and the SDK is S132 v5.0.0.

I am trying to power off my system using NRF_POWER->SYSTEMOFF = 0x01; when I press a button and then, by pressing that button again, the system will wake up and cause a reset. The problem is when I press the button for the first time, the system seems to reset unstoppable, even when I press the reset button or turn off and then turn on the power again, it is still reset continuosly.

Could you help me please? Thanks

  • Well we will hardly help you not knowing what exactly you do in your code before you try to send the chip to SYSTEM OFF. E.g. if you are using Nordic BLE stack and Soft Device is enabled you cannot write to these registers directly but use dedicated sd_power_system_off() function as per API description. Note that this isn't magic cure to every problem with SYSTEM OFF mode, you need to take care about initialization/deinitialization of some things (at least that's my experience). Also for wake-up you need to set the PIN specifically. Have you seen the power management example from nRF5 SDK? Can you make your application working in the same way before even using BLE stack (Soft Device)? Only then you should try to achieve the same flow but with BLE stack enabled.

  • Hi endnode, I enable BLE stack before I power off the system using NRF_POWER->SYSTEMOFF = 0x01;. I have tried comment out the BLE stack config and enable codes, but the problem still happens :((( Below is my piece of code I use to config the system:

    /**
     * @brief : Config system
     * @param :
     * @return:
     */
    void ConfigSystem()
    {
        // Config Log
        ConfigLog(TX_PIN_NUMBER, RX_PIN_NUMBER, CTS_PIN_NUMBER, RTS_PIN_NUMBER, HWFC, UART_BAUDRATE_115200);
        Print("\n\n\n");
        PrintInfo("Headset for people with low vision project");
        PrintAppInfo("Log Initialized!");
    
        // Config SPI
        // USE_SPI have to be defined if SPI is used
    #ifdef USE_SPI
        SPIConfig.SPIBase = NRF_SPIM0;
        SPIConfig.pinCSN = CSN_PIN_NUMBER;
        SPIConfig.pinSCK = SCK_PIN_NUMBER;
        SPIConfig.pinMOSI = MOSI_PIN_NUMBER;
        SPIConfig.pinMISO = MISO_PIN_NUMBER;
        SPIConfig.role = SPI_ROLE;
        SPIConfig.mode = SPI_MODE;
        SPIConfig.order = SPI_BIT_ORDER;
        SPIConfig.freq = SPIM_FREQ_M8;
        ConfigSPI(SPIConfig);
        PrintAppInfo("SPI Master Initialized!");
    #endif
    
        // Config I2C
        // USE_I2C have to be defined if I2C is used
    #ifdef USE_I2C
        I2CMasterConfig.I2CBase = NRF_TWIM0;
        I2CMasterConfig.pinSCL = SCL_PIN_NUMBER;
        I2CMasterConfig.pinSDA = SDA_PIN_NUMBER;
        I2CMasterConfig.role = I2C_ROLE;
        I2CMasterConfig.frequency = I2CM_FREQ_K100;
        ConfigI2C(I2CMasterConfig);
        PrintAppInfo("I2C Master Initialized!");
    #endif
    
        // Config indicators (GPIO pins used for controlling LEDs)
        ConfigIndicator();
        PrintAppInfo("Indicator Initialized!");
    
        //Config ADC
        ADC_Channel_Configuration_t ADCChannelConfig;
        ADCChannelConfig.ADCPosPin = ADC_PSELP_PIN;
        ADCChannelConfig.ADCNegPin = ADC_PSELN_PIN;
        ADCChannelConfig.resPinPos = ADC_RESISTOR_DISABLED;
        ADCChannelConfig.resPinNeg = ADC_RESISTOR_PULLDOWN;
        ADCChannelConfig.acqTime = ADC_ACQTIME_3US;
        ADCChannelConfig.burst = ADC_BURST_DISABLED;
        ADCChannelConfig.gain = ADC_GAIN_1_6;
        ADCChannelConfig.mode = ADC_MODE_DIFF;
        ADCChannelConfig.reference = ADC_REFERENCE_INTERNAL;
        ConfigADCChannel(ADC_CHANNEL, ADCChannelConfig);
    
        ADC_Configuration_t ADCConfig;
        ADCConfig.resolution = ADC_RESOLUTION;
        ADCConfig.samplerateMode = ADC_SAMPLERATE_MODE_TASK;
        ADCConfig.oversample = ADC_OVERSAMPLE_DISABLED;
        ADCConfig.buffer = &ADCBuffer;
        ADCConfig.bufferAmount = 1;
        ConfigADC(ADCConfig);
        PrintAppInfo("ADC Initialized!");
    
        // Config BLE and start advertising
        ConfigBLE();
        PrintAppInfo("BLE Initialized!");
        //  BLEStartAdvertising(BLE_ADV_MODE_FAST);
        //  PrintAppInfo("Start advertising");
        BLEStartScanning();
        PrintAppInfo("Start scanning");
    
        // Config Power
        ConfigPOWER();
        PrintAppInfo("POWER Initialized!");
    
        // delay a while for system to be ready
        int i;
        for(i = 0; i < 1000; i++)
        ;
    }
    
  • (I don't see the problem right now but already the blocking FOR loop in the end makes me almost blind, come one, cannot you implement some better non-blocking waiting loop?)

  • That is one of my mistake, I will remove it, thanks for advising me :D

  • Maybe you need some delay but having it done through some timer lib would be better. Anyway this is single function but what about the rest of your project? i recommend to firstly implement this "button press -> SYSTEM OFF -> button press -> SYSTEM ON" in some of SDK examples where you can easily get support here. Once it works and you see on UART debug line or similar that no reset or unintended wake-ups happen then you can port the code to your FW easily.

Related