VCMP - Voltage Comparator#

Supply Voltage Comparator (VCMP) Peripheral API.

This module contains functions to control the VCMP peripheral of Silicon Labs 32-bit MCUs and SoCs. The VCMP monitors the input voltage supply and generates interrupts on events using as little as 100 nA.

Modules#

VCMP_Init_TypeDef

Enumerations#

enum
vcmpWarmTime4Cycles = _VCMP_CTRL_WARMTIME_4CYCLES
vcmpWarmTime8Cycles = _VCMP_CTRL_WARMTIME_8CYCLES
vcmpWarmTime16Cycles = _VCMP_CTRL_WARMTIME_16CYCLES
vcmpWarmTime32Cycles = _VCMP_CTRL_WARMTIME_32CYCLES
vcmpWarmTime64Cycles = _VCMP_CTRL_WARMTIME_64CYCLES
vcmpWarmTime128Cycles = _VCMP_CTRL_WARMTIME_128CYCLES
vcmpWarmTime256Cycles = _VCMP_CTRL_WARMTIME_256CYCLES
vcmpWarmTime512Cycles = _VCMP_CTRL_WARMTIME_512CYCLES
}

Warm-up Time in High Frequency Peripheral Clock cycles.

enum
vcmpHystNone
vcmpHyst20mV
}

Hysteresis configuration.

Functions#

void
VCMP_Init(const VCMP_Init_TypeDef *vcmpInit)

Configure and enable Voltage Comparator.

void
VCMP_LowPowerRefSet(bool enable)

Enable or disable Low Power Reference setting.

void
VCMP_TriggerSet(int level)

Configure the trigger level of the voltage comparator.

void

Enable Voltage Comparator.

void

Disable Voltage Comparator.

uint32_t

Calculate voltage to trigger level.

bool

Check whether VDD is lower than the trigger level.

bool

Check whether VDD is higher than the trigger level.

bool

Check whether the VCMP output is ready.

void
VCMP_IntClear(uint32_t flags)

Clear one or more pending VCMP interrupts.

void
VCMP_IntSet(uint32_t flags)

Set one or more pending VCMP interrupts from SW.

void
VCMP_IntDisable(uint32_t flags)

Disable one or more VCMP interrupts.

void
VCMP_IntEnable(uint32_t flags)

Enable one or more VCMP interrupts.

uint32_t

Get pending VCMP interrupt flags.

uint32_t

Get enabled and pending VCMP interrupt flags.

Macros#

#define

Default VCMP initialization structure.

Enumeration Documentation#

VCMP_WarmTime_TypeDef#

VCMP_WarmTime_TypeDef

Warm-up Time in High Frequency Peripheral Clock cycles.

Enumerator
vcmpWarmTime4Cycles

4 cycles

vcmpWarmTime8Cycles

8 cycles

vcmpWarmTime16Cycles

16 cycles

vcmpWarmTime32Cycles

32 cycles

vcmpWarmTime64Cycles

64 cycles

vcmpWarmTime128Cycles

128 cycles

vcmpWarmTime256Cycles

256 cycles

vcmpWarmTime512Cycles

512 cycles


Definition at line 54 of file platform/emlib/inc/em_vcmp.h

VCMP_Hysteresis_TypeDef#

VCMP_Hysteresis_TypeDef

Hysteresis configuration.

Enumerator
vcmpHystNone

Normal operation, no hysteresis.

vcmpHyst20mV

Digital output will not toggle until positive edge is at least 20 mV above or below negative input voltage.


Definition at line 74 of file platform/emlib/inc/em_vcmp.h

Function Documentation#

VCMP_Init#

void VCMP_Init (const VCMP_Init_TypeDef *vcmpInit)

Configure and enable Voltage Comparator.

Parameters
[in]vcmpInit

The VCMP Initialization structure.


Definition at line 53 of file platform/emlib/src/em_vcmp.c

VCMP_LowPowerRefSet#

void VCMP_LowPowerRefSet (bool enable)

Enable or disable Low Power Reference setting.

Parameters
[in]enable

If true, enables low power reference. If false, disable low power reference.


Definition at line 133 of file platform/emlib/src/em_vcmp.c

VCMP_TriggerSet#

void VCMP_TriggerSet (int level)

Configure the trigger level of the voltage comparator.

Parameters
[in]level

A trigger value, in range 0-63.


Definition at line 149 of file platform/emlib/src/em_vcmp.c

VCMP_Enable#

void VCMP_Enable (void)

Enable Voltage Comparator.

