![]() |
RA Flexible Software Package Documentation
Release v6.0.0
|
|
Functions | |
fsp_err_t | R_ACMPHS_B_Open (comparator_ctrl_t *const p_ctrl, comparator_cfg_t const *const p_cfg) |
fsp_err_t | R_ACMPHS_B_InfoGet (comparator_ctrl_t *const p_ctrl, comparator_info_t *const p_info) |
fsp_err_t | R_ACMPHS_B_OutputEnable (comparator_ctrl_t *const p_ctrl) |
fsp_err_t | R_ACMPHS_B_StatusGet (comparator_ctrl_t *const p_ctrl, comparator_status_t *const p_status) |
fsp_err_t | R_ACMPHS_B_Close (comparator_ctrl_t *p_ctrl) |
Driver for the ACMPHS_B peripheral on RA MCUs. This module implements the Comparator Interface.
The ACMPHS HAL module supports the following features:
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
Name | Name must be a valid C symbol | g_comparator0 | Module name. |
Channel | MCU Specific Options | Select the hardware channel. | |
Trigger Edge Selector |
| Both Edge | The trigger specifies when a comparator callback event should occur. Unused if the interrupt priority is disabled or the callback is NULL. |
Noise Filter |
| No sampling (bypass) | Select the PCLK divisor for the hardware digital debounce filter. Larger divisors provide a longer debounce and take longer for the output to update. |
Output Polarity |
| Not Inverted | When enabled comparator output is inverted. This affects the output read from R_ACMPHS_B_StatusGet(), the pin output level, and the edge trigger. |
Pin Output |
| Disabled | Turn this on to enable the CMPOUTn signal for this channel. The CMPOUTn signal for each channel is OR'd together and the result is output to VCOUT. More pin output options are available on select MCUs. |
Callback | Name must be a valid C symbol | NULL | Define this function in the application. It is called when the Trigger event occurs. |
Comparator Interrupt Priority | MCU Specific Options | Select the interrupt priority for the comparator interrupt. | |
Analog Input Voltage Source | MCU Specific Options | Select the Analog input voltage source. Channel mentioned in the options represents channel in ACMPHS_B | |
Reference Voltage Input Source | MCU Specific Options | Select the Analog reference voltage source. Channel mentioned in the options represents channel in ACMPHS_B |
The ACMPHS peripheral is clocked from PCLKB. You can set the PCLKB frequency using the Clocks tab of the RA Configuration editor or by using the CGC Interface at run-time.
Comparator output can be enabled or disabled on each channel individually. The VCOUT pin is a logical OR of all comparator outputs.
When the noise filter is enabled for a channel, the comparison is evaluated three times before the output of the comparison in VCOUT or ELC event is affected. The sampling rate is driven by PCLKB. The sampling can be further slowed by adjusting the comparator_filter_t setting. NOTE: The R_ACMPLP_StatusGet reflects the comparison results before the effects of the noise filter.
If output polarity is configured as "Inverted" then the VCOUT signal will be inverted and the R_ACMPHS_StatusGet() will return an inverted status.
Once the analog comparator is configured, the program must wait for the stabilization time to elapse before using the comparator.
The following is a basic example of minimal use of the ACMPHS_B. The comparator is configured to trigger a callback when the input rises above the internal reference voltage (VREF). A GPIO output acts as the comparator input and is externally connected to the CMPIN input of the ACMPHS_B.
fsp_err_t R_ACMPHS_B_Open | ( | comparator_ctrl_t *const | p_ctrl, |
comparator_cfg_t const *const | p_cfg | ||
) |
Configures the comparator and starts operation. Callbacks and pin output are not active until outputEnable() is called. comparator_api_t::outputEnable() should be called after the output has stabilized. Implements comparator_api_t::open().
Comparator inputs must be configured in the application code prior to calling this function.
FSP_SUCCESS | Open successful. |
FSP_ERR_ASSERTION | An input pointer is NULL |
FSP_ERR_INVALID_ARGUMENT | An argument is invalid. Filter of 16 (COMPARATOR_FILTER_16), filter of 32 (COMPARATOR_FILTER_32) are not supported in this implementation. |
FSP_ERR_ALREADY_OPEN | The control block is already open or the hardware lock is taken. |
FSP_ERR_IN_USE | The channel is already in use. |
FSP_ERR_INVALID_CHANNEL | Selected channel does not exist. |
FSP_ERR_UNSUPPORTED | Selected mode not supported by this API |
fsp_err_t R_ACMPHS_B_InfoGet | ( | comparator_ctrl_t *const | p_ctrl, |
comparator_info_t *const | p_info | ||
) |
Provides the minimum stabilization wait time in microseconds. Implements comparator_api_t::infoGet().
FSP_SUCCESS | Information stored in p_info. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |
fsp_err_t R_ACMPHS_B_OutputEnable | ( | comparator_ctrl_t *const | p_ctrl | ) |
Enables the comparator output, which can be polled using comparator_api_t::statusGet(). Also enables pin output and interrupts as configured during comparator_api_t::open(). Implements comparator_api_t::outputEnable().
FSP_SUCCESS | Comparator output is enabled. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |
fsp_err_t R_ACMPHS_B_StatusGet | ( | comparator_ctrl_t *const | p_ctrl, |
comparator_status_t *const | p_status | ||
) |
Provides the operating status of the comparator. Implements comparator_api_t::statusGet().
FSP_SUCCESS | Operating status of the comparator is provided in p_status. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |
fsp_err_t R_ACMPHS_B_Close | ( | comparator_ctrl_t * | p_ctrl | ) |
Stops the comparator. Implements comparator_api_t::close().
FSP_SUCCESS | Instance control block closed successfully. |
FSP_ERR_ASSERTION | An input pointer was NULL. |
FSP_ERR_NOT_OPEN | Instance control block is not open. |