EasyManua.ls Logo

Microchip Technology dsPIC30F - Page 398

Microchip Technology dsPIC30F
738 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
dsPIC30F Family Reference Manual
DS70064C-page 17-22 © 2004 Microchip Technology Inc.
17.12.2.2 Multiple Channels with Simultaneous Sampling
As shown in Figure 17-8 when using simultaneous sampling, the SAMC value specifies the
sampling time. In the example, SAMC specifies a sample time of 3 T
AD. Because automatic
sample start is active, sampling will start on all channels after the last conversion ends and will
continue for 3 A/D clocks. See Example 17-5 for code example.
Figure 17-8: Converting 4 Channels, Auto-Sample Start, T
AD Conversion Start, Simultaneous Sampling
Example 17-5: Converting 4 Channels, Auto-Sample Start,
T
AD Conversion Start, Simultaneous Sampling Code
TCONV TCONV TCONV TCONV
ADCLK
ch1_samp
ch2_samp
ch3_samp
ch0_samp
ADCBUF0
ADCBUF1
ADCBUF2
ADCBUF3
TCONV TCONV
DONE
SAMP
TSAMP
ADPCFG = 0xFF78; // RB0,RB1,RB2 & RB7 = analog
ADCON1 = 0x00EC; // SIMSAM bit = 1 implies ...
// simultaneous sampling
// ASAM = 1 for auto sample after convert
// SSRC = 111 for 3Tad sample time
ADCHS = 0x0007; // Connect AN7 as CH0 input
ADCSSL = 0;
ADCON3 = 0x0302; // Auto Sampling 3 Tad, Tad = internal 2 Tcy
ADCON2 = 0x030C; // CHPS = 1x implies simultaneous ...
// sample CH0 to CH3
// SMPI = 0011 for interrupt after 4 converts
ADCON1bits.ADON = 1; // turn ADC ON
while (1) // repeat continuously
{
ADC16Ptr = &ADCBUF0; // initialize ADCBUF pointer
OutDataPtr = &OutData[0]; // point to first TXbuffer value
IFS0bits.ADIF = 0; // clear interrupt
while (IFS0bits.ADIF); // conversion done?
for (count = 0; count < 4; count++) // save the ADC values
{
ADCValue = *ADC16Ptr++;
LoadADC(ADCValue);
}
} // repeat

Table of Contents

Other manuals for Microchip Technology dsPIC30F