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

some question of nrf51822 timer

I am developing using a nrf51822.I need delay timer that can be substitued for nrf_delay_ms(). in other words,need a task delay that can be taken some event from another side during delay time. Is nrf_timer_delay_ms() possible ? If so,please tell me how to use and attention point regarding sw side and hw side. BR

Parents Reply Children
  • Hi hjjeon

    If you want to sleep during your delay instead of executing code, in order to save power, you can do the following:

    1. Set up your TIMER interrupt with the desired delay and enable the interrupt.
    2. When you want a delay, start the timer and go to sleep with the __WFI command (see nRF51 Series Reference Manual (RM) v2.1, section 11.1.3.
    3. When the timer expires, it will generate an interrupt, the chip will wake up and execute your defined interrupt handler.
    4. The TIMER interrupt handler stops the TIMER and resets it, making the TIMER counter to be zero.
    5. When the interrupt handler finishes execution, code execution will continue in the main thread, starting with the command after your __WFI command.
    6. Whenever you want a delay again in your code execution, simply start the timer and issue __WFI command.
Related