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

how can i make system tick funtion?

I know that nrf51822 is not supported system tick handler ? I need system tick function. How can i make system tick function for nrf51822?

Parents
  • If you need exactly 1 ms ticks, you will have to use the 16 MHz timers, since the low-frequency clock is 32.768 kHz (32768 Hz), giving ticks with a frequency of 32768/(32+1) = 992.96... Hz.

    The 16 MHz timers does not have a TICK interrupt, so to use them for such purpose, I'd recommend to set the PRESCALER register to something appropriate, set one of the CC values correctly and enable the COMPAREX_CLEAR shortcut, so that the timer restarts on each compare. After this, you can enable the COMPAREX interrupt in INTEN and the TIMERX interrupt in the NVIC, and then just start the TIMER and let it run.

    For completeness, making a tick is easier with the RTC; you just set the PRESCALER correctly, enable the TICK interrupt in INTEN and the RTC interrupt in the NVIC and then start the RTC. Remember to start the LFCLK before starting the RTC.

Reply
  • If you need exactly 1 ms ticks, you will have to use the 16 MHz timers, since the low-frequency clock is 32.768 kHz (32768 Hz), giving ticks with a frequency of 32768/(32+1) = 992.96... Hz.

    The 16 MHz timers does not have a TICK interrupt, so to use them for such purpose, I'd recommend to set the PRESCALER register to something appropriate, set one of the CC values correctly and enable the COMPAREX_CLEAR shortcut, so that the timer restarts on each compare. After this, you can enable the COMPAREX interrupt in INTEN and the TIMERX interrupt in the NVIC, and then just start the TIMER and let it run.

    For completeness, making a tick is easier with the RTC; you just set the PRESCALER correctly, enable the TICK interrupt in INTEN and the RTC interrupt in the NVIC and then start the RTC. Remember to start the LFCLK before starting the RTC.

Children
Related