Jump to main content

##

# 1.1 ACC PWM Generation

This example uses ACC peripheral Library to generate a PWM waveform with variable duty cycle.

## Description

This application example uses Analog Comparator to generate a PWM waveform by comparing the sine wave generated from the DAC with an external input voltage. Duty cycle of the PWM waveform is inversely proportional to the input voltage.

## Downloading and Building the Application

To clone or download this application from Github, go to the main page of this repository and then click Clone button to clone this repository or download as zip file. This content can also be downloaded using content manager by following these instructions.

Path of the application within the repository is apps/acc/acc_wav_gen/firmware.

To build the application, refer to the following table and open the project using its IDE.

Project Name | Description
--- | ---
sam_e70_xult.X | MPLABX project for SAM E70 Xplained Ultra Evaluation Kit
sam_v71_xult.X | MPLABX project for SAM V71 Xplained Ultra Evaluation Kit

## Setting Up the Hardware

The following table shows the target hardware for the application projects.

Project Name | Description
--- | ---
sam_e70_xult.X | SAM E70 Xplained Ultra Evaluation Kit
sam_v71_xult.X | SAM V71 Xplained Ultra Evaluation Kit

### Setting Up SAM E70 Xplained Ultra Evaluation Kit

- Comparator Positive Input: Connect an external voltage source to PD30 (Pin 3 of the J501)
- Comparator Negative Input: Sine wave from the DAC Channel 0. No connection required
- Connect the Debug USB port on the board to the computer using a micro USB cable

### Setting Up SAM V71 Xplained Ultra Evaluation Kit

- Comparator Positive Input: Connect an external voltage source to PD30 (Pin 28 of the Camera Interface connector)
- Comparator Negative Input: Sine wave from the DAC Channel 0 (No connection required)
- Connect the Debug USB port on the board to the computer using a micro USB cable

## Running the Application

1. Build and program the application project using its respective IDE
2. Observe the generated PWM waveform on the output pin using an oscilloscope
3. Change the positive input of the comparator from 0 to 3.3V and observe the duty cycle of the PWM waveform changing from 0 to 100 percentage

Refer to the table below for the PWM output pin of different boards:

Board | PWM Output Pin
--- | ---
SAM E70 Xplained Ultra Evaluation Kit | PB03 (Pin 7 of the J502 Connector)
SAM V71 Xplained Ultra Evaluation Kit | PB03 (Pin 20 of the Camera Interface connector)