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

delay by timer

i want make delay funtion by timer?

in the other MCU like PIC, AVR, stm. i find register that hold value counter and i cant set this value for example: timer 8 bit will count to 256 and i set value =100 to every tick it increased to 256 overflow and make a period delay.

thanks.

Parents
  • Hello phanhust

    On the nRF51822 you have 3 timer modules which run on the HFCLK, and the RTC (real time counter) which runs on the LFCLK.

    When using the SoftDevice the first timer module, TIMER0 is controlled by the SoftDevice and is off limits for the application. Due to the timer modules using the HFCLK the current consumption while using them is considerable, and they should only be used for cases where high timing accuracy is needed. For use-cases with lower accuracy requirements, you can use the RTC which has much lower current consumption. Most examples in the SDK uses the timer library, which employs the RTC.

    You can read more about the Timer modules on page 33 and 62 of the nRF51822 product specification, and page 99 of the nRF51 series Reference manual.

    You can read about the RTC on page 33 and 62 of the product specification and page 103 of the reference manual.

    You can read about the timer library here.

    You can find examples for both the RTC and the timer modules in the examples\peripheral folder in the SDK, and you can find documentation for the examples on the infocenter (The provided link is for SDK12.3).

    Best regards

    Jørn Frøysa

  • Yes the example codes in the SDK typically use the drivers or libraries which come with it. The example you link to is the bare-metal implementation of the timer operation, so it's as direct and "simple" as you can get. I'm not sure I've fully understood what it is you want to do. What to do you mean by "delay function"? Do you mean you want to prevent the CPU from continuing in the program for a certain amount of time?

Reply
  • Yes the example codes in the SDK typically use the drivers or libraries which come with it. The example you link to is the bare-metal implementation of the timer operation, so it's as direct and "simple" as you can get. I'm not sure I've fully understood what it is you want to do. What to do you mean by "delay function"? Do you mean you want to prevent the CPU from continuing in the program for a certain amount of time?

Children
No Data
Related