Datasheet

Audio PICtail
Plus Daughter Board User’s Guide
DS70297A-page 20 © 2007 Microchip Technology Inc.
The demo program consists of these basic software elements:
ADC Driver
Output Compare Module Driver
Loopback Application Software
3.1.1 ADC Driver
The ADC driver reads the incoming signal on the specified 12-bit ADC channel (either
AN0 or AN3), as determined by the ADC CH SEL jumper (J9). The driver interface is
specified in the file ADCChannelDrv.h. The driver is implemented in
ADCChannelDrv.c file.
The ADC driver uses DMA Channel 0 to read data from the ADC register. The DMA
channel is configured for continuous ping-pong operation, which allows the application
to read one buffer while the DMA is populating the other buffer. Buffer memory must be
allocated by the user application.
Parameters such as instruction cycle frequency, sampling rate, buffer size and ADC
module configuration are set in the ADCChannelDrv.h header file. Refer to the driver
documentation on the CD for details.
3.1.2 Output Compare Module Driver
The Output Compare PWM (OCPWM) Driver uses the Output Compare module to
convert digital data to a PWM signal. Either Output Compare Channel 1 or Channel 2
can be used. The driver interface is specified in the file OCPWMDrv.h and the driver is
implemented in OCPWMDrv.c file.
The driver uses DMA Channel 1 to write data to the OCxRS register in the Output
Compare PWM module. This channel is configured for continuous ping-pong
operation. The buffers for the driver must be allocated by the user application.
The Timer 2 module on the dsPIC33F or PIC24H device is configured for the maximum
PWM time period. The driver maps the input sample value to a time period, which is
then loaded into the OCxRS register. The OC output stays high until the Timer 2 value
matches the OCxRS register time period and then stays low for the rest of the PWM
period. This way the duty cycle of the OC PWM signal is proportional to the input digital
sample.
Parameters such as instruction cycle frequency, sampling rate, buffer size and PWM
carrier frequency are set in the OCPWMDrv.h header file. Refer to the driver
documentation on the CD for details.