Accurate timing in deep-sleep

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accurate timing in deep-sleep

440 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Muis on Thu Dec 20 12:27:19 MST 2012
I need to take 256 ADC samples per second, and deep-sleep in between. In the documentation I read that the Watchdog timer (which is used to wakeup from deep sleep), is very inaccurate (40%). Im worried that this will cause a lot of jitter, in other words: that the signal is sampled at irregular intervals.

Is there any way to use deep-sleep, and still wakeup accurately enough to sample at exactly 256 Hz?

Labels (1)
0 Kudos
4 Replies

396 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Muis on Thu Jan 03 17:54:40 MST 2013
I have seen that example before, but the problem was that it's written for the LPC1114 which features a different WDT than the (windowed) one in the LPC11U14. So most registers have different names, and I find it hard to port the code.
0 Kudos

396 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Muis on Thu Jan 03 17:52:51 MST 2013
Thanks for your excellent response! It's a little above my head, but I just realised there will also be a RTC on the board (NXP PCF8563) which seems to be able to generate a 256 Hz clock out signal, so I guess it will be easier (and more accurate) to use that as an interrupt to wake up from deep-sleep. But Im sure your explanation will come in handy to other forum members trying to solve this without an external RTC.
0 Kudos

396 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DF9DQ on Fri Dec 21 03:06:29 MST 2012
The first step to an accurate repetitive interrupt is to measure the Watchdog frequency, just as <strong>Zero</strong> has pointed out. The basic idea is to use either the IRC (1%) or a crystal as a time base for the frequency measurement. Knowing the real Watchdog oscillator frequency allows you to adjust the wakeup timer interval accordingly.

The second step is to ensure a minimum jitter. Self-timed wakeup from deep-sleep mode must use a timer that runs from the system (CPU) clock. This clock is derived from watchdog oscillator during deep-sleep, but will be switched over to IRC or crystal in the active periods. Unfortunately, this discontinuous clocking of the timer makes it hard, if not impossible, to use it to fire at regular intervals. (Many applications actually don't have an issue here, and can just setup the sleep interval after each activity period).

There is a solution to this problem, but it comes at the cost of using two extra pins. You can use CLKOUT to output the (divided) watchdog oscillator. Connect this to the capture input of the timer that's being used for the self-timed wakeup. Use that timer in counter mode, so that it increments with every CLKOUT pulse. This provides you with a time base that is independent of the system clock frequency.

Note that the capture input of the timer is sampled with the timer's peripheral clock, which is the system (CPU) clock in the LPC1100. So in order for the counter mode to work, ensure that the system clock is higher than 2.5x the CLKOUT frequency at all times.

Regards,
Rolf
0 Kudos

395 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Dec 20 17:33:47 MST 2012
IIRC there is a sample in LPCXpresso which is called  'timedwakeup'.
This sample is using a timer to measure watchdog timer and improve wakeup time.
I'm not sure if that's exact enough for 256 Hz, but that's a good way to handle this horrible watchdog accuracy. 
0 Kudos