![]() |
Synergy Software Package User's Manual
|
The ACMPLP HAL module implements the comparator API for signal processing applications and supports the ACMPLP 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 ACMPLP:
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | Normal or window mode | Callback on rising edge, falling edge, or both | Configurable debounce filter | Option to include comparator output on VCOUT |
|---|---|---|---|---|
| S124 | ✓ | ✓ | ✓ | ✓ |
| S128 | ✓ | ✓ | ✓ | ✓ |
| S1JA | ✓ | ✓ | ✓ | ✓ |
| S3A1 | ✓ | ✓ | ✓ | ✓ |
| S3A3 | ✓ | ✓ | ✓ | ✓ |
| S3A6 | ✓ | ✓ | ✓ | ✓ |
| S3A7 | ✓ | ✓ | ✓ | ✓ |
| S5D3 | N/A | N/A | N/A | N/A |
| S5D5 | N/A | N/A | N/A | N/A |
| S5D9 | N/A | N/A | N/A | N/A |
| S7G2 | N/A | N/A | N/A | N/A |
The ACMPLP HAL module defines API functions 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.
ACMPLP 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 comparator_api_t::outputEnable is called. comparator_api_t::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 Comparator Driver (r_acmplp) HAL module controls the Low-Power Analog Comparator (ACMPLP) peripheral on a Synergy microcontroller. It directly controls the ACMPLP 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 R_ACMPLP 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 ACMPLP 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_acmplp0. This name can be changed in the associated Properties window.)
ACMPLP HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_comparator0 Comparator Driver on r_acmplp | Threads | New Stack> Driver> Analog> Comparator Driver on r_acmplp |
When the Comparator Driver on r_acmplp 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 ACMPLP 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 ACMPLP HAL Module on r_acmplp
| 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. |
| Mode | Mode Normal, Mode Window Default: Mode Normal | In normal mode, comparator output is high if VCMP > VREF. In window mode, comparator output is high if VCMP is outside the range of VREF0 to VREF1. |
| Trigger | Trigger Rising, Trigger Falling, Trigger Both Edge Default: Trigger Both Edge | The trigger specifies when a comparator callback event should occur. Unused if the interrupt priority is disabled or the callback is NULL. |
| Filter | Filter Off, Filter 1, Filter 8, Filter 32 Default: Filter Off | 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 | Off, On Default: Off | Turns this on to invest comparator output. This affects the output read from StatusGet(), the pin output level, and the edge trigger. |
| Pin Output | Off, On Default: Off | Turn this on to include the output from this comparator on VCOUT. The comparator output on VCOUT is OR'd 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. |
Configuration Settings for the ACMPLP HAL Module Lower Level Modules
Typically, only a small number of settings must be modified from the default for lower level drivers as indicated via the Red text in the Thread Stack block. Notice that some of the configuration properties must be set to a certain value for proper framework operation and will be locked to prevent user modification. The following table identifies all the settings within the properties section for the module:
Configuration Settings for the Analog Connection HAL Module on r_analog_connect
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enable or disable the parameter error checking. |
| Name | g_analog_connect0 | Module name. |
| Connection Table Name | g_analog_connect0_table | This connection table name is passed to the connectMultiple API function to make all configured connections. |
| ACMPHS0 IVCMP | No Connection, PORT5 P500, PORT0 P013, PORT1 P100 Default: No Connection | Select the connection for ACMPHS0 IVCMP
|
| ACMHS0 IVREF | No Connection, PORT5 P501, PORT0 P014, PORT1 P101, DAC80 DA, DAC120 DA, Analog0 VREF Default: No Connection | Select the connection for ACMPHS0 IVREF
|
| ACMPL0 IVREF0 | No Connection, PORT1 P109, DAC80 DA Default: No Connection | Select the connection for ACMPL0 IVREF0. |
| ACMPLP1 IVREF1 | No Connection, PORT1 P110, DAC81 DA Default: No Connection | Select the connection for ACMPLP1 IVREF1. |
| ACMPLP0 IVCMP | No Connection, PORT4 P400, OPAMP0 AMPO Default: No Connection | Select the connection for ACMPLP0 IVCMP. |
| ACMPLP0 IVREF | No Connection, ANALOG0 VREF, ACMPLP0 IVREF0 Default: No Connection | Select the connection for ACMPLP0 IVREF. |
| ACMPLP1 IVCMP | No Connection, PORT4 P408, OPAMP1 AMPO Default: No Connection | Select the connection for ACMPLP1 IVCMP. |
| ACMPLP1 IVREF | No Connection, ANALOG0 VREF, ACMPLP0 IVREF0, ACMPLP1 IVREF1 Default: No Connection | Select the connection for ACMPLP1 VREF. |
| OPAMP0 AMPO | No Connection, PORT0P014, PORT0 P013, PORT0P003, PORT0 P002 Default: No Connection | Select the connection for OAMP0 AMPO.
|
| OPAMP0 AMPM | No Connection, PORT5 P501, PORT5 500, PORT0 P014, PORT0 P113, PORT0 P003, OPAMP0 AMPO Default: No Connection | Select the connection for OPAMP0 AMPM.
|
| OPAMP0 AMPP | No Connection, PORT5 P500, PORT0 P014, PORT0P013, PORT0 P002, DAC120 DA Default: No Connection | Select the connection for OPAMP0 AMPP.
|
| OPAMP1 AMPM | No Connection, PORT0 P014, OPAMP1 AMPO Default: No Connection | Select the connection for OPAMP1 AMPM.
|
| OPAMP1 AMPP | No Connection, PORT0 P014, PORT0 P013, PORT0 P003, PORT0 P002, DAC80 DA Default: No Connection | Select the connection for OPAMP1 AMPP.
|
| OPAMP2 AMPM | No Connection, PORT0 P003, OPAMP2 AMPO Default: No Connection | Select the connection for OPAMP2 AMPM.
|
| OPAMP2 AMPP | No Connection, PORT0 P003, PORT0 P002, DAC81DA Default: No Connection | Select the connection for OPAMP2 AMPP.
|
The ACMPLP HAL module uses the PCLKB as its clock source.
To change the clock frequency at run-time, use the CGC Interface.
To use the ACMPLP 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 ACMPLP HAL Module on r_acmplp
| Resource | ISDE Tab | Pin selection Sequence |
|---|---|---|
| ACMPLP | Pins | Select Peripherals> Analog:ACMP |
Typically, only a small number of settings must be modified from the default for lower level drivers as indicated via the Red text in the Thread Stack block. Notice that some of the configuration properties must be set to a certain value for proper framework operation and will be locked to prevent user modification. The following table identifies all the settings within the properties section for the module:
Configuration Settings for the Analog Connection HAL Module on r_analog_connect
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enable or disable the parameter error checking. |
| Name | g_analog_connect0 | Module name. |
| Connection Table Name | g_analog_connect0_table | This connection table name is passed to the connectMultiple API function to make all configured connections. |
| ACMPHS0 IVCMP | No Connection, PORT5 P500, PORT0 P013, PORT1 P100 Default: No Connection | Select the connection for ACMPHS0 IVCMP.
|
| ACMHS0 IVREF | No Connection, PORT5 P501, PORT0 P014, PORT1 P101, DAC80 DA, DAC120 DA, Analog0 VREF Default: No Connection | Select the connection for ACMPHS0 IVREF.
|
| ACMPL0 IVREF0 | No Connection, PORT1 P109, DAC80 DA Default: No Connection | Select the connection for ACMPL0 IVREF0. |
| ACMPLP1 IVREF1 | No Connection, PORT1 P110, DAC81 DA Default: No Connection | Select the connection for ACMPLP1 IVREF1. |
| ACMPLP0 IVCMP | No Connection, PORT4 P400, OPAMP0 AMPO Default: No Connection | Select the connection for ACMPLP0 IVCMP. |
| ACMPLP0 IVREF | No Connection, ANALOG0 VREF, ACMPLP0 IVREF0 Default: No Connection | Select the connection for ACMPLP0 IVREF. |
| ACMPLP1 IVCMP | No Connection, PORT4 P408, OPAMP1 AMPO Default: No Connection | Select the connection for ACMPLP1 IVCMP. |
| ACMPLP1 IVREF | No Connection, ANALOG0 VREF, ACMPLP0 IVREF0, ACMPLP1 IVREF1 Default: No Connection | Select the connection for ACMPLP1 VREF. |
| OPAMP0 AMPO | No Connection, PORT0P014, PORT0 P013, PORT0P003, PORT0 P002 Default: No Connection | Select the connection for OAMP0 AMPO.
|
| OPAMP0 AMPM | No Connection, PORT5 P501, PORT5 500, PORT0 P014, PORT0 P113, PORT0 P003, OPAMP0 AMPO Default: No Connection | Select the connection for OPAMP0 AMPM.
|
| OPAMP0 AMPP | No Connection, PORT5 P500, PORT0 P014, PORT0P013, PORT0 P002, DAC120 DA Default: No Connection | Select the connection for OPAMP0 AMPP.
|
| OPAMP1 AMPM | No Connection, PORT0 P014, OPAMP1 AMPO Default: No Connection | Select the connection for OPAMP1 AMPM.
|
| OPAMP1 AMPP | No Connection, PORT0 P014, PORT0 P013, PORT0 P003, PORT0 P002, DAC80 DA Default: No Connection | Select the connection for OPAMP1 AMPP.
|
| OPAMP2 AMPM | No Connection, PORT0 P003, OPAMP2 AMPO Default: No Connection | Select the connection for OPAMP2 AMPM.
|
| OPAMP2 AMPP | No Connection, PORT0 P003, PORT0 P002, DAC81DA Default: No Connection | Select the connection for OPAMP2 AMPP.
|
The typical steps in using the ACMPLP HAL module in an application are:
open API call.These common steps are illustrated in a typical operational flow diagram in the following figure: