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

rtc use inside sleep mode?

i m using pca10028 with gcc tool chain setup in windows...now i m using sdk 8 and work inside ble_uart code...i was add rtc1 inside that code sucsessfully but now.. when device goes to sleep so rtc interrupt handler function not calling stop... so, can i use rtc for time counter inside sleep mode....

Parents
  • I would recommend that you go through the Application Timer Tutorial, but you create a timer with the timer library using the following code:

    static void timeout_handler(void * p_context)
    {
        printf("\r\nTimeout!\r\n");
    }
    
    int main(void)
    {
        APP_TIMER_DEF(my_timer_id);
        err_code = app_timer_create(&my_timer_id, APP_TIMER_MODE_REPEATED, timeout_handler);
        
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    
        static uint32_t timeout = 1000; // Timer timeout in ms
        err_code = app_timer_start(my_timer_id,  APP_TIMER_TICKS(timeout, APP_TIMER_PRESCALER), NULL);
    }
    

    Notice that in ble_app_uart example, the device is put in system off sleep mode when advertising times out. This will disable clock sources and thereby stop timers. You need to remove the call to sd_power_system_off() in sleep_mode_enter() function in main.c to avoid entering system off mode.

Reply
  • I would recommend that you go through the Application Timer Tutorial, but you create a timer with the timer library using the following code:

    static void timeout_handler(void * p_context)
    {
        printf("\r\nTimeout!\r\n");
    }
    
    int main(void)
    {
        APP_TIMER_DEF(my_timer_id);
        err_code = app_timer_create(&my_timer_id, APP_TIMER_MODE_REPEATED, timeout_handler);
        
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    
        static uint32_t timeout = 1000; // Timer timeout in ms
        err_code = app_timer_start(my_timer_id,  APP_TIMER_TICKS(timeout, APP_TIMER_PRESCALER), NULL);
    }
    

    Notice that in ble_app_uart example, the device is put in system off sleep mode when advertising times out. This will disable clock sources and thereby stop timers. You need to remove the call to sd_power_system_off() in sleep_mode_enter() function in main.c to avoid entering system off mode.

Children
No Data
Related