![]() |
Synergy Software Package User's Manual
|
The ACMPHS HAL module implements the comparator API for signal processing applications and supports the ACMPHS peripheral available on the Synergy microcontroller hardware. A callback is available to signal the user application on transition events.
The following hardware features are, or are not, supported by the SSP for the ACMPHS:
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | Query HS Comparator result | Callback on rising edge, falling edge, or both | Configurable debounce filter | Option to include comparator output on VCOUT |
|---|---|---|---|---|
| S124 | N/A | N/A | N/A | N/A |
| S128 | N/A | N/A | N/A | N/A |
| S1JA | ✓ | ✓ | ✓ | ✓ |
| S3A1 | N/A | N/A | N/A | N/A |
| S3A3 | N/A | N/A | N/A | N/A |
| S3A6 | N/A | N/A | N/A | N/A |
| S3A7 | ✓ | ✓ | ✓ | ✓ |
| S5D3 | ✓ | ✓ | ✓ | ✓ |
| S5D5 | ✓ | ✓ | ✓ | ✓ |
| S5D9 | ✓ | ✓ | ✓ | ✓ |
| S7G2 | ✓ | ✓ | ✓ | ✓ |
The ACMPHS HAL module defines APIs to open, enable, get status and close the module. A complete list of the available APIs, an example API call and a short description of each can be found in the following table. A table of status return values follows the API summary table.
ACMPHS HAL Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| open | g_comparator0.p_api->open(g_comparator0.p_ctrl, g_comparator0.p_cfg);Configures the comparator and starts operation. Callbacks and pin output are not active until outputEnable() is called. outputEnable() should be called after the output has stabilized. |
| outputEnable | g_comparator0.p_api->outputEnable(g_comparator0.p_ctrl);Enables the comparator output, which can be polled using statusGet(). Also enables pin output and interrupts as configured during open(). |
| infoGet | g_comparator0.p_api->infoGet(g_comparator0.p_ctrl, p_info);Provides the minimum stabilization wait time in microseconds. |
| statusGet | g_comparator0.p_api->statusGet(g_comparator0.p_ctrl, p_status);Provides the operating status of the comparator. |
| close | g_comparator0.p_api->close(g_comparator0.p_ctrl);Close the module. |
| versionGet | g_comparator0.p_api->read(&version);Retrieves the version using the version pointer. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | API Call Successful. |
| SSP_ERR_INVALID_ARGUMENT | Parameter has invalid value. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_ASSERTION | An input pointer is NULL. |
| SSP_ERR_IN_USE | Peripheral is in use or hardware lock is taken. |
| SSP_ERR_TIMEOUT | The debounce filter is off and 2 consecutive matching values were not read within 1024 attempts. |
The ACMPHS HAL module controls the high-speed analog comparator peripheral on a Synergy microcontroller. It directly controls the ACMPHS hardware without using any RTOS elements and provides convenient APIs to simplify development.
Comparator Output on VCOUT Pin
The signal on the VCOUT pin is a logical 'OR' of the outputs of all comparators (ACMPHS and ACMPLP) with their output pin enabled.
Interrupts and Callbacks
When a comparator event occurs, the Comparator Driver on r_acmphs HAL module calls the callback (comparator_cfg_t::p_callback) with the callback argument (comparator_callback_args_t).
This section describes how to include the ACMPHS HAL Module in an application using the SSP configurator.
To add the Comparator Driver to an application, simply add it to a thread using the stacks selection sequence given in the following table. (The default name for the Comparator Driver is g_acmphs0. This name can be changed in the associated Properties window.)
ACMPHS HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_comparator0 Comparator Driver on r_acmphs | Threads | New Stack> Driver> Analog> Comparator Driver on r_acmphs |
When the Comparator Driver on r_acmphs is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower‑level modules. Any modules needing additional configuration information have the box text highlighted in Red. Modules with a Gray band are individual modules that stand alone. Modules with a Blue band are shared or common; they need only be added once and can be used by multiple stacks. Modules with a Pink band can require the selection of lower-level modules; these are either optional or recommended. (This is indicated in the block with the inclusion of this text.) If the addition of lower-level modules is required, the module description include Add in the text. Clicking on any Pink banded modules brings up the New icon and displays possible choices.
The ACMPHS HAL Module must be configured by the user for the desired operation. The available configuration settings and defaults for all the user-accessible properties are given in the properties tab within the SSP configurator and are shown in the following tables for easy reference. Only properties that can be changed without causing conflicts are available for modification. Other properties are locked and not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error-prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP Configurator and are shown in the following tables for easy reference.
Configuration Settings for the ACMPHS HAL Module on r_acmphs
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Controls whether to include code for API parameter checking. |
| Name | g_comparator | Module name. |
| Channel | 0 | Select the hardware channel. |
| Trigger Edge | Rising, Falling, Both Edge Default: Both Edge | The trigger specifies when a comparator callback event should occur. Unused if the interrupt priority is disabled or the callback is NULL. |
| Debounce Filter | No Filter, 8, 16, 32 Default: No Filter | Select the PCLK divisor for the hardware digital debounce filter. Larger divisors provide a longer debounce and take longer for the output to update. |
| Invert | Not Inverted, Inverted Default: Not Inverted | Turns this on to invest comparator output. This affects the output read from StatusGet(), the pin output level, and the edge trigger. |
| Pin Output | Disabled, Enabled Default: Disabled | Turn this on to include the output from this comparator on VCOUT. The comparator output on VCOUT is ORed with output from all other ACMPHS and ACMPLP comparators. |
| Callback | NULL | Define this function in the application. It is called when the Trigger event occurs. |
| Comparator Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX), Disabled Default: Disabled | Select the interrupt priority for the comparator interrupt. |
The ACMPHS HAL module uses the PCLKB as its clock source.
To change the clock frequency at run-time, use the CGC Interface.
To use the ACMPHS HAL module, the port pins for the channels receiving the analog input must be set as input pins in the pin configurator in the ISDE. The following table illustrates the method for selecting the pins within the ISDE configuration window:
Pin Selection for the ACMPHS HAL Module on r_acmphs
| Resource | ISDE Tab | Pin selection Sequence |
|---|---|---|
| ACMPHS | Pins | Select Peripherals> Analog:ACMP |
The typical steps in using the ACMPHS HAL module in an application are:
These common steps are illustrated in a typical operational flow diagram in the following figure: