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

POFCON power fail comparator requires delay to insure event?

The product spec says "This event will also be generated if the supply voltage is already below VPOF at the time the POF is enabled" but it seems like the event is not generated until after a delay, which the product spec does not seem to specify.

Attached is code I used to test, where I enable the POFCON and immediately check for the event, with or without an intervening delay.

There also might be a difference between the nrf51 and nrf52, since my code to check battery level using the POFCON (not the code attached) seemed to work on the nrf51.

Also, in nrf_drivers/hal/power.h, the function nrf_power_pofcon_set() does not flush the ARM write cache. So its effect would not be ensured until some time later, when the next RAM read occurred and flushes the write cache.

Environment: SDK12.2 and not using BT or softdevice, tested on uBlox NINA via NRF52DK.

main.cpp

  • Hi,

    Yes, there seem to be a delay between when the POF is enabled and when the event is generated. This is probably due to the internal workings of the module (the event is not generated before the POF starts, sets the threshold and then detects that the VDD is below the threshold). I can check this with the hardware devs if you want.

    Also the CPU runs at 64 MHz and the peripheral bus at 16 MHz, which will add more delays (this is why you should use a barrier by reading NRF_POWER->POFCON).

    I would recommend to use an event handler:

    nrf_drv_power_pofwarn_config_t pof_config;
    pof_config.thr = NRF_POWER_POFTHR_V28;
    pof_config.handler = my_pof_handler;
    
    nrf_drv_power_pof_init(&pof_config);
    

    Ole

Related