Hi all ...
My product uses multiple BLE peripherals (Simblee by RF Digital) communicating with a common BLE central to time events detected via sensors on the different devices. My circuit has a DS3231 (Maxim) to get required accuracy (+/-2ppm). The DS3231 resolution is only 1 Hz, so I'm using its square wave output to drive a GPIO pin, and I use TIMER1 and TIMER2 to implement my own RTC.
TIMER1 is configured as a counter to count seconds, TIMER2 as a free running timer to time time between seconds (prescaler 9). Using GPIOTE and PPI, each time the GPIO pin goes hi (on each pulse from the DS3231):
- TIMER1 increments
- TIMER2 clears
When an event occurs, I simply capture the timer values. TIMER1 will be current seconds, TIMER2 will be current ticks since last second pulse. With prescaler 9 I divide ticks by 31250 to get seconds and add to the second count to get actual time.
Here's the issue: I'm actually getting 31708 ticks per second instead of the expected 31250, so I'm trying to determine the accuracy of the timers, with hope that there's a way to increase it.
Thanks,
Tim