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

getting incorrect output using the timer_example_timer_mode example

My goal is to generate the clock signal of some particular frequency. I am using nrf51822 DK and used the timer example code from github: github.com/.../main.c. With timer prescalar set to 0 , the output frequency should be 16Mhz. but the output frequency I am getting is 243hz. And as i increase prescalar value the output frequency keeps decreasing from 243 hz. Can anyone tell me what might be the problem? I used oscilloscope to measure the frequency at the output pin at which the signal is generated.

Parents
  • Hello Nikhil

    I believe the result you see is correct. The example toggles a led on two compare values of the timer. The led then blinks with a frequency of approximately 244 Hz (4,098ms period time on my logic analyzer). This is however NOT the timer frequency of 16 MHz. The timer counts through 65536 values during one LED period. To find the actual timer frequency you take 65536/0,004098 = 15992191Hz, approximately 16MHz as decribed in the example.

    Best regards

    Jørn Frøysa

  • Unfortunately it is practically impossible to generate a 16MHz signal. The best I have found is 8MHz using a timer, PPI and GPIOTE, here. However we cannot guarantee stable and reliable operation, so use it at your own risk.

Reply Children
No Data
Related