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