Generating Waveforms with PCA
Generating waveforms of a particular frequency.
Using the frequency output mode of the PCA, generate a square wave on pin
CEX0. We will control the frequency with a global variable, but the range will
be limited to 1 KHz to 250 KHz.
- Determine what frequency clock source will be required for the PCA clock.
Remember that FCEXn = FPCA/2*PCA0CPHn
- Use the config tool to configure the PCA so that:
- CEX0 is enabled on the Port I/O Crossbar (be sure to copy ALL of the XBRO
registers to your configuration routine.
- Configure PCA counter timebase to the appropriate clock input.
- Start the PCA Counter/Timer.
- Module 0 is configured for Frequency Output Mode, with 1 KHz frequency.
- Write a program, waveforms.c, that calls the Port I/O and PCA configuration routines and then waits in an infinite loop.
Use a global variable for the frequency.
- Measure the frequency of the CEX0
output (Port 0, pin0) on the oscilloscope. You may measure the signal directly
from the header on the board. Recall how the port pins are
arranged on the headers:
Be careful not to short pins with the large alligator clip
scope probes.
-
Change the frequency from the minimum value of 1KHz to the maximum value of
250 KHz. Verify this frequency measurement on the oscilloscope.