User Manual
Jennic
JennicJennic
Jennic
40 JN-DS-JN5139 v1.5 © Jennic 2008
if the device is asleep then the interrupt may be used as an event to end the sleep period. See Section 16 for further
details on how they are used during sleep periods. Features include:
•
32-bit down-counter
•
Optionally runs during sleep periods
•
Clocked from 32 kHz RC oscillator
A wakeup timer consists of a 32-bit down counter clocked from the 32 kHz internal clock. An interrupt or wakeup
event can be generated when the counter reaches zero. On reaching zero the counter will continue to count down
until stopped, which allows the latency in responding to the interrupt to be measured. If an interrupt or wakeup event
is required, the timer interrupt should be enabled before loading the count value for the period. Once the count value
is loaded and counter started, the counter begins to count down; the counter can be stopped at any time through
software control. The counter will remain at the value it contained when the timer was stopped and no interrupt will
be generated. The status of the timers can be read to indicate if the timers are running and/or have expired; this is
useful when the timer interrupts are masked. If a timer has expired then the expired status will be reset by the
function.
12.3.1 RC Oscillator Calibration
The RC oscillator used to time sleep periods is designed to require very little power to operate and be self-contained,
requiring no external timing components and hence is lower cost. As a consequence of using on-chip resistors and
capacitors, the inherent absolute accuracy and temperature coefficient is lower than that of a crystal oscillator, but
once calibrated the accuracy approaches that of a crystal oscillator. Sleep time periods should be as close to the
desired time as possible in order to allow the device to wake up in time for important events, for example beacon
transmissions in the IEEE802.15.4 protocol. If the sleep time is accurate, the device can be programmed to wake up
very close to the calculated time of the event and so keep current consumption to a minimum. If the sleep time
is less accurate, it will be necessary to wake up earlier in order to be certain the event will be captured. If the device
wakes earlier, it will be awake for longer and so reduce battery life.
In order to allow sleep time periods to be as close to the desired length as possible, the true frequency of the RC
oscillator needs to be determined to better than the initial 30% accuracy. The calibration factor can then be used to
calculate the true number of nominal 32kHz periods needed to make up a particular sleep time. A calibration
reference timer, clocked from the crystal oscillator, is provided to allow comparisons to be made between the RC
clock and the 16MHz crystal oscillator when the JN5139 is awake. Operation is as follows:
•
Wakeup timer0 is disabled and programmed with a number of 32kHz ticks
•
Timer0 event status must be cleared
•
Calibration mode is enabled which causes the Calibration Reference counter to be zeroed. Both counters
start counting, the wakeup timer decrementing and the calibration counter incrementing
•
When the wakeup timer reaches zero the Reference Counter is stopped, allowing software to read the
number of 16MHz clock ticks generated during the time represented by the number of 32kHz ticks
programmed in the wakeup timer. The true period of the 32kHz clock can thus be determined and used
when programming a wakeup timer to achieve a better accuracy and hence more accurate sleep periods
For a RC oscillator running at exactly 32kHz the value returned by the calibration procedure should be 10000, for a
calibration period of twenty 32kHz clock periods. If the oscillator is running faster than 32kHz the count will be less
than 10000, if running slower the value will be higher. For a calibration count of 9000, indicating that the RC oscillator
period is running at approximately 35kHz, to time for a period of 2 seconds the timer should be loaded with 71,111
((10000/9000) x (32000 x 2)) rather than 64000.
12.3.2 External 32kHz Clock Source
It is possible to change the source of the 32kHz clock used for the sleep timers to an externally supplied 32kHz
reference clock on the CLK32K input (DIO9). This mode could allow the timer clock to be sourced from a very stable
oscillator module, allowing more accurate sleep cycle timings. (See section 17.2.3 I/O Characteristics, DIO9 is a 3V
tolerant input)










