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

Handling Blink timers and using LED one-shot

Hi,

I have a app that using a constantly blinking LED started at power-up, however I am having some trouble stopping the timer.. (Yes, I know it's simple.. but i still cant figure out where)

This is my timer

err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(8, APP_TIMER_PRESCALER), NULL);

How do I turn it off? (stopping the timer)..I need to destroy this timer in bsp_init I think) app_timer_create(&m_leds_timer_id, APP_TIMER_MODE_SINGLE_SHOT, leds_timer_handler);

I have another question .. in another post someone asked for a 1 second Timer (one shot) and this code below was suggested to turn off an LED using a temp timer.. and also referred to rtc1.h. Is this usable in use PCA20006 for SMART BEACON??? I can't find the header or any reference to rtc1_timeout_set_ms in samples.

This was the code suggested in the other post.

static void ledice (void)
{    
        
        rtc1_timeout_set_ms(500);

        LEDS_ON(BSP_LED_0_MASK);

        while (!rtc1_timeout()) { }   

        LEDS_OFF(BSP_LED_0_MASK);
}

Sorry for these questions... to be honest, I am just bad at timer irqs... sorry

Thanks JJ

Parents
  • The bsp module is indeed not easy to use and we are working on improving it.

    The bsp module uses one shot timer and starts a new timer in the event handler based on the state. If the state is IDLE it will not start a new timer, hence this is the way you stop the constant blinking. You can set the state with:

    uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
    APP_ERROR_CHECK(err_code);
    

    You should use app_timer and not rtc1.h. App_timer uses the RTC1 peripheral so if you try to use both app_timer and rtc1.h you will run into trouble. See this tutorial on how to use the app_timer module.

Reply
  • The bsp module is indeed not easy to use and we are working on improving it.

    The bsp module uses one shot timer and starts a new timer in the event handler based on the state. If the state is IDLE it will not start a new timer, hence this is the way you stop the constant blinking. You can set the state with:

    uint32_t err_code = bsp_indication_set(BSP_INDICATE_IDLE);
    APP_ERROR_CHECK(err_code);
    

    You should use app_timer and not rtc1.h. App_timer uses the RTC1 peripheral so if you try to use both app_timer and rtc1.h you will run into trouble. See this tutorial on how to use the app_timer module.

Children
No Data
Related