ADC-PWM Synchronization via ADC Interrupt
This example shows how to use the ADC and PWM blocks. In the generated code, changes in the voltage of the ADC input alter the duty cycle of the PWM output. The period of the PWM waveform remains constant. This example also shows how to use the Hardware Interrupt block to synchronize the update of the PWM duty cycle with the ADC conversion.
Required Hardware:
- Spectrum Digital F2808/F2812/F28335 eZdsp
- Texas Instruments™ F2808/F28027/F28035/F28044/F28069/F28335/F28343/F28346 ControlCARD with docking station
- Texas Instruments™ F28027/F28069 ControlSTICK
- Oscilloscope and probes
- Function generator
Available versions of this example:
- F281x based board: c281x_adcpwmasynctest.mdl
- F280x/F2823x/F2833x based board: c280x_2833x_adcpwmasynctest.mdl
- Piccolo F2802x/F2803x/F2806x based board: c280xx_adcpwmasynctest.mdl
Contents
Model
The following figure shows the example model:
Description
This example shows how to use the ADC block to sample an analog voltage and how to use the PWM block to generate a pulse waveform. The analog voltage controls the duty cycle of the PWM waveform. Duty cycle changes can be observed on the oscilloscope. "Hardware Interrupt" installs an Interrupt Service Routine (ISR) for ADC interrupt and schedules the execution of the connected subsystem (ADC-PWM Subsystem) when ADC interrupt (ADCINT) is received.
"ADC-PWM Subsystem" consists of an ADC driving the duty cycle input port of the PWM. PWM is configured to trigger ADC start of conversion (SOC).
Hardware Connections
Connect the function generator output to the ADC input ADCINA0 on the board. Connect the output of the PWM1 to the analog input of the oscilloscope.
How to Run the Example on the DSP Board
The following sections explain how to configure, build, and deploy the executable.
With Code Composer Studio v3.3 (CCSv3.3) - Default
- Open the model corresponding to the family of processor you are using.
- Each model is configured for a default processor. Open the Model Configuration Parameters dialog and select "Coder Target" under "Code Generation". Next, click "Target Hardware Resources" dialog to select a different processor.
- Click Build Model to generate, build, load and run the program.
- Observe the change of the PWM waveform on the oscilloscope.
With Code Composer Studio v4 (CCSv4)
CCSv4 support is provided via a makefile based approach. This requires running xmakefilesetup to set the environment. You can ignore the following if you have already gone through these steps. For more information, please refer to the Xmakefile Documentation
- Run XMakefile User Configuration.
- Set the Template parameter to gmake.
- Uncheck the Display operational configuration only checkbox.
- Set the Configuration parameter to ticcs_c2000_ccsv4, click Apply, if you haven't used this tool before, a dialog will ask you to browse to your CCSv4 installation folder. Pick the right folder and click OK.
- Click on the Tool Directories and make sure that the paths are pointing to directories matching your installation. For example:
- C:\Program Files\Texas Instruments\ccsv4\ for CCS Installation
- C:\Program Files\Texas Instruments\ccsv4\tools\compiler\C2000\ for Code Generation Tools
- C:\Program Files\Texas Instruments\bios_5_41_10_36\ for DSP/BIOS Installation
Code Generation and Creation of an .out file using CCSv4:
- Open the model corresponding to the family of processor you are using.
- Open the Model Configuration Parameters dialog and select "Coder Target" under "Code Generation". Next, click "Target Hardware Resources" dialog and set the IDE/Tool chain parameter to Texas Instruments Code Composer Studio v4 (makefile generation only).
- Change the selected board and processor to match your hardware.
- Click OK to save the changes.
- Click Build Model or press Ctrl+B to generate and build an .out executable file.
- Using CCSv4, connect to your board, load and run the .out file.
- Observe the PWM waveform on the oscilloscope.
With Code Composer Studio v5 (CCSv5)
CCSv5 support is provided via a makefile based approach. This requires running xmakefilesetup to set the environment. You can ignore the following if you have already gone through these steps. For more information, please refer to the Xmakefile Documentation
- Run XMakefile User Configuration.
- Set the Template parameter to gmake.
- Uncheck the Display operational configuration only checkbox.
- Set the Configuration parameter to ticcs_c2000_ccsv5, click Apply, if you haven't used this tool before, a dialog will ask you to browse to your CCSv5 installation folder. Pick the right folder and click OK.
- Click on the Tool Directories and make sure that the paths are pointing to directories matching your installation. For example:
- C:\ti\ccsv5\ for CCS Installation
- C:\ti\ccsv5\tools\compiler\c2000\ for Code Generation Tools
- C:\ti\bios_5_41_11_38\ for DSP/BIOS Installation
Code Generation and Creation of an .out file using CCSv5:
- Open the model.
- Open the Model Configuration Parameters dialog and select "Coder Target" under "Code Generation". Next, click "Target Hardware Resources" dialog and set the IDE/Tool chain parameter to Texas Instruments Code Composer Studio v5 (makefile generation only).
- Change the selected board and processor to match your hardware.
- Click OK to save the changes.
- Click Build Model or press Ctrl+B to generate and build an .out executable file.
- Using CCSv5, connect to your board, load and run the .out file.
- Observe the PWM waveform on the oscilloscope.