Parameters
N/A

Definition at line 139 of file platform/emlib/inc/em_vcmp.h

VCMP_Disable#

void VCMP_Disable (void)

Disable Voltage Comparator.

Parameters
N/A

Definition at line 148 of file platform/emlib/inc/em_vcmp.h

VCMP_VoltageToLevel#

uint32_t VCMP_VoltageToLevel (float v)

Calculate voltage to trigger level.

Parameters
[in]v

Voltage Level for trigger.

Note

  • Soft float support is needed for this function to work.

Returns

  • Trigger level.


Definition at line 166 of file platform/emlib/inc/em_vcmp.h

VCMP_VDDLower#

bool VCMP_VDDLower (void)

Check whether VDD is lower than the trigger level.

Parameters
N/A

Returns

  • True if Voltage Comparator indicated VDD < trigger level, else returns false.


Definition at line 179 of file platform/emlib/inc/em_vcmp.h

VCMP_VDDHigher#

bool VCMP_VDDHigher (void)

Check whether VDD is higher than the trigger level.

Parameters
N/A

Returns

  • True if Voltage Comparator indicated VDD > trigger level, else returns false.


Definition at line 196 of file platform/emlib/inc/em_vcmp.h

VCMP_Ready#

bool VCMP_Ready (void)

Check whether the VCMP output is ready.

Parameters
N/A

Returns

  • True if VCMP output is ready.


Definition at line 212 of file platform/emlib/inc/em_vcmp.h

VCMP_IntClear#

void VCMP_IntClear (uint32_t flags)

Clear one or more pending VCMP interrupts.

Parameters
[in]flags

VCMP interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources for the VCMP module (VCMP_IFS_nnn).


Definition at line 230 of file platform/emlib/inc/em_vcmp.h

VCMP_IntSet#

void VCMP_IntSet (uint32_t flags)

Set one or more pending VCMP interrupts from SW.

Parameters
[in]flags

VCMP interrupt sources to set to pending. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the VCMP module (VCMP_IFS_nnn).


Definition at line 244 of file platform/emlib/inc/em_vcmp.h

VCMP_IntDisable#

void VCMP_IntDisable (uint32_t flags)

Disable one or more VCMP interrupts.

Parameters
[in]flags

VCMP interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the VCMP module (VCMP_IFS_nnn).


Definition at line 258 of file platform/emlib/inc/em_vcmp.h

VCMP_IntEnable#

void VCMP_IntEnable (uint32_t flags)

Enable one or more VCMP interrupts.

Parameters
[in]flags

VCMP interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the VCMP module (VCMP_IFS_nnn).


Definition at line 272 of file platform/emlib/inc/em_vcmp.h

VCMP_IntGet#

uint32_t VCMP_IntGet (void)

Get pending VCMP interrupt flags.

Parameters
N/A

Note

  • The event bits are not cleared by the use of this function.

Returns

  • Pending VCMP interrupt sources. Returns a set of interrupt flags OR-ed together for multiple interrupt sources in the VCMP module (VCMP_IFS_nnn).


Definition at line 288 of file platform/emlib/inc/em_vcmp.h

VCMP_IntGetEnabled#

uint32_t VCMP_IntGetEnabled (void)

Get enabled and pending VCMP interrupt flags.

Parameters
N/A

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

Note

  • The event bits are not cleared by the use of this function.

Returns

  • Pending and enabled VCMP interrupt sources. The return value is the bitwise AND combination of

    • the OR combination of enabled interrupt sources in VCMP_IEN_nnn register (VCMP_IEN_nnn) and

    • the OR combination of valid interrupt flags of the VCMP module (VCMP_IF_nnn).


Definition at line 311 of file platform/emlib/inc/em_vcmp.h

Macro Definition Documentation#

VCMP_INIT_DEFAULT#

#define VCMP_INIT_DEFAULT
Value:
{ \
true, /** Half Bias enabled. */ \
0x7, /** Bias current 0.7 uA when half bias is enabled. */ \
false, /** Falling edge sense not enabled. */ \
false, /** Rising edge sense not enabled. */ \
vcmpWarmTime4Cycles, /** 4 clock cycles warm-up time. */ \
vcmpHystNone, /** No hysteresis. */ \
0, /** 0 in digital output when inactive. */ \
true, /** Do not use low power reference. */ \
39, /** Trigger level just below 3V. */ \
true, /** Enable after initialization. */ \
}

Default VCMP initialization structure.


Definition at line 113 of file platform/emlib/inc/em_vcmp.h