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:

Available versions of this example:

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

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

  1. C:\Program Files\Texas Instruments\ccsv4\ for CCS Installation
  2. C:\Program Files\Texas Instruments\ccsv4\tools\compiler\C2000\ for Code Generation Tools
  3. C:\Program Files\Texas Instruments\bios_5_41_10_36\ for DSP/BIOS Installation

Code Generation and Creation of an .out file using CCSv4:

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

  1. C:\ti\ccsv5\ for CCS Installation
  2. C:\ti\ccsv5\tools\compiler\c2000\ for Code Generation Tools
  3. C:\ti\bios_5_41_11_38\ for DSP/BIOS Installation

Code Generation and Creation of an .out file using CCSv5: