![]() |
Synergy Software Package User's Manual
|
The DAC8 HAL module provides a high-level API for digital-to-analog conversion applications and supports an 8-bit D/A converter (DAC8) peripheral on Synergy MCUs.
The following hardware features are, or are not, supported by SSP for the DAC8.
Legend:
| Symbol | Meaning |
|---|---|
| ✓ | Available (Tested) |
| ⌧ | Not Available (Not tested/not functional or both) |
| N/A | Not supported by MCU |
| MCU Group | 8-Bit | 2 Channels Output | 3-Channel Output | Module-Stop Function | Event link function through ELC HAL driver * |
|---|---|---|---|---|---|
| S124 | N/A | N/A | N/A | N/A | N/A |
| S128 | ✓ | ✓ | ✓ | ✓ | ✓ |
| S1JA | ✓ | ✓ | N/A | ✓ | ✓ |
| S3A1 | ⌧ | ⌧ | N/A | ⌧ | ⌧ |
| S3A3 | ✓ | ✓ | N/A | ✓ | ✓ |
| S3A6 | ⌧ | ⌧ | N/A | ⌧ | ⌧ |
| S3A7 | N/A | N/A | N/A | N/A | N/A |
| S5D3 | N/A | N/A | N/A | N/A | N/A |
| S5D5 | N/A | N/A | N/A | N/A | N/A |
| S5D9 | N/A | N/A | N/A | N/A | N/A |
| S7G2 | N/A | N/A | N/A | N/A | N/A |
The DAC8 HAL module defines APIs for opening, closing, starting, stopping and writing to the DAC. 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.
DAC8 HAL Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| open | g_dac8.p_api->open(g_dac8.p_ctrl, g_dac8.p_cfgInitial Configuration. |
| close | g_dac8.p_api->close(g_dac8.p_ctrl)Close the D/A Converter. |
| write | g_dac8.p_api->write(g_dac8.p_ctrl, val)Write Sample value to the D/A Converter. |
| start | g_dac8.p_api->start(g_dac8.p_ctrl)Start the D/A Converter if it has not been started yet. |
| stop | g_dac8.p_api->stop(g_dac8.p_ctrl)Stop the D/A Converter if the converter is running. |
| versionGet | g_dac8.p_api->versionGet(&version)Retrieve the API version with the version pointer. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | API Call Successful. |
| SSP_ERR_HW_LOCKED | DAC resource is locked. |
| SSP_ERR_NOT_OPEN | Unit is not open. |
| SSP_ERR_ASSERTION | Wrong parameter. |
| SSP_ERR_IP_CHANNEL_NOT_PRESENT | Wrong channel selected. |
The DAC8 HAL module configures the 8-bit D/A converter (DAC8) to output one of 256 voltage levels between positive and negative reference voltages. The driver can be configured to accept the 8-bit output data in left‑or‑right‑justified format in a 16-bit input data. The driver supports two modes for the DAC.
To reduce the noise present in ADC readings the driver can configure synchronous anti-interference mode with the ADC module. This reduces conversion noise by disabling the DAC charge while the ADC is sampling. Check the hardware manual to determine if this feature is supported.
For operation at low AVCC voltage the driver can enable or disable the hardware charge pump.
Real-Time Mode
In real-time mode the output voltage is only changed on a signal from the ELC peripheral. Note when using real time mode the first call to dac_api_t::write() will set the initial output voltage.
As an illustration, the following code shows how to link the DAC8 output on channel 0 to the ELC software event and trigger the output to change.
This section describes how to include the DAC8 HAL Module in an application using the SSP configurator.
To add the DAC8 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 DAC8 Driver is g_dac8_0. This name can be changed in the associated Properties window.)
DAC8 HAL Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_dac8_0 DAC Driver on r_dac8 | Threads | New Stack> Driver> Analog> DAC Driver on r_dac8 |
When the DAC8 Driver on r_dac8 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 DAC8 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 DAC8 HAL Module on r_dac8
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enable or disable the parameter error checking. |
| Name | g_dac8_0 | Module name. |
| Channel | 0 | Channel selection. |
| Synchronize with ADC | Enabled, Disabled Default: Disabled | Choose whether to sync with the ADC module. |
| Data Format | Right Justified, Left Justified Default: Right Justified | Data format selection. |
| DAC Mode | Normal Mode, Real-time (Event Link) Mode Default: Normal Mode | DAC mode selection. |
| Charge Pump Enabled (Requires MOCO active) | Enabled, Disabled Default: Enabled | Enable or disable the charge pump. |
The DAC8 HAL module does not require a specific clock configuration.
To use the DAC8 HAL module, the port pins for the channels receiving the analog input must be set as analog pins in the pin configurator. The following table illustrates the method for selecting the pins within the SSP configuration window and the subsequent table illustrates an example selection for the DAC pins:
Pin Selection for the DAC8 HAL Module on r_dac8
| Resource | ISDE Tab | Pin selection Sequence |
|---|---|---|
| DAC8 | Pins | Select Peripherals> Analog:DAC8> DAC80. |
Pin Configuration Settings for the DAC8 HAL Module on r_dac8
| Property | Value | Description |
|---|---|---|
| Module Name | DAC80 | DAC Peripheral Module. |
| Operation Mode | Enabled, Disabled Default: Enabled | DAC Peripheral operation mode. |
| DA0 | None, DA0 Default: None | DAC Output Pin. |
| DA1 | None, DA1 Default: None | DAC Output Pin. |
The typical steps in using the DAC8 HAL module in an application are:
These common steps are illustrated in a typical operational flow diagram in the following figure: