CRYOTIMER - Ultra Low Energy Timer#
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 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 */
CMU_ClockEnable(cmuClock_CRYOTIMER, true);
/* 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. */
CRYOTIMER_Init_TypeDef init = CRYOTIMER_INIT_DEFAULT;
init.osc = cryotimerOscULFRCO;
init.presc = cryotimerPresc_1;
init.period = cryotimerPeriod_128;
CRYOTIMER_Init(&init);
/* 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 by calling CRYOTIMER_IntClear. If the you do 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 */
CMU_ClockEnable(cmuClock_CRYOTIMER, true);
/* Configure the CRYOTIMER to use the ULFRCO which is running at 1 KHz
* and trigger an EM4 wakeup every 1024/1000 = 1,024s. */
CRYOTIMER_Init_TypeDef init = CRYOTIMER_INIT_DEFAULT;
init.osc = cryotimerOscULFRCO;
init.presc = cryotimerPresc_1;
init.period = cryotimerPeriod_1k;
init.em4Wakeup = true;
CRYOTIMER_Init(&init);
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 by using functions in the EMU - Energy Management Unit module. See EMU_EM4Init and EMU_EM4Init_TypeDef. If an oscillator is retained in EM4, users are also responsible for unlatching the retained configuration on a wakeup from EM4.
Modules#
Enumerations#
Prescaler selection.
Low frequency oscillator selection.
Period selection value.
Functions#
Clear the CRYOTIMER period interrupt.
Get the CRYOTIMER interrupt flag.
Get enabled and pending CRYOTIMER interrupt flags.
Enable one or more CRYOTIMER interrupts.
Disable one or more CRYOTIMER interrupts.
Set the CRYOTIMER period interrupt flag.
Set the CRYOTIMER period select.
Get the CRYOTIMER period select value.
Get the CRYOTIMER counter value.
Enable/disable EM4 wakeup capability.
Enable/disable the CRYOTIMER.
Initialize the CRYOTIMER.
Macros#
Default CRYOTIMER init structure.
Enumeration Documentation#
CRYOTIMER_Presc_TypeDef#
CRYOTIMER_Presc_TypeDef
Prescaler selection.
Enumerator | |
---|---|
cryotimerPresc_1 | Divide clock by 1. |
cryotimerPresc_2 | Divide clock by 2. |
cryotimerPresc_4 | Divide clock by 4. |
cryotimerPresc_8 | Divide clock by 8. |
cryotimerPresc_16 | Divide clock by 16. |
cryotimerPresc_32 | Divide clock by 32. |
cryotimerPresc_64 | Divide clock by 64. |
cryotimerPresc_128 | Divide clock by 128. |
112
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_Osc_TypeDef#
CRYOTIMER_Osc_TypeDef
Low frequency oscillator selection.
Enumerator | |
---|---|
cryotimerOscLFRCO | Select Low-frequency RC Oscillator. |
cryotimerOscLFXO | Select Low-frequency Crystal Oscillator. |
cryotimerOscULFRCO | Select Ultra Low Frequency RC Oscillator. |
124
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_Period_TypeDef#
CRYOTIMER_Period_TypeDef
Period selection value.
Enumerator | |
---|---|
cryotimerPeriod_1 | Wakeup event after every Pre-scaled clock cycle. |
cryotimerPeriod_2 | Wakeup event after 2 Pre-scaled clock cycles. |
cryotimerPeriod_4 | Wakeup event after 4 Pre-scaled clock cycles. |
cryotimerPeriod_8 | Wakeup event after 8 Pre-scaled clock cycles. |
cryotimerPeriod_16 | Wakeup event after 16 Pre-scaled clock cycles. |
cryotimerPeriod_32 | Wakeup event after 32 Pre-scaled clock cycles. |
cryotimerPeriod_64 | Wakeup event after 64 Pre-scaled clock cycles. |
cryotimerPeriod_128 | Wakeup event after 128 Pre-scaled clock cycles. |
cryotimerPeriod_256 | Wakeup event after 256 Pre-scaled clock cycles. |
cryotimerPeriod_512 | Wakeup event after 512 Pre-scaled clock cycles. |
cryotimerPeriod_1k | Wakeup event after 1k Pre-scaled clock cycles. |
cryotimerPeriod_2k | Wakeup event after 2k Pre-scaled clock cycles. |
cryotimerPeriod_4k | Wakeup event after 4k Pre-scaled clock cycles. |
cryotimerPeriod_8k | Wakeup event after 8k Pre-scaled clock cycles. |
cryotimerPeriod_16k | Wakeup event after 16k Pre-scaled clock cycles. |
cryotimerPeriod_32k | Wakeup event after 32k Pre-scaled clock cycles. |
cryotimerPeriod_64k | Wakeup event after 64k Pre-scaled clock cycles. |
cryotimerPeriod_128k | Wakeup event after 128k Pre-scaled clock cycles. |
cryotimerPeriod_256k | Wakeup event after 256k Pre-scaled clock cycles. |
cryotimerPeriod_512k | Wakeup event after 512k Pre-scaled clock cycles. |
cryotimerPeriod_1m | Wakeup event after 1m Pre-scaled clock cycles. |
cryotimerPeriod_2m | Wakeup event after 2m Pre-scaled clock cycles. |
cryotimerPeriod_4m | Wakeup event after 4m Pre-scaled clock cycles. |
cryotimerPeriod_8m | Wakeup event after 8m Pre-scaled clock cycles. |
cryotimerPeriod_16m | Wakeup event after 16m Pre-scaled clock cycles. |
cryotimerPeriod_32m | Wakeup event after 32m Pre-scaled clock cycles. |
cryotimerPeriod_64m | Wakeup event after 64m Pre-scaled clock cycles. |
cryotimerPeriod_128m | Wakeup event after 128m Pre-scaled clock cycles. |
cryotimerPeriod_256m | Wakeup event after 256m Pre-scaled clock cycles. |
cryotimerPeriod_512m | Wakeup event after 512m Pre-scaled clock cycles. |
cryotimerPeriod_1024m | Wakeup event after 1024m Pre-scaled clock cycles. |
cryotimerPeriod_2048m | Wakeup event after 2048m Pre-scaled clock cycles. |
cryotimerPeriod_4096m | Wakeup event after 4096m Pre-scaled clock cycles. |
131
of file platform/emlib/inc/em_cryotimer.h
Function Documentation#
CRYOTIMER_IntClear#
void CRYOTIMER_IntClear (uint32_t flags)
Clear the CRYOTIMER period interrupt.
[in] | flags | CRYOTIMER interrupt sources to clear. Use CRYOTIMER_IFC_PERIOD. |
218
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_IntGet#
uint32_t CRYOTIMER_IntGet (void )
Get the CRYOTIMER interrupt flag.
N/A |
Note
This function does not clear event bits.
Returns
Pending CRYOTIMER interrupt sources. The only interrupt source available for the CRYOTIMER is CRYOTIMER_IF_PERIOD.
234
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_IntGetEnabled#
uint32_t CRYOTIMER_IntGetEnabled (void )
Get enabled and pending CRYOTIMER interrupt flags.
N/A |
Useful for handling more interrupt sources in the same interrupt handler.
Note
This function does not clear interrupt flags.
Returns
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
253
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_IntEnable#
void CRYOTIMER_IntEnable (uint32_t flags)
Enable one or more CRYOTIMER interrupts.
[in] | flags | CRYOTIMER interrupt sources to enable. Use CRYOTIMER_IEN_PERIOD. |
268
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_IntDisable#
void CRYOTIMER_IntDisable (uint32_t flags)
Disable one or more CRYOTIMER interrupts.
[in] | flags | CRYOTIMER interrupt sources to disable. Use CRYOTIMER_IEN_PERIOD. |
280
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_IntSet#
void CRYOTIMER_IntSet (uint32_t flags)
Set the CRYOTIMER period interrupt flag.
[in] | flags | CRYOTIMER interrupt sources to set to pending. Use CRYOTIMER_IFS_PERIOD. |
Note
Writes 1 to the interrupt flag set register.
296
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_PeriodSet#
void CRYOTIMER_PeriodSet (uint32_t period)
Set the CRYOTIMER period select.
[in] | period | 2^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. |
Note
Sets the duration between the interrupts/wakeup events based on the pre-scaled clock.
314
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_PeriodGet#
uint32_t CRYOTIMER_PeriodGet (void )
Get the CRYOTIMER period select value.
N/A |
Note
Gets the duration between the interrupts/wakeup events in the CRYOTIMER.
Returns
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.
332
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_CounterGet#
uint32_t CRYOTIMER_CounterGet (void )
Get the CRYOTIMER counter value.
N/A |
Returns
Returns the current CRYOTIMER counter value.
344
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_EM4WakeupEnable#
void CRYOTIMER_EM4WakeupEnable (bool enable)
Enable/disable EM4 wakeup capability.
[in] | enable | True to enable EM4 wakeup, false to disable. |
356
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_Enable#
void CRYOTIMER_Enable (bool enable)
Enable/disable the CRYOTIMER.
[in] | enable | True to enable the CRYOTIMER, false to disable. |
370
of file platform/emlib/inc/em_cryotimer.h
CRYOTIMER_Init#
void CRYOTIMER_Init (const CRYOTIMER_Init_TypeDef * init)
Initialize the CRYOTIMER.
[in] | init | A pointer to the initialization structure. |
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.
390
of file platform/emlib/inc/em_cryotimer.h
Macro Definition Documentation#
CRYOTIMER_INIT_DEFAULT#
#define CRYOTIMER_INIT_DEFAULTValue:
Default CRYOTIMER init structure.
197
of file platform/emlib/inc/em_cryotimer.h