CRYOTIMER - Ultra Low Energy Timer

Description

Ultra Low Energy Timer/Counter (CRYOTIMER) Peripheral API.

The CRYOTIMER is a 32 bit counter which operates on a low-frequency oscillator and is capable of running in all Energy Modes. It can provide periodic wakeup events and PRS signals which can be used to wake up peripherals from any energy mode. The CRYOTIMER provides a very wide range of periods for the interrupts facilitating flexible ultra-low energy operation. Because of its simplicity, the CRYOTIMER is a lower energy solution for periodically waking up the MCU compared to the RTCC.

To configure the CRYOTIMER, call the CRYOTIMER_Init function. This function will configure the CRYOTIMER peripheral according to the user configuration.

When using the CRYOTIMER, choose which oscillator to use as the CRYOTIMER clock. The CRYOTIMER supports 3 low-frequency clocks LFXO, LFRCO, and ULFRCO. The oscillator that is chosen must be enabled and ready before calling this CRYOTIMER_Init function. See CMU_OscillatorEnable for details of how to enable and wait for an oscillator to become ready. Note that ULFRCO is always ready while LFRCO cmuOsc_LFRCO and LFXO cmuOsc_LFXO must be enabled by the user.

Note that the only oscillator which is running in EM3 is ULFRCO. Keep this in mind when choosing which oscillator to use for the CRYOTIMER.

This example shows how to use the CRYOTIMER to generate an interrupt at a configurable period.

/* Enable clock to CRYOTIMER module */
/* Configure the CRYOTIMER to use the ULFRCO which is running at 1 KHz
* and trigger an interrupt every 128/1000 = 0,128s using the period
* interrupt. */
/* Now we enable the period interrupt in the CRYOTIMER and we enable
* the CRYOTIMER IRQ in the NVIC. */
CRYOTIMER_IntEnable (CRYOTIMER_IEN_PERIOD);
NVIC_EnableIRQ(CRYOTIMER_IRQn);

To use the CRYOTIMER in EM4, enable EM4 wakeup in the CRYOTIMER. This can be done either in the CRYOTIMER_Init_TypeDef structure when initializing the CRYOTIMER or at a later time by using CRYOTIMER_EM4WakeupEnable .

Note that when using the CRYOTIMER to wake up from EM4, the application has the responsibility to clear the wakeup event. This is done by calling CRYOTIMER_IntClear . If the user does not clear the wakeup event, the wakeup event will stay pending and will cause an immediate wakeup the next time the application attempts to enter EM4.

This example shows how to use the CRYOTIMER to wake up from EM4 after a configurable amount of time.

/* Enable clock to CRYOTIMER module */
/* Configure the CRYOTIMER to use the ULFRCO which is running at 1 KHz
* and trigger an EM4 wakeup every 1024/1000 = 1,024s. */