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

Is there any setting for using WFE();?

Hi,

In my proejct, I am using WFE(); in some while loops because of core low power mode.

For example, waiting for time_out flags like codes below.

I am wondering if it is helpful to use WFE(); in terms of power consumption and if the example usage is proper.

Also, the other question is do I need to set up anything (interrupt pin or timer) to wake device up from the WFE low power mode state? or just call WFE(); anywhere if I use while loop?

int i2c_read(i2c_s *objuint8_t devAddruint8_t *datauint8_t length)
{
    i2c_xfer_done[obj->instance] = false;
    int retry = I2C_RETRY_NUM;

    ret_code_t err_code = nrf_drv_twi_rx(obj->i2c_dev, devAddr, data, length);
    if (err_code != NRFX_SUCCESS)
    {
        debug_verbose(NON_CRITICAL_ERROR, SENSOR_CONTROL_CATEGORY, "i2c_read: nrf_drv_twi_init error\r\n");
    }
    while (i2c_xfer_done[obj->instance] == false && retry--)
    {
#ifdef SOFTDEVICE_PRESENT
        if(nrf_sdh_is_enabled())
        {
            sd_app_evt_wait();
        }
        else
#endif // SOFTDEVICE_PRESENT
        {
            __WFE();
        }
    }
    if (retry < 0)
    {
        err_code = NRFX_ERROR_TIMEOUT;
    }
    return err_code;
}
    while(get_interruptPin_level_C() == 0 && !timed_out) // TODO: app timer expired immediately
    // while(get_interruptPin_level_C() == 0 && (timeOutTicks > os_getTime() - startTick))
    {
#ifdef SOFTDEVICE_PRESENT
        if(nrf_sdh_is_enabled())
        {
            sd_app_evt_wait();
        }
        else
#endif // SOFTDEVICE_PRESENT
        {
            __WFE();
        }
    }
Thanks!
Parents Reply Children
No Data
Related