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

How can I generate 7 sec delay using app timer in SDK_13 ?

I am new in the nRF52832 controller so help me for coding of my question. any help will be appreciated. thank you.

Parents
  • Havent tested this, but it should work

    #include "app_timer.h"
    #include "app_error.h"
    #define TICKS_7_SECONDS APP_TIMER_TICKS(7000)
    
    APP_TIMER_DEF(my_timer);
    
    static void my_timer_timeout_handler(void * p_context)
    {
        // 7 seconds passed. 
        // Do something
    }
    
    int main(void)
    {
        
        uint32_t err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
        
        err_code = app_timer_create(&my_timer, APP_TIMER_MODE_SINGLE_SHOT, my_timer_timeout_handler);
        APP_ERROR_CHECK(err_code);
        
        err_code = app_timer_start(my_timer, TICKS_7_SECONDS, NULL);
        APP_ERROR_CHECK(err_code);
        
        for(;;)
        {
            // Busy waiting
        }
        return 0;
    }
    
Reply
  • Havent tested this, but it should work

    #include "app_timer.h"
    #include "app_error.h"
    #define TICKS_7_SECONDS APP_TIMER_TICKS(7000)
    
    APP_TIMER_DEF(my_timer);
    
    static void my_timer_timeout_handler(void * p_context)
    {
        // 7 seconds passed. 
        // Do something
    }
    
    int main(void)
    {
        
        uint32_t err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
        
        err_code = app_timer_create(&my_timer, APP_TIMER_MODE_SINGLE_SHOT, my_timer_timeout_handler);
        APP_ERROR_CHECK(err_code);
        
        err_code = app_timer_start(my_timer, TICKS_7_SECONDS, NULL);
        APP_ERROR_CHECK(err_code);
        
        for(;;)
        {
            // Busy waiting
        }
        return 0;
    }
    
Children
Related