The ACMP module consists of minimum of 3 analog comparators. Each analog comparator has two inputs, INP and INN. Input INP is compared with input INN in the pad voltage domain. It generates a digital comparator output signal. The digital comparator output signal is shifted down from VDDP power supply voltage level to VDDC core voltage level. The ACMP module provides the following functionalities.
- Monitor external voltage level
- Operates in low power mode
- Provides Inverted ouput option
- The ACMP low level driver funtionalities
-
Initializes an instance of analog comparator module with the XMC_ACMP_CONFIG_t configuration structure using the API XMC_ACMP_Init().
-
Programs the source of input(INP) specified by XMC_ACMP_INP_SOURCE_t parameter using the API XMC_ACMP_SetInput().
-
Sets the low power mode of operation using XMC_ACMP_SetLowPowerMode() API.
◆ XMC_ACMP0
Comparator module base address defined
◆ XMC_ACMP_COMP_OUT_t
Defines the comparator output status options.
Enumerator |
---|
XMC_ACMP_COMP_OUT_NO_INVERSION | ACMP output is HIGH when, Input Positive(INP) greater than Input Negative(INN). Vplus > Vminus
|
XMC_ACMP_COMP_OUT_INVERSION | ACMP output is HIGH when, Input Negative(INN) greater than Input Positive(INP). Vminus > Vplus
|
◆ XMC_ACMP_HYSTERESIS_t
Defines the hysteresis voltage levels to reduce noise sensitivity.
Enumerator |
---|
XMC_ACMP_HYSTERESIS_OFF | No hysteresis
|
XMC_ACMP_HYSTERESIS_10 | Hysteresis = 10mv
|
XMC_ACMP_HYSTERESIS_15 | Hysteresis = 15mv
|
XMC_ACMP_HYSTERESIS_20 | Hysteresis = 20mv
|
◆ XMC_ACMP_INP_SOURCE_t
Defines the analog comparator input connection method.
Enumerator |
---|
XMC_ACMP_INP_SOURCE_STANDARD_PORT | Input is connected to port
|
XMC_ACMP_INP_SOURCE_ACMP1_INP_PORT | Input is connected to port and ACMP1 INP
|
◆ XMC_ACMP_STATUS_t
Defines the return value of an API.
Enumerator |
---|
XMC_ACMP_STATUS_SUCCESS | API completes the execution successfully
|
XMC_ACMP_STATUS_ERROR | API cannot fulfill the request
|
◆ XMC_ACMP_ClearLowPowerMode()
void XMC_ACMP_ClearLowPowerMode |
( |
void |
| ) |
|
- Parameters
-
- Returns
- None
- Description:
- Exits the low power mode by reseting LPWR bit of ANACMP0 register.
The low power mode is controlled by ACMP0 module. Low power mode is applicable for all instances of the comparator. To re-enable the low power mode, call the related API XMC_ACMP_SetLowPowerMode().
- Related APIs:
- XMC_ACMP_SetLowPowerMode().
◆ XMC_ACMP_DisableComparator()
void XMC_ACMP_DisableComparator |
( |
XMC_ACMP_t *const |
peripheral, |
|
|
uint32_t |
instance |
|
) |
| |
- Parameters
-
peripheral | Constant pointer to analog comparator module, of XMC_ACMP_t type. Use XMC_ACMP0 macro. |
instance | ACMP instance number.
Range:
0 - ACMP0
1 - ACMP1
2 - ACMP2
3 - ACMP3 - Only applicable for XMC1400 devices
|
- Returns
- None
- Description:
- Disables an instance of ACMP module.
Stops the comparator by resetting CMP_EN bit of respective ANACMP instance register. The instance number determines which analog comparator to be switched off.
- Related APIs:
- XMC_ACMP_EnableComparator().
◆ XMC_ACMP_DisableReferenceDivider()
void XMC_ACMP_DisableReferenceDivider |
( |
void |
| ) |
|
- Parameters
-
- Returns
- None
- Description:
- Disables the reference divider for analog comparator instance 1.
ACMP1 input INP is disconnected from the reference divider. This is achieved by reseting DIV_EN bit of ANACMP1 register.
- Related APIs:
- None.
◆ XMC_ACMP_EnableComparator()
void XMC_ACMP_EnableComparator |
( |
XMC_ACMP_t *const |
peripheral, |
|
|
uint32_t |
instance |
|
) |
| |
- Parameters
-
peripheral | Constant pointer to analog comparator module, of XMC_ACMP_t type. Use XMC_ACMP0 macro. |
instance | ACMP instance number.
Range:
0 - ACMP0
1 - ACMP1
2 - ACMP2
3 - ACMP3 - Only applicable for XMC1400 devices
|
- Returns
- None
- Description:
- Enables an instance of ACMP module.
Starts the comparator by setting CMP_EN bit of respective ANACMP instance register. The instance number determines which analog comparator to be switched on. Call this API after the successful completion of the comparator initilization and input selection.
- Related APIs:
- XMC_ACMP_DisableComparator().
◆ XMC_ACMP_EnableReferenceDivider()
void XMC_ACMP_EnableReferenceDivider |
( |
void |
| ) |
|
- Parameters
-
- Returns
- None
- Description:
- Enables the reference divider for analog comparator instance 1.
ACMP1 input INP is driven by an internal reference voltage by setting DIV_EN bit of ANACMP1 register. Other comparator instances can also share this reference divider option by calling the XMC_ACMP_SetInput() API.
- Related APIs:
- XMC_ACMP_SetInput().
◆ XMC_ACMP_Init()
- Parameters
-
peripheral | Constant pointer to analog comparator module, of XMC_ACMP_t type. Use XMC_ACMP0 macro. |
instance | ACMP instance number.
Range:
0 - ACMP0
1 - ACMP1
2 - ACMP2
3 - ACMP3 - Only applicable for XMC1400 devices
|
config | Pointer to configuration data. Refer data structure XMC_ACMP_CONFIG_t for settings. |
- Returns
- None
- Description:
- Initializes an instance of analog comparator module.
Configures the ANACMP resister with hysteresis, comparator filter and inverted comparator output.
- Related APIs:
- None.
◆ XMC_ACMP_SetInput()
- Parameters
-
peripheral | Constant pointer to analog comparator module, of XMC_ACMP_t type. Use XMC_ACMP0 macro. |
instance | ACMP instance number.
Range:
0 - ACMP0
2 - ACMP2
3 - ACMP3 - Only applicable for XMC1400 devices
|
source | ACMP input source selection options.
Range:
XMC_ACMP_INP_SOURCE_STANDARD_PORT - Input is connected to port
XMC_ACMP_INP_SOURCE_ACMP1_INP_PORT - Input is connected to port and ACMP1 INP
|
- Returns
- None
- Description:
- Sets the analog comparartor input selection for ACMP0, ACMP2 instances.
Apart from ACMP1 instance, each ACMP instances can be connected to its own port and ACMP1 INP. Calling XMC_ACMP_EnableReferenceDivider() API, after this API can share the reference divider to one of the comparartor input as explained in the following options.
The hardware options to set input are listed below.
-
The comparator inputs aren't connected to other ACMP1 comparator inputs.
-
Can program the comparator-0 to connect ACMP0.INP to ACMP1.INP in XMC1200 AA or XMC1300 AA
-
Can program the comparator-0 to connect ACMP0.INN to ACMP1.INP in XMC1200 AB or XMC1300 AB or XMC1400 AA
-
Can program the comparator-2 to connect ACMP2.INP to ACMP1.INP
Directly accessed registers are ANACMP0, ANACMP2 according to the availability of instance in the devices.
- Related APIs:
- XMC_ACMP_EnableReferenceDivider.
XMC_ACMP_DisableReferenceDivider.
◆ XMC_ACMP_SetLowPowerMode()
void XMC_ACMP_SetLowPowerMode |
( |
void |
| ) |
|
- Parameters
-
- Returns
- None
- Description:
- Set the comparartors to operate in low power mode, by setting the LPWR bit of ANACMP0 register.
The low power mode is controlled by ACMP0 instance. Low power mode is applicable for all instances of the comparator. In low power mode, blanking time will be introduced to ensure the stability of comparartor output. This will slow down the comparator operation.
- Related APIs:
- XMC_ACMP_ClearLowPowerMode().