![]() |
Synergy Software Package User's Manual
|
The OPAMP HAL module provides a high level API for signal amplification applications and supports the OPAMP peripheral available on Synergy MCUs.
The following hardware features are, or are not, supported by SSP for OPAMP:
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | Low power mode | High speed mode | Start by SW | AGT compare match | Stop by SW | ADC conversion end |
|---|---|---|---|---|---|---|
| S124 | N/A | N/A | N/A | N/A | N/A | N/A |
| S128 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S1JA | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S3A1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S3A3 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S3A6 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S3A7 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| S5D3 | N/A | N/A | N/A | N/A | N/A | N/A |
| S5D5 | N/A | N/A | N/A | N/A | N/A | N/A |
| S5D9 | N/A | N/A | N/A | N/A | N/A | N/A |
| S7G2 | N/A | N/A | N/A | N/A | N/A | N/A |
The OPAMP HAL module defines API functions to open, start, stop, read status, trim 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.
OPAMP HAL Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| open | g_opamp0.p_api->open(g_opamp0.p_ctrl, g_opamp0.p_cfg);Applies power to the OPAMP and initializes the hardware based on the user configuration. |
| start | g_opamp0.p_api->start(g_opamp0.p_ctrl, channel_mask);If the OPAMP is configured for hardware triggers, enables hardware triggers. Otherwise, starts the op-amp. |
| stop | g_opamp0.p_api->stop(g_opamp0.p_ctrl, channel_mask);Stops the op-amp. If the OPAMP is configured for hardware triggers, disables hardware triggers. |
| trim | g_opamp0.p_api->trim(g_opamp0.p_ctrl, cmd, p_args);On MCUs that support trimming, the op-amp trim register is set to the factory default after open(). This function allows the application to trim the operational amplifier to a user setting, which overwrites the factory default factory trim values. See Operational Notes for important details. |
| infoGet | g_opamp0.p_api->infoGet(g_opamp0.p_ctrl, p_info);Provides the minimum stabilization wait time in microseconds. |
| statusGet | g_opamp0.p_api->statusGet(g_opamp0.p_ctrl, p_status);Provides the operating status for each op-amp in a bitmask. This bit is set when operation begins, before the stabilization wait time has elapsed. |
| close | g_opamp0.p_api-> close(g_opamp0.p_ctrl);Stops the op-amps. |
| versionGet | g_opamp0.p_api->versionGet(&version);Retrieve the module 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_INVALID_POINTER | The parameter p_data is NULL. |
| SSP_ERR_INVALID_STATE | The command is not valid for the current state of the trim function. |
| SSP_ERR_INVALID_MODE | Trim is not allowed in low power mode. |
The OPAMP HAL module controls the OPAMP peripheral on a Synergy microcontroller. It directly controls the OPAMP hardware without using any RTOS elements and provides convenient APIs to simplify development.
Trimming the OPAMP
On MCUs that support trimming, the op-amp trim register is set to the factory default after the opamp_api_t::open API is called).
This function allows the application to trim the operational amplifier to a user setting, which overwrites the factory default factory trim values.
Not supported on all MCUs. See hardware manual for details. Not supported if configured for low power mode (OPAMP_MODE_LOW_POWER).
This function is not reentrant. Only one side of one op-amp can be trimmed at a time. Complete the procedure for one side of one channel before calling the opamp_api_t::trim API with the command OPAMP_TRIM_CMD_START again.
The trim procedure works as follows:
The following status return values are associated with the opamp_api_t::trim API:
| SSP_SUCCESS | Conversion result in p_data |
|---|---|
| SSP_ERR_UNSUPPORTED | Trimming is not supported on this MCU. |
| SSP_ERR_INVALID_STATE | The command is not valid in the current state of the trim state machine. |
| SSP_ERR_INVALID_ARGUMENT | The requested channel is not operating or the trim procedure is not in progress for this channel/input combination. |
| SSP_ERR_INVALID_MODE | Trim is not allowed in low power mode. |
| SSP_ERR_ASSERTION | An input pointer was NULL. |
| SSP_ERR_NOT_OPEN | Instance control block is not open. Trimming is not supported on all MCUs. |
This module only works for selected Synergy MCUs. Refer to the release notes for your current SSP release to see which MCUs are supported by this module. Additionally, the MCU Hardware Manual shows which peripherals are available.
Refer to the most recent SSP Release Notes for any additional operational limitations for this module.
This section describes how to include the OPAMP HAL Module in an application using the SSP configurator.
To add the OPAMP 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 OPAMP Driver is g_opamp0. This name can be changed in the associated Properties window.)
OPAMP HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_opamp0 OPAMP Driver on r_opamp | Threads | New Stack> Driver> Analog> OPAMP Driver on r_opamp |
When the OPAMP Driver on r_opamp 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 OPAMP 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 OPAMP HAL Module on r_opamp
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enable or disable the parameter error checking. |
| Name | g_opamp | Module name. |
| AGT Start Trigger Configuration (N/A unless AGT Start Trigger is Selected for the Channel) | AGT1 Compare Match Starts OPAMPs 0 and 2 if configured for AGT Start/AGT0 Compare Match Starts OMPAMPs 1 and 3 if configured for AGT Start, AGT1 Compare Match Starts OPAMPs 0 and 1 if configured for AGT Start/AGT0 Compare Match Starts OPAMPs 2 and 3 if configured for AGT Start, AGT1 Compare Match Starts all OPAMPs configured for AGT Start Default: AGT1 Compare Match Starts all OPAMPs configured for AGT Start | Configure which AGT channel event triggers op-amp channel. The AGT compare match event only starts the op-amp channel if the AGT Start trigger is selected in the Trigger configuration for the channel. |
| Power Mode | Low Power, Middle Speed, High Speed Default: High Speed | Configure the op-amp based on power or speed requirements. This setting affects the minimum required stabilization time. Middle speed is not available for all MCUs. |
| Trigger Channel 0 | Software Start Software Stop, AGT Start Software Stop, AGT Start ADC Stop Default: Software Start Software Stop | Select the event triggers to start or stop op-amp channel 0. If the event trigger is selected for start, the opamp_api_t::start API enables the event trigger for this channel. If the event trigger is selected for stop, the opamp_api_t::stop API disables the event trigger for this channel. |
| Trigger Channel 1 | Software Start Software Stop, AGT Start Software Stop, AGT Start ADC Stop Default: Software Start Software Stop | Select the event triggers to start or stop op-amp channel 1. If the event trigger is selected for start, the opamp_api_t::start API enables the event trigger for this channel. If the event trigger is selected for stop, the opamp_api_t::stop API disables the event trigger for this channel. |
| Trigger Channel 2 | Software Start Software Stop, AGT Start Software Stop, AGT Start ADC Stop Default: Software Start Software Stop | Select the event triggers to start or stop op-amp channel 2. If the event trigger is selected for start, the opamp_api_t::start API enables the event trigger for this channel. If the event trigger is selected for stop, the opamp_api_t::stop API disables the event trigger for this channel. |
| Trigger Channel 3 | Software Start Software Stop, AGT Start Software Stop, AGT Start ADC Stop Default: Software Start Software Stop | Select the event triggers to start or stop op-amp channel 3. If the event trigger is selected for start, the opamp_api_t::start API enables the event trigger for this channel. If the event trigger is selected for stop, the opamp_api_t::stop API disables the event trigger for this channel. |
The OPAMP HAL module does not require a specific clock configuration.
To use the OPAMP 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 OPAMP HAL Module on r_opamp
| Resource | ISDE Tab | Pin selection Sequence |
|---|---|---|
| OPAMP | Pins | Select Peripherals> Analog: OPAMP 0/1/2 |
The typical steps in using the OPAMP HAL module in an application are:
These common steps are illustrated in a typical operational flow diagram in the following figure: