alternate for nrf_delay_ms

hello,

i am using nrf52832 with lis3dh accelarometer and max30205 temperature sensor in our customised board with sdk 15.2 in my driver for temperature sensor i am using delay function

i need any alternate for delay function which consumes less current 

while (m_xfer_done == false)
;
nrf_delay_ms(5);// in this line i have to wait for 5 ms 

thanks and regards

manikanadan v

Parents Reply Children
  • There are similar requests in the devzone like this one.. That should help you to atleast show the logic of how to use a one shot delay using app_timer

  • hello,  

    i already know how to use an app timer 

    static volatile bool m_le_delay_flag = false;

    err_code = app_timer_create(&m_delay, APP_TIMER_MODE_SINGLE_SHOT, timer_evt_Delay);
    APP_ERROR_CHECK(err_code);

    static void power_manage(void) {
    uint32_t err_code = sd_app_evt_wait();
    APP_ERROR_CHECK(err_code);
    }

    /** function for calling low power delay */
    uint8_t nrf_delay_ms_app(int ms_delay) {

    uint32_t err_code;
    err_code = app_timer_start(m_delay, APP_TIMER_TICKS(ms_delay), NULL);
    APP_ERROR_CHECK(err_code);
    m_delay_flag = true;
    while (m_delay_flag) {
    power_manage();
    }
    return 0;
    }

    static void timer_evt_Delay(void *p_context) {

    printf("delay\n");
    m_delay_flag = false;
    }

    but when i call  nrf_delay_ms_app(10); in my application my program get alted in  bove while loop do you happen to know the reason befind this (note :i am calling this function inside an another app timer handler ) kindly check and tell me how can i rectify this

    thanks and regards

    manikandan v

  • you cant call this function from another timer handler since the timer handler is called from RTC interrupt handler and you should not be waiting in a while loop in those handlers. The fundemental idea of you trying to create delay in timer callback handler in itself is not correct.

Related