No log messages from the Power Management library (nrf_pwr_mgmt)

Hi all,

I'm trying to put the system into the SYSOFF mode when the device detects an external charger. HW-wise it's implemented by the charge controller pulling a GPIO HIGH when an external charger is detected, and pulling the pin LOW when the charger is removed.

I'm following the official nRF SDK example (here) and implementing some aspects from it into a custom board project using SDK v17.1.0. The system seems to reach the line and then shuts off as expected since the logs stop at that point:

nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF)
 

Logs when it reaches the point:

<info> app_timer: RTC: initialized.
<info> app: !!!! ACTIVE CHARGER DETECTED, PIN IS HIGH !!!!

However, I don't see any logs printed from the power management module itself which are available and displayed correctly when using the original example, such as:

<info> app: System is ready for shutdown
<info> pwr_mgmt: Shutdown request 4
<info> pwr_mgmt: Shutdown started. Type 0
<info> app: NRF_PWR_MGMT_EVT_PREPARE_WAKEUP
<info> pwr_mgmt: SysOff handler 0x00003829 => ready
<info> pwr_mgmt: Maximum CPU usage: 1%
<info> pwr_mgmt: Shutdown complete.

In other words, I don't see any logs originated from <info> pwr_mgmt. Moreover, I've turned the CPU usage monitor on through the sdk_congif.h, but the CPU logs are not printed into the logs as well:

// <i> Module will trace percentage of CPU usage in one second intervals.

#ifndef NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED
#define NRF_PWR_MGMT_CONFIG_CPU_USAGE_MONITOR_ENABLED 1
#endif

Lastly, the system doesn't seem to reach the shutdown_handler() as NRF_LOG_INFO("INSIDE THE SHUTDOWN HANDLER") is not printed into the logs.

Am I missing a configuration setting somewhere that suppresses those logs?

Code snippet for clarity:

/** @brief Handler when the a change on the VIN_DET_PIN is detected
*/
static void vin_det_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    
    switch(action)
    {
        case NRF_GPIOTE_POLARITY_TOGGLE:
            // Active charger detected
            NRF_LOG_INFO("!!!! VIN TOGGLE DETECTED !!!!");
            break;
        case NRF_GPIOTE_POLARITY_LOTOHI:
            // Active charger detected
            NRF_LOG_INFO("!!!! ACTIVE CHARGER DETECTED !!!!");
            break;
        case NRF_GPIOTE_POLARITY_HITOLO:
            // Active charger removed
            NRF_LOG_INFO("!!!! ACTIVE CHARGER REMOVED !!!!");
            break;
        default:
            NRF_LOG_ERROR("!!!! UNKNOWN COMMAND IN VIN_DET_PIN_HANDLER");
            break;   
    }
}

/** @brief Function for initializing the GPIOTE peripheral.
*/
static void gpioet_init(void) {
    ret_code_t err_code;

    // Check whether the GPIOTE driver has been initialized before by any other module, e.g. app_button_init().
    if (!nrf_drv_gpiote_is_init())
    {
        // Initialize the GPIOTE driver
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    }

    nrf_drv_gpiote_in_config_t vin_det_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
    vin_det_config.pull = NRF_GPIO_PIN_NOPULL;

    err_code = nrf_drv_gpiote_in_init(VIN_DET_PIN, &vin_det_config, vin_det_pin_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(VIN_DET_PIN, true);

}


/**@brief Handler for shutdown preparation.
 */
bool shutdown_handler(nrf_pwr_mgmt_evt_t event)
{
    uint32_t err_code;

    NRF_LOG_INFO("INSIDE THE SHUTDOWN HANDLER");

    switch (event)
    {
        case NRF_PWR_MGMT_EVT_PREPARE_SYSOFF:
            NRF_LOG_INFO("NRF_PWR_MGMT_EVT_PREPARE_SYSOFF");
            //err_code = bsp_buttons_disable();
            //APP_ERROR_CHECK(err_code);
            break;

        case NRF_PWR_MGMT_EVT_PREPARE_WAKEUP:
            NRF_LOG_INFO("NRF_PWR_MGMT_EVT_PREPARE_WAKEUP");
            //err_code = bsp_buttons_disable();
            //// Suppress NRF_ERROR_NOT_SUPPORTED return code.
            //UNUSED_VARIABLE(err_code);

            //err_code = bsp_wakeup_button_enable(BTN_ID_WAKEUP);
            //// Suppress NRF_ERROR_NOT_SUPPORTED return code.
            //UNUSED_VARIABLE(err_code);
            break;

        case NRF_PWR_MGMT_EVT_PREPARE_DFU:
            NRF_LOG_ERROR("Entering DFU is not supported by this example.");
            APP_ERROR_HANDLER(NRF_ERROR_API_NOT_IMPLEMENTED);
            break;

        case NRF_PWR_MGMT_EVT_PREPARE_RESET:
            NRF_LOG_INFO("NRF_PWR_MGMT_EVT_PREPARE_RESET");
            break;
    }

    //err_code = app_timer_stop_all();
    //APP_ERROR_CHECK(err_code);

    return true;
}


/**@brief Register application shutdown handler with priority 0. */
NRF_PWR_MGMT_HANDLER_REGISTER(shutdown_handler, 0);


/** @brief Function to check VIN_DET_PIN status
*/
static void vin_pin_check(void)
{
    bool is_set = nrf_drv_gpiote_in_is_set(VIN_DET_PIN);
        
    if (is_set) {
        NRF_LOG_INFO("!!!! ACTIVE CHARGER DETECTED, PIN IS HIGH !!!!");

        // Initiate a shutdown as the device is on charge
        nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);
    }
    else {
        NRF_LOG_INFO("!!!! ACTIVE CHARGER NOT DETECTED, PIN IS LOW !!!!");
        // Carry on to the system boot-up
    }
}

Parents
  • Have you enabled logging from the power management module? Ref in sdk_config.h:

    // <e> NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED
    #define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0
    #endif
    // <o> NRF_PWR_MGMT_CONFIG_LOG_LEVEL  - Default Severity level
     
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL
    #define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3
    #endif
    
    // <o> NRF_PWR_MGMT_CONFIG_INFO_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRF_PWR_MGMT_CONFIG_INFO_COLOR
    #define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0
    #endif
    
    // <o> NRF_PWR_MGMT_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRF_PWR_MGMT_CONFIG_DEBUG_COLOR
    #define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0
    #endif
    
    // </e>

Reply
  • Have you enabled logging from the power management module? Ref in sdk_config.h:

    // <e> NRF_PWR_MGMT_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef NRF_PWR_MGMT_CONFIG_LOG_ENABLED
    #define NRF_PWR_MGMT_CONFIG_LOG_ENABLED 0
    #endif
    // <o> NRF_PWR_MGMT_CONFIG_LOG_LEVEL  - Default Severity level
     
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef NRF_PWR_MGMT_CONFIG_LOG_LEVEL
    #define NRF_PWR_MGMT_CONFIG_LOG_LEVEL 3
    #endif
    
    // <o> NRF_PWR_MGMT_CONFIG_INFO_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRF_PWR_MGMT_CONFIG_INFO_COLOR
    #define NRF_PWR_MGMT_CONFIG_INFO_COLOR 0
    #endif
    
    // <o> NRF_PWR_MGMT_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRF_PWR_MGMT_CONFIG_DEBUG_COLOR
    #define NRF_PWR_MGMT_CONFIG_DEBUG_COLOR 0
    #endif
    
    // </e>

Children
Related