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

POFWARN Example ?

nRF51822

I'm interested in setting up the the POFCON to enable me to get a POFWARN interrupt when the battery voltage drops below 2.7V.

The softdevice is enabled at the time of these calls.

The first two calls are fine - (pof_enable and pof_threshold). But the ClearPending causes an App_Error - err_code = 0x2001 which looks to be an SoC error / SVC handler missing.

err_code = sd_power_pof_enable(POWER_POFCON_POF_Enabled);
APP_ERROR_CHECK(err_code);

err_code = sd_power_pof_threshold_set(POWER_POFCON_THRESHOLD_V27);
APP_ERROR_CHECK(err_code);
	
err_code = sd_nvic_ClearPendingIRQ(POWER_CLOCK_IRQn);
APP_ERROR_CHECK(err_code);

err_code = sd_nvic_SetPriority(POWER_CLOCK_IRQn, NRF_APP_PRIORITY_HIGH);
APP_ERROR_CHECK(err_code);

err_code = sd_nvic_EnableIRQ(POWER_CLOCK_IRQn);
APP_ERROR_CHECK(err_code);

I have defined the POWER_CLOCK_INT Handler as below ...

void POWER_CLOCK_IRQHandler() { LEDState(BLUE_1SEC_BLINK); }

Any suggestions on what I may be doing wrong - or examples that I could reference ?

Thanks ! -Tim

Parents
  • Whoops - I keep forgetting that you've got to use the Event System when using the SoftDevice.

    Changed my code to register for Sys Events (glad that the error codes are clear - or I likely wouldn't have found my way there) - and works perfectly ! 2.69V and my RED LED starts blinkin' :-)

    err_code = sd_power_pof_enable(POWER_POFCON_POF_Enabled);
    APP_ERROR_CHECK(err_code);
    
    err_code = sd_power_pof_threshold_set(POWER_POFCON_THRESHOLD_V27);
    APP_ERROR_CHECK(err_code);
    	
    // Subscribe for Sys events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    
    
    static void sys_evt_dispatch(uint32_t sys_evt)
    {
        if (sys_evt == NRF_EVT_POWER_FAILURE_WARNING)
    	{
    		LEDState(RED_1SEC_BLINK);
    	}
    }
    
Reply
  • Whoops - I keep forgetting that you've got to use the Event System when using the SoftDevice.

    Changed my code to register for Sys Events (glad that the error codes are clear - or I likely wouldn't have found my way there) - and works perfectly ! 2.69V and my RED LED starts blinkin' :-)

    err_code = sd_power_pof_enable(POWER_POFCON_POF_Enabled);
    APP_ERROR_CHECK(err_code);
    
    err_code = sd_power_pof_threshold_set(POWER_POFCON_THRESHOLD_V27);
    APP_ERROR_CHECK(err_code);
    	
    // Subscribe for Sys events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    
    
    static void sys_evt_dispatch(uint32_t sys_evt)
    {
        if (sys_evt == NRF_EVT_POWER_FAILURE_WARNING)
    	{
    		LEDState(RED_1SEC_BLINK);
    	}
    }
    
Children
No Data
Related