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.
- 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
- Texas Instruments™ F28M35xx/F28M36xx ControlCARD(To use F28M35x/F28M36x you need Texas Instruments C2000 Concerto Support Package)
- Texas Instruments™ F2807x/F2837xS/F2837xD ControlCARD or LaunchPad
- Oscilloscope and probes
- Function generator
Available versions of this example:
- F281x based board: c281x_adcpwmasynctest_ert.slx
- F280x/F2823x/F2833x based board: c280x_2833x_adcpwmasynctest_ert.slx
- Piccolo F2802x/F2803x/F2806x or Concerto F28M35x/F28M36x based board: c280xx_adcpwmasynctest_ert.slx
- Piccolo F2807x or Delfino F2837xS/F2837xD based board: c2807x_2837xx_adcpwmasynctest_ert.slx
The following figure shows the example model:
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).
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 hardware board
The following sections explain how to configure, build, and deploy the executable.
- Open the model corresponding to the target hardware you are using.
- Each model is configured for a default target hardware. To select a different target hardware, go to Model Configuration Parameters > Hardware Implemenation > Hardware board.
- By default, the model is configured with the CCSv5 toolchain to build, load and run. To change the version of toolchain, go to Model Configuration Parameters > Code Generation > Build process > Toolchain and select the appropriate toolchain matching your Code Composer Studio(CCS) installation.
- Note that with CCSv3.3, download of the executable to the target is not supported. After building the model, use CCSv3.3 to download and run the program on the hardware.
- Click Build Model to generate, build, load and run the program.
- Observe the change of the PWM waveform on the oscilloscope.