![]() |
Synergy Software Package User's Manual
|
The Audio Playback Framework DAC module provides a high-level API for audio playback applications and handles the synchronization needed to play 8-bit or 16-bit pulse-code modulation (PCM) samples. The Audio Playback DAC Framework uses the DAC/DAC8, timer (AGT or GPT) and data-transfer (DMA or DTC) peripherals on a Synergy MCU. A user-defined callback can be created to respond to the need for additional data.
The Audio Playback DAC Framework module defines APIs for operations such as opening, starting, playing and stopping. 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.
Audio Playback DAC Framework Module API Summary
| Function Name | Example API Call and Description |
|---|---|
| open | g_sf_audio_playback_hw0.p_api->open( g_sf_audio_playback_hw0.p_ctrl, g_sf_audio_playback_hw0.p_cfg);Open a device channel for read/write and control. |
| start | g_sf_audio_playback_hw0.p_api->start( g_sf_audio_playback_hw0.p_ctrl, &p_data, Timeout);Start Audio Playback Hardware. |
| stop | g_sf_audio_playback_hw0.p_api->stop( g_sf_audio_playback_hw0.p_ctrl);Stop Audio Playback Hardware. |
| play | g_sf_audio_playback_hw0.p_api->play (g_sf_audio_playback_hw0.p_ctrl, p_buffer, length);Play audio buffer. |
| dataTypeGet | g_sf_audio_playback_hw0.p_api->dataTypeGet( g_sf_audio_playback_hw0.p_ctrl, p_data_type);Store expected data type in provided pointer p_data_type. |
| close | g_sf_audio_playback_hw0.p_api->close( g_sf_audio_playback_hw0.p_ctrl);Close the audio module. |
| versionGet | g_sf_audio_playback_hw0.p_api->versionGet(&version);Return the version of the module with the version pointer. |
Status Return Values
| Name | Description |
|---|---|
| SSP_SUCCESS | Function successful. |
| SSP_ERR_ASSERTION | A pointer is NULL or a parameter is invalid. |
| SSP_ERR_OUT_OF_MEMORY | The number of streams open at once is limited to SF_AUDIO_PLAYBACK_CFG_MAX_STREAMS. If this number is exceeded, an out of memory error occurs. |
| SSP_ERR_TIMEOUT | Timeout occurred before playback finished. |
| SSP_ERR_NOT_OPEN | The stream control block p_ctrl is not initialized. |
The Audio Playback Framework DAC module creates a thread internally to support audio playback. The following figure shows a flowchart of the Audio Playback Framework thread and its interactions with public Audio Playback Framework APIs.
Suggested use of the Audio Playback Framework:
The Audio Playback DAC Framework supports multiple audio streams on a single hardware port. A block diagram of the modules required if two streams are used is shown in the following figure:
&R_DAC->DADRn[0] if using DAC channel 0 or &R_DAC->DADRn[1] if using DAC channel 1.&R_DAC8->DADRn[2] if using DAC8 channel 2 (S128) or &R_DAC8->DADRn[0] if using DAC8 channel 0 (S1JA).&R_DAC->DADRn[0] if using DAC channel 0 or &R_DAC->DADRn[1] if using DAC channel 1.&R_DAC8->DADRn[2] if using DAC8 channel 2 (S128) or &R_DAC8->DADRn[0] if using DAC8 channel 0 (S1JA).This section describes how to include the Audio Playback DAC Framework module in an application using the SSP configurator.
To add the Audio Playback DAC Framework module to an application, simply add it to a HAL /Common thread using the stacks selection sequence given in the following table. (The default name for the Audio Playback DAC Framework module is g_sf_audio_playback_hw0. This name can be changed in the associated Properties window.)
Audio Playback DAC Framework Module Selection Sequence
| Resource | ISDE Tab | Stacks Selection Sequence |
|---|---|---|
| g_sf_audio_playback_hw0 Audio Playback Hardware Framework on g_sf_audio_playback_hw0 | Threads | New Stack> Framework> Audio> Audio Playback Hardware Framework on g_sf_audio_playback_hw_dac |
When the Audio Playback DAC Framework module on sf_audio_playback_hw_dac 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 Audio Playback DAC Framework module must be configured by the user for the desired operation. The SSP configuration window will automatically identify (by highlighting the block in red) any required configuration selections, such as interrupts or operating modes, which must be configured for lower-level modules in order to ensure successful operation. Furthermore, only those properties that can be changed without causing conflicts are available for modification. Other properties are 'locked' and are 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 Audio Playback DAC Framework Module on sf_audio_playback_hw_dac
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enables or disables the parameter checking. |
| DMAC Support | Disabled, Enabled Default: Disabled | DMAC support selection. |
| Name | g_sf_audio_playback_hw0 | Module name. |
In some cases, settings other than the defaults for lower-level modules can be desirable. For example, it might be useful to select the DAC channel based on the target hardware implementation. The configurable properties for the lower-level stack modules are given in the following sections for completeness and as a reference.
Typically, only a small number of settings must be modified from the default for lower-level drivers as indicated with 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 Transfer Driver on r_dmac Software Activation
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Selects if code for parameter checking is to be included in the build. |
| Name | g_transfer0 | Module name. |
| Channel | 0 | Channel selection. |
| Mode | Normal | Mode selection. |
| Transfer Size | 2 Bytes | Transfer size selection. |
| Destination Address Mode | Fixed | Destination address mode selection. |
| Source Address Mode | Incremented | Source address mode selection. |
| Repeat Area (Unused in Normal Mode | Source | Repeat area selection. |
| Destination Pointer | NULL | Destination pointer selection. |
| Source Pointer | NULL | Source pointer selection. |
| Number of Transfers | 0 | Number of transfers selection. |
| Number of Blocks (Valid only in Block Mode) | 0 | Number of blocks selection. |
| Activation Source | Software Activation, Peripheral Events Default: Software Activation | Activation source selection. |
| Auto Enable | False | Auto enable selection. |
| Callback | NULL | Callback selection. |
| Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Disabled | Interrupt priority selection. |
Configuration Settings for the Transfer Driver on r_dmac Software Activation 1
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Selects if code for parameter checking is to be included in the build. |
| Software Start | Enabled, Disabled Default: Disabled | Software start selection. |
| Linker section to keep DTC vector table | .ssp_dtc_vector_table | Linker section selection. |
| Name | g_transfer0 | Module name. |
| Mode | Normal | Mode selection. |
| Transfer Size | 2 Bytes | Transfer size selection. |
| Destination Address Mode | Fixed | Destination address mode selection. |
| Source Address Mode | Incremented | Source address mode selection. |
| Repeat Area (Unused in Normal Mode | Source | Repeat area selection. |
| Interrupt Frequency | After all transfers have completed | Interrupt frequency selection. |
| Destination Pointer | NULL | Destination pointer selection. |
| Source Pointer | NULL | Source pointer selection. |
| Number of Transfers | 0 | Number of transfers selection. |
| Number of Blocks (Valid only in Block Mode) | 0 | Number of blocks selection. |
| Activation Source (Must enable IRQ) | Software Activation 1, Software Activation 2, Peripheral Events Default: Software Activation 1 | Activation source selection. |
| Auto Enable | False | Auto enable selection. |
| Callback (Only valid with Software start) | NULL | Callback selection. |
| ELC Software Event Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Disabled | ELC Software Event interrupt priority selection. |
Configuration Settings for the Timer Driver on r_agt
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enables or disables parameter checking. |
| Name | g_timer0 | Module name. |
| Channel | 0 | Physical hardware channel. |
| Mode | Periodic | Warning: One-shot functionality is not available in the GPT hardware, so it is implemented in software by stopping the timer in the ISR called when the period expires. For this reason, ISRs must be enabled for one-shot mode even if the callback is unused. |
| Period Value | 10 | See Timer Period Calculation. |
| Period Unit | Hertz | See Timer Period Calculation. |
| Auto Start | False | Set to true to start the timer after configuring or false to leave the timer stopped until timer_api_t::start is called. |
| Count Source | PCLKB, PCLKB/8, PCLKB/2, LOCO, AGT0 Underflow, AGT0 fSub Default: PCLKB | The clock source for the AGT counter. |
| AGTO Output Enabled | True, False Default: False | Set to true to output the timer signal on a port pin configured for AGT (AGTO pin). Set to false for no output of the timer signal. |
| AGTIO Output Enabled | True, False Default: False | Set to true to output the timer signal on a port pin configured for AGT (AGTIO pin). Set to false for no output of the timer signal. |
| Output Inverted | True, False Default: False | Set to false to start the output signal low. Set to true to start the output signal high. |
| Enable comparator A output pin | True, False Default: False | Enable comparator A output pin selection. |
| Enable comparator B output pin | True, False Default: False | Enable comparator B output pin selection. |
| Callback | NULL | A user callback function can be registered in timer_api_t::open. If this callback function is provided, it will be called from the interrupt service routine (ISR) each time the timer period elapses. Warning: Since the callback is called from an ISR, care should be taken not to use blocking calls or lengthy processing. Spending excessive time in an ISR can affect the responsiveness of the system. |
| Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Disabled | Timer interrupt priority. 0 is the highest priority. |
Configuration Settings for the Timer Driver on r_gpt
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enables or disables the parameter checking. |
| Name | g_timer0 | Module name. |
| Channel | 0 | Channel selection. |
| Mode | Periodic | Warning: One-shot functionality is not available in the GPT hardware, so it is implemented in software by stopping the timer in the ISR called when the period expires. For this reason, ISRs must be enabled for one-shot mode even if the callback is unused. |
| Period Value | 10 | See Timer Period Calculation. |
| Period Unit | Hertz | See Timer Period Calculation. |
| Duty Cycle Value | 50 | Duty cycle value selection. |
| Duty Cycle Unit | Unit Raw Counts, Unit Percent, Unit Percent x 1000 Default: Unit Raw Counts | Duty cycle unit selection. |
| Auto Start | False | Set to true to start the timer after configuring or false to leave the timer stopped until timer_api_t::start is called. |
| GTIOCA Output Enabled | True, False Default: False | Set to true to output the timer signal on a port pin configured for GPT. Set to false for no output of the timer signal. |
| GTIOCA Stop Level | Pin Level Low, Pin Level High, Pin Level Retained Default: Pin Level Low | Controls output pin level when the timer is stopped. |
| GTIOCB Output Enabled | True, False Default: False | Set to true to output the timer signal on a port pin configured for GPT. Set to false for no output of the timer signal. |
| GTIOCB Stop Level | Pin Level Low, Pin Level High, Pin Level Retained Default: Pin Level Low | Controls output pin level when the timer is stopped. |
| Callback | NULL | A user callback function can be registered in timer_api_t::open. If this callback function is provided, it will be called from the interrupt service routine (ISR) each time the timer period elapses. Warning: Since the callback is called from an ISR, care should be taken not to use blocking calls or lengthy processing. Spending excessive time in an ISR can affect the responsiveness of the system. |
| Interrupt Priority | Priority 0 (highest), Priority 1:14, Priority 15 (lowest - not valid if using ThreadX) Default: Disabled | Interrupt priority selection. |
Configuration Settings for the DAC HAL Module on r_dac
| ISDE Property | Value | Description |
|---|---|---|
| Parameter Checking | BSP, Enabled, Disabled Default: BSP | Enable or disable the parameter error checking. |
| Name | g_dac0 | Module name. |
| Channel | 0 | Set to 0 for output DA0 or 1 for output DA1. |
| Synchronize with ADC | Enabled, Disabled Default: Disabled | Set to true for anti-interference synchronization with the Analog-to-Digital Converter (ADC) Module. Set to false if power supply interference between the analog modules is not a problem, or if asynchronous conversion by the DAC Module is desired. |
| Data Format | Right Justified | Set to zero, if 12-bit data values are loaded in bits 11 through 0, or right justified. Set to one, if 12-bit data values are loaded in bits 15 through 4, or left justified. |
| Output Amplifier | Enable, Disable Default: Disable | Set to true, if output amplifier hardware function is desired. Set to false to bypass output amplifier hardware function. |
Configuration Settings for the DAC8 HAL Module 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 | 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 Audio Playback DAC Framework hardware modules use the peripheral clocks available in the Clocks configuration window.
The DAC or SSI peripheral module uses pins on the MCU to communicate to external devices. I/O pins must be selected and configured as required by the external device. The following tables illustrate the method for selecting the pins within the SSP configuration window and show an example selection for the associated pins.
Pin Selection Sequence for the Audio Playback DAC Framework Module
| Resource | ISDE Tab | Pin selection Sequence |
|---|---|---|
| DAC | Pins | Select Peripherals > Analog:DAC12 > DAC120/121 |
| SSI | Pins | Select Peripherals > Connectivity:SSI > SSI/0/1 |
Pin Configuration Settings for the DAC HAL Module on r_dac
| Pin Configuration Property | Value | Description |
|---|---|---|
| Operation Mode | Enabled, Disabled | Operation selection. |
| DAC | None, P014 Default: P014 | DAC pin selection. |
The typical steps in using the Audio Playback DAC Framework module in an application are:
These common steps are illustrated in a typical operational flow in the following figure: