RTCC - Real Timer Counter/Calendar#

Real Time Counter and Calendar (RTCC) Peripheral API.

This module contains functions to control the RTCC peripheral of Silicon Labs 32-bit MCUs and SoCs. The RTCC ensures timekeeping in low energy modes. The RTCC also includes a BCD calendar mode for easy time and date keeping.

Modules#

RTCC_Init_TypeDef

RTCC_CCChConf_TypeDef

Enumerations#

enum
rtccCntModeNormal = _RTCC_CTRL_CNTMODE_NORMAL
rtccCntModeCalendar = _RTCC_CTRL_CNTMODE_CALENDAR
}

Operational mode of the counter.

enum
rtccCntPresc_1 = _RTCC_CTRL_CNTPRESC_DIV1
rtccCntPresc_2 = _RTCC_CTRL_CNTPRESC_DIV2
rtccCntPresc_4 = _RTCC_CTRL_CNTPRESC_DIV4
rtccCntPresc_8 = _RTCC_CTRL_CNTPRESC_DIV8
rtccCntPresc_16 = _RTCC_CTRL_CNTPRESC_DIV16
rtccCntPresc_32 = _RTCC_CTRL_CNTPRESC_DIV32
rtccCntPresc_64 = _RTCC_CTRL_CNTPRESC_DIV64
rtccCntPresc_128 = _RTCC_CTRL_CNTPRESC_DIV128
rtccCntPresc_256 = _RTCC_CTRL_CNTPRESC_DIV256
rtccCntPresc_512 = _RTCC_CTRL_CNTPRESC_DIV512
rtccCntPresc_1024 = _RTCC_CTRL_CNTPRESC_DIV1024
rtccCntPresc_2048 = _RTCC_CTRL_CNTPRESC_DIV2048
rtccCntPresc_4096 = _RTCC_CTRL_CNTPRESC_DIV4096
rtccCntPresc_8192 = _RTCC_CTRL_CNTPRESC_DIV8192
rtccCntPresc_16384 = _RTCC_CTRL_CNTPRESC_DIV16384
rtccCntPresc_32768 = _RTCC_CTRL_CNTPRESC_DIV32768
}

Counter prescaler selection.

enum
rtccCntTickPresc = _RTCC_CTRL_CNTTICK_PRESC
rtccCntTickCCV0Match = _RTCC_CTRL_CNTTICK_CCV0MATCH
}

Prescaler mode of the RTCC counter.

enum
rtccCapComChModeOff = _RTCC_CC_CTRL_MODE_OFF
rtccCapComChModeCapture = _RTCC_CC_CTRL_MODE_INPUTCAPTURE
rtccCapComChModeCompare = _RTCC_CC_CTRL_MODE_OUTPUTCOMPARE
}

Capture/Compare channel mode.

enum
rtccCompMatchOutActionPulse = _RTCC_CC_CTRL_CMOA_PULSE
rtccCompMatchOutActionToggle = _RTCC_CC_CTRL_CMOA_TOGGLE
rtccCompMatchOutActionClear = _RTCC_CC_CTRL_CMOA_CLEAR
rtccCompMatchOutActionSet = _RTCC_CC_CTRL_CMOA_SET
}

Compare match output action mode.

enum
rtccInEdgeRising = _RTCC_CC_CTRL_ICEDGE_RISING
rtccInEdgeFalling = _RTCC_CC_CTRL_ICEDGE_FALLING
rtccInEdgeBoth = _RTCC_CC_CTRL_ICEDGE_BOTH
rtccInEdgeNone = _RTCC_CC_CTRL_ICEDGE_NONE
}

Input edge select.

enum
rtccCompBaseCnt = _RTCC_CC_CTRL_COMPBASE_CNT
rtccCompBasePreCnt = _RTCC_CC_CTRL_COMPBASE_PRECNT
}

Capture/Compare channel compare mode.

enum
rtccDayCompareModeMonth = _RTCC_CC_CTRL_DAYCC_MONTH
rtccDayCompareModeWeek = _RTCC_CC_CTRL_DAYCC_WEEK
}

Day compare mode.

Typedefs#

typedef uint8_t

PRS channel number.

Functions#

uint32_t

Get the RTCC compare register value for a selected channel.

void
RTCC_ChannelCompareValueSet(int ch, uint32_t value)

Set the RTCC compare register value for a selected channel.

uint32_t

Get the RTCC input capture register value for a selected channel.

uint32_t

Get the RTCC capture/compare register value for a selected channel.

void
RTCC_ChannelCCVSet(int ch, uint32_t value)

Set RTCC capture/compare register value for a selected channel.

uint32_t

Get the calendar DATE register content for a selected channel.

void
RTCC_ChannelDateSet(int ch, uint32_t date)

Set the calendar DATE register for a selected channel.

uint32_t

Get the calendar TIME register content for a selected channel.

void
RTCC_ChannelTimeSet(int ch, uint32_t time)

Set the calendar TIME register for a selected channel.

uint32_t

Get the combined CNT/PRECNT register content.

uint32_t

Get the RTCC counter value.

void
RTCC_CounterSet(uint32_t value)

Set the RTCC CNT counter.

uint32_t

Get the DATE register value.

void
RTCC_DateSet(uint32_t date)

Set the RTCC DATE register.

void

Enable/disable EM4 wakeup capability.

void
RTCC_Enable(bool enable)

Enable/disable RTCC counting.

void
RTCC_Init(const RTCC_Init_TypeDef *init)

Initialize RTCC.

void
RTCC_ChannelInit(int ch, RTCC_CCChConf_TypeDef const *confPtr)

Configure the selected capture/compare channel of the RTCC.

void
RTCC_IntClear(uint32_t flags)

Clear one or more pending RTCC interrupts.

void
RTCC_IntDisable(uint32_t flags)

Disable one or more RTCC interrupts.

void
RTCC_IntEnable(uint32_t flags)

Enable one or more RTCC interrupts.

uint32_t

Get pending RTCC interrupt flags.

uint32_t

Get enabled and pending RTCC interrupt flags.

void
RTCC_IntSet(uint32_t flags)

Set one or more pending RTCC interrupts from SW.

void
RTCC_Lock(void)

Lock RTCC registers.

uint32_t

Get the RTCC pre-counter value.

void
RTCC_PreCounterSet(uint32_t preCntVal)

Set the RTCC pre-counter value.

void

Restore RTCC to its reset state.

void

Power down retention RAM.

void

Clear the STATUS register.

uint32_t

Get the STATUS register value.

uint32_t

Get the TIME register value.

void
RTCC_TimeSet(uint32_t time)

Set the RTCC TIME register.

void

Unlock RTCC registers.

Macros#

#define

Default RTCC initialization structure.

#define

Default RTCC channel output compare initialization structure.

#define

Default RTCC channel input capture initialization structure.

#define

Number of RTCC capture/compare channels.

#define

Validation of valid RTCC channel for assert statements.

Enumeration Documentation#

RTCC_CntMode_TypeDef#

RTCC_CntMode_TypeDef

Operational mode of the counter.

Enumerator
rtccCntModeNormal

Normal counter mode.

rtccCntModeCalendar

Calendar mode.


Definition at line 70 of file platform/emlib/inc/em_rtcc.h

RTCC_CntPresc_TypeDef#

RTCC_CntPresc_TypeDef

Counter prescaler selection.

Enumerator
rtccCntPresc_1

Divide clock by 1.

rtccCntPresc_2

Divide clock by 2.

rtccCntPresc_4

Divide clock by 4.

rtccCntPresc_8

Divide clock by 8.

rtccCntPresc_16

Divide clock by 16.

rtccCntPresc_32

Divide clock by 32.

rtccCntPresc_64

Divide clock by 64.

rtccCntPresc_128

Divide clock by 128.

rtccCntPresc_256

Divide clock by 256.

rtccCntPresc_512

Divide clock by 512.

rtccCntPresc_1024

Divide clock by 1024.

rtccCntPresc_2048

Divide clock by 2048.

rtccCntPresc_4096

Divide clock by 4096.

rtccCntPresc_8192

Divide clock by 8192.

rtccCntPresc_16384

Divide clock by 16384.

rtccCntPresc_32768

Divide clock by 32768.


Definition at line 82 of file platform/emlib/inc/em_rtcc.h

RTCC_PrescMode_TypeDef#

RTCC_PrescMode_TypeDef

Prescaler mode of the RTCC counter.

Enumerator
rtccCntTickPresc

CNT register ticks according to prescaler value.

rtccCntTickCCV0Match

CNT register ticks when PRECNT matches the 15 least significant bits of ch.


Definition at line 124 of file platform/emlib/inc/em_rtcc.h

RTCC_CapComChMode_TypeDef#

RTCC_CapComChMode_TypeDef

Capture/Compare channel mode.

Enumerator
rtccCapComChModeOff

Capture/Compare channel turned off.

rtccCapComChModeCapture

Capture mode.

rtccCapComChModeCompare

Compare mode.


Definition at line 145 of file platform/emlib/inc/em_rtcc.h

RTCC_CompMatchOutAction_TypeDef#

RTCC_CompMatchOutAction_TypeDef

Compare match output action mode.

Enumerator
rtccCompMatchOutActionPulse

Generate a pulse.

rtccCompMatchOutActionToggle

Toggle output.

rtccCompMatchOutActionClear

Clear output.

rtccCompMatchOutActionSet

Set output.


Definition at line 152 of file platform/emlib/inc/em_rtcc.h

RTCC_InEdgeSel_TypeDef#

RTCC_InEdgeSel_TypeDef

Input edge select.

Enumerator
rtccInEdgeRising

Rising edges detected.

rtccInEdgeFalling

Falling edges detected.

rtccInEdgeBoth

Both edges detected.

rtccInEdgeNone

No edge detection, signal is left as is.


Definition at line 181 of file platform/emlib/inc/em_rtcc.h

RTCC_CompBase_TypeDef#

RTCC_CompBase_TypeDef

Capture/Compare channel compare mode.

Enumerator
rtccCompBaseCnt

CCVx is compared with the CNT register.

rtccCompBasePreCnt

CCVx is compared with a CNT[16:0] and PRECNT[14:0].


Definition at line 189 of file platform/emlib/inc/em_rtcc.h

RTCC_DayCompareMode_TypeDef#

RTCC_DayCompareMode_TypeDef

Day compare mode.

Enumerator
rtccDayCompareModeMonth

Day of month is selected for Capture/Compare.

rtccDayCompareModeWeek

Day of week is selected for Capture/Compare.


Definition at line 199 of file platform/emlib/inc/em_rtcc.h

Typedef Documentation#

RTCC_PRSSel_TypeDef#

typedef uint8_t RTCC_PRSSel_TypeDef

PRS channel number.

This type is used when configuring input capture mode on a RTCC channel.


Definition at line 161 of file platform/emlib/inc/em_rtcc.h

Function Documentation#

RTCC_ChannelCompareValueGet#

uint32_t RTCC_ChannelCompareValueGet (int ch)

Get the RTCC compare register value for a selected channel.

Parameters
[in]ch

Channel selector.

Returns

  • Compare register value.


Definition at line 401 of file platform/emlib/inc/em_rtcc.h

RTCC_ChannelCompareValueSet#

void RTCC_ChannelCompareValueSet (int ch, uint32_t value)

Set the RTCC compare register value for a selected channel.

Parameters
[in]ch

Channel selector.

[in]value

Compare register value


Definition at line 421 of file platform/emlib/inc/em_rtcc.h

RTCC_ChannelCaptureValueGet#

uint32_t RTCC_ChannelCaptureValueGet (int ch)

Get the RTCC input capture register value for a selected channel.

Parameters
[in]ch

Channel selector.

Returns

  • Capture register value.


Definition at line 441 of file platform/emlib/inc/em_rtcc.h

RTCC_ChannelCCVGet#

uint32_t RTCC_ChannelCCVGet (int ch)

Get the RTCC capture/compare register value for a selected channel.

Parameters
[in]ch

Channel selector.

For parts with separate capture compare value registers, this function returns the compare value.

Returns

  • Capture/compare register value.


Definition at line 463 of file platform/emlib/inc/em_rtcc.h

RTCC_ChannelCCVSet#

void RTCC_ChannelCCVSet (int ch, uint32_t value)

Set RTCC capture/compare register value for a selected channel.

Parameters
[in]ch

Channel selector.

[in]value

Capture/compare register value

For parts with separate capture compare value registers, this function sets the compare value.


Definition at line 480 of file platform/emlib/inc/em_rtcc.h

RTCC_ChannelDateGet#

uint32_t RTCC_ChannelDateGet (int ch)

Get the calendar DATE register content for a selected channel.

Parameters
[in]ch

Channel selector.

Returns

  • DATE register value.


Definition at line 496 of file platform/emlib/inc/em_rtcc.h

RTCC_ChannelDateSet#

void RTCC_ChannelDateSet (int ch, uint32_t date)

Set the calendar DATE register for a selected channel.

Parameters
[in]ch

Channel selector.

[in]date

DATE value.


Definition at line 512 of file platform/emlib/inc/em_rtcc.h

RTCC_ChannelTimeGet#

uint32_t RTCC_ChannelTimeGet (int ch)

Get the calendar TIME register content for a selected channel.

Parameters
[in]ch

Channel selector.

Returns

  • TIME register value.


Definition at line 528 of file platform/emlib/inc/em_rtcc.h

RTCC_ChannelTimeSet#

void RTCC_ChannelTimeSet (int ch, uint32_t time)

Set the calendar TIME register for a selected channel.

Parameters
[in]ch

Channel selector.

[in]time

TIME value.


Definition at line 544 of file platform/emlib/inc/em_rtcc.h

RTCC_CombinedCounterGet#

uint32_t RTCC_CombinedCounterGet (void )

Get the combined CNT/PRECNT register content.

Parameters
N/A

Returns

  • CNT/PRECNT register value.


Definition at line 558 of file platform/emlib/inc/em_rtcc.h

RTCC_CounterGet#

uint32_t RTCC_CounterGet (void )

Get the RTCC counter value.

Parameters
N/A

Returns

  • Current RTCC counter value.


Definition at line 575 of file platform/emlib/inc/em_rtcc.h

RTCC_CounterSet#

void RTCC_CounterSet (uint32_t value)

Set the RTCC CNT counter.

Parameters
[in]value

CNT value.


Definition at line 592 of file platform/emlib/inc/em_rtcc.h

RTCC_DateGet#

uint32_t RTCC_DateGet (void )

Get the DATE register value.

Parameters
N/A

Returns

  • Current DATE register value.


Definition at line 611 of file platform/emlib/inc/em_rtcc.h

RTCC_DateSet#

void RTCC_DateSet (uint32_t date)

Set the RTCC DATE register.

Parameters
[in]date

DATE value.


Definition at line 623 of file platform/emlib/inc/em_rtcc.h

RTCC_EM4WakeupEnable#

void RTCC_EM4WakeupEnable (bool enable)

Enable/disable EM4 wakeup capability.

Parameters
[in]enable

Set to true to enable EM4 wakeup, set to false otherwise.


Definition at line 637 of file platform/emlib/inc/em_rtcc.h

RTCC_Enable#

void RTCC_Enable (bool enable)

Enable/disable RTCC counting.

Parameters
[in]enable

True to enable RTCC counting, false to disable counting.


Definition at line 112 of file platform/emlib/src/em_rtcc.c

RTCC_Init#

void RTCC_Init (const RTCC_Init_TypeDef * init)

Initialize RTCC.

Parameters
[in]init

A pointer to the RTCC initialization structure.

Note that the compare values must be set separately with RTCC_CompareSet(), which should probably be done prior to the use of this function if configuring the RTCC to start when initialization is completed.


Definition at line 152 of file platform/emlib/src/em_rtcc.c

RTCC_ChannelInit#

void RTCC_ChannelInit (int ch, RTCC_CCChConf_TypeDef const * confPtr)

Configure the selected capture/compare channel of the RTCC.

Parameters
[in]ch

A channel selector.

[in]confPtr

A pointer to the configuration structure.

Use this function to configure an RTCC channel. Select capture/compare mode, match output action, overflow output action, and PRS input configuration. See the configuration structure RTCC_CCChConf_TypeDef for more details.


Definition at line 74 of file platform/emlib/src/em_rtcc.c

RTCC_IntClear#

void RTCC_IntClear (uint32_t flags)

Clear one or more pending RTCC interrupts.

Parameters
[in]flags

RTCC interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources.


Definition at line 661 of file platform/emlib/inc/em_rtcc.h

RTCC_IntDisable#

void RTCC_IntDisable (uint32_t flags)

Disable one or more RTCC interrupts.

Parameters
[in]flags

RTCC interrupt sources to disable. Use a set of interrupt flags OR-ed together to disable multiple interrupt.


Definition at line 678 of file platform/emlib/inc/em_rtcc.h

RTCC_IntEnable#

void RTCC_IntEnable (uint32_t flags)

Enable one or more RTCC interrupts.

Parameters
[in]flags

RTCC interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt.

Note

  • Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using RTCC_IntClear() prior to enabling the interrupt.


Definition at line 696 of file platform/emlib/inc/em_rtcc.h

RTCC_IntGet#

uint32_t RTCC_IntGet (void )

Get pending RTCC interrupt flags.

Parameters
N/A

Note

  • Event bits are not cleared by using this function.

Returns

  • Pending RTCC interrupt sources. Returns a set of interrupt flags OR-ed together for the interrupt sources set.


Definition at line 712 of file platform/emlib/inc/em_rtcc.h

RTCC_IntGetEnabled#

uint32_t RTCC_IntGetEnabled (void )

Get enabled and pending RTCC interrupt flags.

Parameters
N/A

Useful for handling more interrupt sources in the same interrupt handler.

Returns

  • Pending and enabled RTCC interrupt sources. Returns a set of interrupt flags OR-ed together for the interrupt sources set.


Definition at line 728 of file platform/emlib/inc/em_rtcc.h

RTCC_IntSet#

void RTCC_IntSet (uint32_t flags)

Set one or more pending RTCC interrupts from SW.

Parameters
[in]flags

RTCC interrupt sources to set to pending. Use a set of interrupt flags (RTCC_IFS_nnn).


Definition at line 746 of file platform/emlib/inc/em_rtcc.h

RTCC_Lock#

void RTCC_Lock (void )

Lock RTCC registers.

Parameters
N/A

Note

  • When RTCC registers are locked, RTCC_CTRL, RTCC_PRECNT, RTCC_CNT, RTCC_TIME, RTCC_DATE, RTCC_IEN, RTCC_POWERDOWN and RTCC_CCx_XXX registers cannot be written to.


Definition at line 764 of file platform/emlib/inc/em_rtcc.h

RTCC_PreCounterGet#

uint32_t RTCC_PreCounterGet (void )

Get the RTCC pre-counter value.

Parameters
N/A

Returns

  • Current RTCC pre-counter value.


Definition at line 793 of file platform/emlib/inc/em_rtcc.h

RTCC_PreCounterSet#

void RTCC_PreCounterSet (uint32_t preCntVal)

Set the RTCC pre-counter value.

Parameters
[in]preCntVal

RTCC pre-counter value to be set.


Definition at line 810 of file platform/emlib/inc/em_rtcc.h

RTCC_Reset#

void RTCC_Reset (void )

Restore RTCC to its reset state.

Parameters
N/A

Definition at line 187 of file platform/emlib/src/em_rtcc.c

RTCC_RetentionRamPowerDown#

void RTCC_RetentionRamPowerDown (void )

Power down retention RAM.

Parameters
N/A

Note

  • Once retention RAM is powered down, it cannot be powered up again.


