Detailed 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. */

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. */
init.em4Wakeup = true;

All the low frequency oscillators can be used in EM4, however, the oscillator that is used must be be configured to be retained when going into EM4. This can be configured by using functions in the EMU module. See EMU_EM4Init and EMU_EM4Init_TypeDef. If an oscillator is retained in EM4, the user is also responsible for unlatching the retained configuration on a wakeup from EM4.

Data Structures

struct  CRYOTIMER_Init_TypeDef




enum  CRYOTIMER_Osc_TypeDef {
enum  CRYOTIMER_Period_TypeDef {
  cryotimerPeriod_1 = 0,
  cryotimerPeriod_2 = 1,
  cryotimerPeriod_4 = 2,
  cryotimerPeriod_8 = 3,
  cryotimerPeriod_16 = 4,
  cryotimerPeriod_32 = 5,
  cryotimerPeriod_64 = 6,
  cryotimerPeriod_128 = 7,
  cryotimerPeriod_256 = 8,
  cryotimerPeriod_512 = 9,
  cryotimerPeriod_1k = 10,
  cryotimerPeriod_2k = 11,
  cryotimerPeriod_4k = 12,
  cryotimerPeriod_8k = 13,
  cryotimerPeriod_16k = 14,
  cryotimerPeriod_32k = 15,
  cryotimerPeriod_64k = 16,
  cryotimerPeriod_128k = 17,
  cryotimerPeriod_256k = 18,
  cryotimerPeriod_512k = 19,
  cryotimerPeriod_1m = 20,
  cryotimerPeriod_2m = 21,
  cryotimerPeriod_4m = 22,
  cryotimerPeriod_8m = 23,
  cryotimerPeriod_16m = 24,
  cryotimerPeriod_32m = 25,
  cryotimerPeriod_64m = 26,
  cryotimerPeriod_128m = 27,
  cryotimerPeriod_256m = 28,
  cryotimerPeriod_512m = 29,
  cryotimerPeriod_1024m = 30,
  cryotimerPeriod_2048m = 31,
  cryotimerPeriod_4096m = 32
enum  CRYOTIMER_Presc_TypeDef {
  cryotimerPresc_1 = _CRYOTIMER_CTRL_PRESC_DIV1,
  cryotimerPresc_2 = _CRYOTIMER_CTRL_PRESC_DIV2,
  cryotimerPresc_4 = _CRYOTIMER_CTRL_PRESC_DIV4,
  cryotimerPresc_8 = _CRYOTIMER_CTRL_PRESC_DIV8,
  cryotimerPresc_16 = _CRYOTIMER_CTRL_PRESC_DIV16,
  cryotimerPresc_32 = _CRYOTIMER_CTRL_PRESC_DIV32,
  cryotimerPresc_64 = _CRYOTIMER_CTRL_PRESC_DIV64,
  cryotimerPresc_128 = _CRYOTIMER_CTRL_PRESC_DIV128


__STATIC_INLINE uint32_t CRYOTIMER_CounterGet (void)
 Get the CRYOTIMER counter value.
__STATIC_INLINE void CRYOTIMER_EM4WakeupEnable (bool enable)
 Enable/disable EM4 wakeup capability.
__STATIC_INLINE void CRYOTIMER_Enable (bool enable)
 Enable/disable the CRYOTIMER.
void CRYOTIMER_Init (const CRYOTIMER_Init_TypeDef *init)
 Initialize the CRYOTIMER.
__STATIC_INLINE void CRYOTIMER_IntClear (uint32_t flags)
 Clear the CRYOTIMER period interrupt.
__STATIC_INLINE void CRYOTIMER_IntDisable (uint32_t flags)
 Disable one or more CRYOTIMER interrupts.
__STATIC_INLINE void CRYOTIMER_IntEnable (uint32_t flags)
 Enable one or more CRYOTIMER interrupts.
__STATIC_INLINE uint32_t CRYOTIMER_IntGet (void)
 Get the CRYOTIMER interrupt flag.
__STATIC_INLINE uint32_t CRYOTIMER_IntGetEnabled (void)
 Get enabled and pending CRYOTIMER interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.
__STATIC_INLINE void CRYOTIMER_IntSet (uint32_t flags)
 Set the CRYOTIMER period interrupt flag.
__STATIC_INLINE uint32_t CRYOTIMER_PeriodGet (void)
 Get the CRYOTIMER period select value.
__STATIC_INLINE void CRYOTIMER_PeriodSet (uint32_t period)
 Set the CRYOTIMER period select.

Macro Definition Documentation

{ \
true, /* Start counting when the initialization is done. */ \
false, /* Disable CRYOTIMER during debug halt. */ \
false, /* Disable EM4 wakeup. */ \
cryotimerOscLFRCO, /* Select Low Frequency RC Oscillator. */ \
cryotimerPresc_1, /* LF Oscillator frequency undivided. */ \
cryotimerPeriod_4096m, /* Wakeup event after 4096 M pre-scaled clock cycles. */ \

Default CRYOTIMER init structure.

Definition at line 203 of file em_cryotimer.h.

Enumeration Type Documentation

Low frequency oscillator selection.


Select Low-frequency RC Oscillator.


Select Low-frequency Crystal Oscillator.


Select Ultra Low Frequency RC Oscillator.

Definition at line 130 of file em_cryotimer.h.

Period selection value


Wakeup event after every Pre-scaled clock cycle.


Wakeup event after 2 Pre-scaled clock cycles.


Wakeup event after 4 Pre-scaled clock cycles.


Wakeup event after 8 Pre-scaled clock cycles.


Wakeup event after 16 Pre-scaled clock cycles.


Wakeup event after 32 Pre-scaled clock cycles.


Wakeup event after 64 Pre-scaled clock cycles.


Wakeup event after 128 Pre-scaled clock cycles.


Wakeup event after 256 Pre-scaled clock cycles.


Wakeup event after 512 Pre-scaled clock cycles.


Wakeup event after 1k Pre-scaled clock cycles.


Wakeup event after 2k Pre-scaled clock cycles.


Wakeup event after 4k Pre-scaled clock cycles.


Wakeup event after 8k Pre-scaled clock cycles.


Wakeup event after 16k Pre-scaled clock cycles.


Wakeup event after 32k Pre-scaled clock cycles.


Wakeup event after 64k Pre-scaled clock cycles.


Wakeup event after 128k Pre-scaled clock cycles.


Wakeup event after 256k Pre-scaled clock cycles.


Wakeup event after 512k Pre-scaled clock cycles.


Wakeup event after 1m Pre-scaled clock cycles.


Wakeup event after 2m Pre-scaled clock cycles.


Wakeup event after 4m Pre-scaled clock cycles.


Wakeup event after 8m Pre-scaled clock cycles.


Wakeup event after 16m Pre-scaled clock cycles.


Wakeup event after 32m Pre-scaled clock cycles.


Wakeup event after 64m Pre-scaled clock cycles.


Wakeup event after 128m Pre-scaled clock cycles.


Wakeup event after 256m Pre-scaled clock cycles.


Wakeup event after 512m Pre-scaled clock cycles.


Wakeup event after 1024m Pre-scaled clock cycles.


Wakeup event after 2048m Pre-scaled clock cycles.


Wakeup event after 4096m Pre-scaled clock cycles.

Definition at line 137 of file em_cryotimer.h.

Prescaler selection.


Divide clock by 1.


Divide clock by 2.


Divide clock by 4.


Divide clock by 8.


Divide clock by 16.


Divide clock by 32.


Divide clock by 64.


Divide clock by 128.

Definition at line 118 of file em_cryotimer.h.

Function Documentation

__STATIC_INLINE uint32_t CRYOTIMER_CounterGet ( void  )

Get the CRYOTIMER counter value.

Returns the current CRYOTIMER counter value.

Definition at line 350 of file em_cryotimer.h.

__STATIC_INLINE void CRYOTIMER_EM4WakeupEnable ( bool  enable)

Enable/disable EM4 wakeup capability.

[in]enableTrue to enable EM4 wakeup, false to disable.

Definition at line 362 of file em_cryotimer.h.

References BUS_RegBitWrite().

Referenced by CRYOTIMER_Init().

__STATIC_INLINE void CRYOTIMER_Enable ( bool  enable)

Enable/disable the CRYOTIMER.

[in]enableTrue to enable the CRYOTIMER, false to disable.

Definition at line 376 of file em_cryotimer.h.

References BUS_RegBitWrite().

void CRYOTIMER_Init ( const CRYOTIMER_Init_TypeDef init)

Initialize the CRYOTIMER.

Use this function to initialize the CRYOTIMER. Select a prescaler setting and select a low-frequency oscillator. See the configuration structure CRYOTIMER_Init_TypeDef for more details.

[in]initA pointer to the initialization structure.

Definition at line 50 of file em_cryotimer.c.

References CRYOTIMER_EM4WakeupEnable(), CRYOTIMER_Init_TypeDef::debugRun, CRYOTIMER_Init_TypeDef::em4Wakeup, CRYOTIMER_Init_TypeDef::enable, CRYOTIMER_Init_TypeDef::osc, CRYOTIMER_Init_TypeDef::period, and CRYOTIMER_Init_TypeDef::presc.

__STATIC_INLINE void CRYOTIMER_IntClear ( uint32_t  flags)

Clear the CRYOTIMER period interrupt.

[in]flagsCRYOTIMER interrupt sources to clear. Use CRYOTIMER_IFC_PERIOD.

Definition at line 224 of file em_cryotimer.h.

__STATIC_INLINE void CRYOTIMER_IntDisable ( uint32_t  flags)

Disable one or more CRYOTIMER interrupts.

[in]flagsCRYOTIMER interrupt sources to disable. Use CRYOTIMER_IEN_PERIOD.

Definition at line 286 of file em_cryotimer.h.

__STATIC_INLINE void CRYOTIMER_IntEnable ( uint32_t  flags)

Enable one or more CRYOTIMER interrupts.

[in]flagsCRYOTIMER interrupt sources to enable. Use CRYOTIMER_IEN_PERIOD.

Definition at line 274 of file em_cryotimer.h.

__STATIC_INLINE uint32_t CRYOTIMER_IntGet ( void  )

Get the CRYOTIMER interrupt flag.

This function does not clear event bits.
Pending CRYOTIMER interrupt sources. The only interrupt source available for the CRYOTIMER is CRYOTIMER_IF_PERIOD.

Definition at line 240 of file em_cryotimer.h.

__STATIC_INLINE uint32_t CRYOTIMER_IntGetEnabled ( void  )

Get enabled and pending CRYOTIMER interrupt flags. Useful for handling more interrupt sources in the same interrupt handler.

This function does not clear interrupt flags.
Pending and enabled CRYOTIMER interrupt sources. The return value is the bitwise AND of
  • the enabled interrupt sources in CRYOTIMER_IEN and
  • the pending interrupt flags CRYOTIMER_IF

Definition at line 259 of file em_cryotimer.h.

__STATIC_INLINE void CRYOTIMER_IntSet ( uint32_t  flags)

Set the CRYOTIMER period interrupt flag.

Writes 1 to the interrupt flag set register.
[in]flagsCRYOTIMER interrupt sources to set to pending. Use CRYOTIMER_IFS_PERIOD.

Definition at line 302 of file em_cryotimer.h.

__STATIC_INLINE uint32_t CRYOTIMER_PeriodGet ( void  )

Get the CRYOTIMER period select value.

Gets the duration between the interrupts/wakeup events in the CRYOTIMER.
Duration between the interrupts/wakeup events. Returns the value of the PERIODSEL register. The number of clock cycles can be calculated as the 2^n where n is the return value of this function.

Definition at line 338 of file em_cryotimer.h.

__STATIC_INLINE void CRYOTIMER_PeriodSet ( uint32_t  period)

Set the CRYOTIMER period select.

Sets the duration between the interrupts/wakeup events based on the pre-scaled clock.
[in]period2^period is the number of clock cycles before a wakeup event or interrupt is triggered. The CRYOTIMER_Periodsel_TypeDef enumeration can be used a convenience type when calling this function.

Definition at line 320 of file em_cryotimer.h.