![](http://datasheet.mmic.net.cn/Rabbit-Semiconductor/101-1007_datasheet_95644/101-1007_28.png)
20
PowerCore FLEX
ADC_MUX_EXTERNAL2.c
—Demonstrates how to implement MUX control to read
external A/D channels randomly in your application program. This sample program
will also read and display the voltage of the external A/D channel that is located on pin
7 of header J3 on the PowerCore Prototyping Board.
Since there is only one A/D converter channel on the Prototyping Board, the MUX con-
trol is simulated by using LED DS5 on the Prototyping Board, which is controlled by
PD5.
LED = OFF = A/D channel 0
LED = ON = A/D channel 1.
The following steps explain how to
implement the MUX routine for random A/D channel
selection.
1. Define the number of A/D channels. Change the default from 1 to the number of A/D channels in
your design.
#define MAX_ADCHANNELS <Number Channels>
2. Provide an application MUX function that does the following:
A/D converter channel selection via your hardware MUX circuit.
Change the _adc_mux_channel index to the channel selected.
Add delay for the channel switching settling time.
Set the adc_conversion_done flag to FALSE.
3. Add I/O initialization code at the beginning of your application program for the port pins used for
MUX control.
4. Then:
Call your routine with the A/D converter channel selected.
Wait in a nonblocking wait routine for the adc_conversion_done flag to become TRUE.
Read the A/D converter.
Repeat the sequence.
In order to run this sample program, you will need a separate power supply. Connect
the positive lead from the power supply to the A/D channel input located on pin 7 of
header J3 on the Prototyping Board. Connect the negative lead from the power supply
to the GND located on pin 8 of J3 on the Prototyping Board.
ADC_RD_EXTERNAL.c
—Demonstrates how to read and display the voltage of the
external A/D converter located on the Prototyping Board. The voltage is calculated
from coefficients read from the simulated EEPROM in flash memory. The external A/D
channel is located on pin 7 of header J3 on the PowerCore Prototyping Board.
In order to run this sample program, you will need a separate power supply. Connect
the positive lead from the power supply to the A/D channel input located on pin 7 of
header J3 on the Prototyping Board. Connect the negative lead from the power supply
to the GND located on pin 8 of J3 on the Prototyping Board.