Definition at line 831 of file platform/emlib/inc/em_rtcc.h

RTCC_StatusClear#

void RTCC_StatusClear (void )

Clear the STATUS register.

Parameters
N/A

Definition at line 238 of file platform/emlib/src/em_rtcc.c

RTCC_StatusGet#

uint32_t RTCC_StatusGet (void )

Get the STATUS register value.

Parameters
N/A

Returns

  • Current STATUS register value.


Definition at line 850 of file platform/emlib/inc/em_rtcc.h

RTCC_TimeGet#

uint32_t RTCC_TimeGet (void )

Get the TIME register value.

Parameters
N/A

Returns

  • Current TIME register value.


Definition at line 924 of file platform/emlib/inc/em_rtcc.h

RTCC_TimeSet#

void RTCC_TimeSet (uint32_t time)

Set the RTCC TIME register.

Parameters
[in]time

TIME value.


Definition at line 936 of file platform/emlib/inc/em_rtcc.h

RTCC_Unlock#

void RTCC_Unlock (void )

Unlock RTCC registers.

Parameters
N/A

Note

  • When RTCC registers are locked, RTCC_CTRL, RTCC_PRECNT, RTCC_CNT, RTCC_TIME, RTCC_DATE, RTCC_IEN, RTCC_POWERDOWN and RTCC_CCx_XXX registers cannot be written to.


Definition at line 951 of file platform/emlib/inc/em_rtcc.h

Macro Definition Documentation#

RTCC_INIT_DEFAULT#

#define RTCC_INIT_DEFAULT
Value:
{ \
true, /* Start counting when initialization is done. */ \
false, /* Disable RTCC during debug halt. */ \
false, /* Disable pre-counter wrap on ch. 0 CCV value. */ \
false, /* Disable counter wrap on ch. 1 CCV value. */ \
rtccCntPresc_32, /* 977 us per tick. */ \
rtccCntTickPresc, /* Counter increments according to prescaler value.*/ \
false, /* No RTCC oscillator failure detection. */ \
rtccCntModeNormal, /* Normal RTCC mode. */ \
false, /* No leap year correction. */ \
}

Default RTCC initialization structure.


Definition at line 315 of file platform/emlib/inc/em_rtcc.h

RTCC_CH_INIT_COMPARE_DEFAULT#

#define RTCC_CH_INIT_COMPARE_DEFAULT
Value:
{ \
rtccCapComChModeCompare, /* Select output compare mode. */ \
rtccCompMatchOutActionPulse, /* Create pulse on compare match.*/ \
0, /* PRS channel 0 (not used). */ \
rtccInEdgeNone, /* No edge detection. */ \
rtccCompBaseCnt, /* Counter comparison base. */ \
0, /* No compare mask bits set. */ \
rtccDayCompareModeMonth /* Don't care */ \
}

Default RTCC channel output compare initialization structure.


Definition at line 354 of file platform/emlib/inc/em_rtcc.h

RTCC_CH_INIT_CAPTURE_DEFAULT#

#define RTCC_CH_INIT_CAPTURE_DEFAULT
Value:
{ \
rtccCapComChModeCapture, /* Select input capture mode. */ \
rtccCompMatchOutActionPulse, /* Create pulse on capture. */ \
0, /* PRS channel 0. */ \
rtccInEdgeRising, /* Rising edge detection. */ \
rtccCompBaseCnt, /* Don't care. */ \
0, /* Don't care. */ \
rtccDayCompareModeMonth /* Don't care */ \
}

Default RTCC channel input capture initialization structure.


Definition at line 366 of file platform/emlib/inc/em_rtcc.h

RTCC_CC_NUM#

#define RTCC_CC_NUM
Value:
3UL

Number of RTCC capture/compare channels.


Definition at line 381 of file platform/emlib/inc/em_rtcc.h

RTCC_CH_VALID#

#define RTCC_CH_VALID
Value:
(ch)

Validation of valid RTCC channel for assert statements.


Definition at line 385 of file platform/emlib/inc/em_rtcc.h