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

Precision of TIMER1

Hi there,

I'm using nrf51822 timer1 as the timer for some time-critical task, and I'd like to ask two questions about it:

  1. What's the precision of Timer1 if the internal 256K clock is used?

  2. If some instructions need to be executed in the interrupt handler of timer1, will this impact the precision?

Any feedback will be really appreciated.

Thanks, Stanley

  • well there isn't an internal 256k clock so it's hard to know what you're asking. There's an internal 16MHz clock and an internal 32kHz clock however it's very unlikely that you don't have at least an external 16MHz crystal as well so the precision of TIMER1 would be the precision of that crystal, if you have it running, or the precision of the internal oscillator if you don't. The latter precision is in the spec sheet as typically +/- 1% with a max of +/- 5%.

    And the answer to 2 depends on how you write your code. The timer counts all the time regardless of what you're doing in the code or interrupt handler, so as long as you write the code to interrupt on a regular count multiple it doesn't matter a bit how long you spend in the interrupt handler. If you do something silly like resetting the counter in the interrupt handler, then it does matter as the point the counter resets is dependent on the code and how long it took to take the interrupt.

  • Thanks RK.

    Sorry for not declaring it clearly. The 256K is scaled from internal 16M clock. The precision of crystal I measured is actually in the range of 2% ~ 4%, just like you mentioned here.

    Regarding the interrupt handler, it's as same as what I observed from my test. Thanks for the confirmation.

Related