Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more
Initialization and Configuration functions
[COMP_Private_Functions]
Initialization and Configuration functions. More...
Functions | |
void | COMP_DeInit (uint32_t COMP_Selection) |
Deinitializes COMP peripheral registers to their default reset values. | |
void | COMP_Init (uint32_t COMP_Selection, COMP_InitTypeDef *COMP_InitStruct) |
Initializes the COMP peripheral according to the specified parameters in COMP_InitStruct. | |
void | COMP_StructInit (COMP_InitTypeDef *COMP_InitStruct) |
Fills each COMP_InitStruct member with its default value. | |
void | COMP_Cmd (uint32_t COMP_Selection, FunctionalState NewState) |
Enable or disable the COMP peripheral. | |
void | COMP_SwitchCmd (uint32_t COMP_Selection, FunctionalState NewState) |
Close or Open the SW1 switch. | |
uint32_t | COMP_GetOutputLevel (uint32_t COMP_Selection) |
Return the output level (high or low) of the selected comparator. |
Detailed Description
Initialization and Configuration functions.
=============================================================================== ##### Initialization and Configuration functions ##### ===============================================================================
Function Documentation
void COMP_Cmd | ( | uint32_t | COMP_Selection, |
FunctionalState | NewState | ||
) |
Enable or disable the COMP peripheral.
- Note:
- If the selected comparator is locked, enable/disable can't be performed. To unlock the configuration, perform a system reset.
- Parameters:
-
COMP_Selection,: the selected comparator. This parameter can be COMP_Selection_COMPx where x can be 1 to 7 to select the COMP peripheral. NewState,: new state of the COMP peripheral. This parameter can be: ENABLE or DISABLE. When enabled, the comparator compares the non inverting input with the inverting input and the comparison result is available on comparator output. When disabled, the comparator doesn't perform comparison and the output level is low.
- Return values:
-
None
Definition at line 314 of file stm32f30x_comp.c.
void COMP_DeInit | ( | uint32_t | COMP_Selection ) |
Deinitializes COMP peripheral registers to their default reset values.
- Note:
- Deinitialization can't be performed if the COMP configuration is locked. To unlock the configuration, perform a system reset.
- Parameters:
-
COMP_Selection,: the selected comparator. This parameter can be COMP_Selection_COMPx where x can be 1 to 7 to select the COMP peripheral. None
- Return values:
-
None
< Set COMP_CSR register to reset value
Definition at line 214 of file stm32f30x_comp.c.
uint32_t COMP_GetOutputLevel | ( | uint32_t | COMP_Selection ) |
Return the output level (high or low) of the selected comparator.
The output level depends on the selected polarity. If the polarity is not inverted:
- Comparator output is low when the non-inverting input is at a lower voltage than the inverting input
- Comparator output is high when the non-inverting input is at a higher voltage than the inverting input If the polarity is inverted:
- Comparator output is high when the non-inverting input is at a lower voltage than the inverting input
- Comparator output is low when the non-inverting input is at a higher voltage than the inverting input
- Parameters:
-
COMP_Selection,: the selected comparator. This parameter can be COMP_Selection_COMPx where x can be 1 to 7 to select the COMP peripheral.
- Return values:
-
Returns the selected comparator output level: low or high.
Definition at line 380 of file stm32f30x_comp.c.
void COMP_Init | ( | uint32_t | COMP_Selection, |
COMP_InitTypeDef * | COMP_InitStruct | ||
) |
Initializes the COMP peripheral according to the specified parameters in COMP_InitStruct.
- Note:
- If the selected comparator is locked, initialization can't be performed. To unlock the configuration, perform a system reset.
- By default, PA1 is selected as COMP1 non inverting input. To use PA4 as COMP1 non inverting input call COMP_SwitchCmd() after COMP_Init()
- Parameters:
-
COMP_Selection,: the selected comparator. This parameter can be COMP_Selection_COMPx where x can be 1 to 7 to select the COMP peripheral. COMP_InitStruct,: pointer to an COMP_InitTypeDef structure that contains the configuration information for the specified COMP peripheral. - COMP_InvertingInput specifies the inverting input of COMP
- COMP_NonInvertingInput specifies the non inverting input of COMP
- COMP_Output connect COMP output to selected timer input (Input capture / Output Compare Reference Clear / Break Input)
- COMP_BlankingSrce specifies the blanking source of COMP
- COMP_OutputPol select output polarity
- COMP_Hysteresis configures COMP hysteresis value
- COMP_Mode configures COMP power mode
- Note:
- COMP_Hysteresis must be configured only for STM32F303xC. Otherwise, COMP_Hysteresis must be kept at reset value(COMP_Hysteresis_No).
- COMP_Mode field is only applicable for STM32F303xC devices.
- Return values:
-
None
< Get the COMPx_CSR register value
< Clear the COMP1SW1, COMPxINSEL, COMPxOUTSEL, COMPxPOL, COMPxHYST and COMPxMODE bits
< Configure COMP: inverting input, output redirection, hysteresis value and power mode
< Set COMPxINSEL bits according to COMP_InitStruct->COMP_InvertingInput value
< Set COMPxNONINSEL bits according to COMP_InitStruct->COMP_NonInvertingInput value
< Set COMPxBLANKING bits according to COMP_InitStruct->COMP_BlankingSrce value
< Set COMPxOUTSEL bits according to COMP_InitStruct->COMP_Output value
< Set COMPxPOL bit according to COMP_InitStruct->COMP_OutputPol value
< Set COMPxHYST bits according to COMP_InitStruct->COMP_Hysteresis value
< Set COMPxMODE bits according to COMP_InitStruct->COMP_Mode value
< Write to COMPx_CSR register
Definition at line 245 of file stm32f30x_comp.c.
void COMP_StructInit | ( | COMP_InitTypeDef * | COMP_InitStruct ) |
Fills each COMP_InitStruct member with its default value.
- Parameters:
-
COMP_InitStruct,: pointer to an COMP_InitTypeDef structure which will be initialized.
- Return values:
-
None
Definition at line 287 of file stm32f30x_comp.c.
void COMP_SwitchCmd | ( | uint32_t | COMP_Selection, |
FunctionalState | NewState | ||
) |
Close or Open the SW1 switch.
- Note:
- If the COMP1 is locked, Close/Open the SW1 switch can't be performed. To unlock the configuration, perform a system reset.
- This switch is solely intended to redirect signals onto high impedance input, such as COMP1 non-inverting input (highly resistive switch)
- Parameters:
-
NewState,: New state of the analog switch. This parameter can be ENABLE so the SW1 is closed; PA1 is connected to PA4 or DISABLE so the SW1 switch is open; PA1 is disconnected from PA4
- Return values:
-
None
Definition at line 344 of file stm32f30x_comp.c.
Generated on Tue Jul 12 2022 17:34:45 by
