EasyManua.ls Logo

Microchip Technology dsPIC30F - Page 401

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...
© 2004 Microchip Technology Inc. DS70064C-page 17-25
Section 17. 10-bit A/D Converter
10-bit A/D
Converter
17
Figure 17-11: Converting 1 Channel, Auto-Sample Start, Conversion Trigger Based Conversion Start
Example 17-6: Converting 1 Channel, Auto-Sample Start, Conversion Trigger Based
Conversion Start Code
ADCLK
SAMP
ADCBUF0
TSAMP
TCONV
BSF ADCON1,ASAM Instruction Execution
TCONV
TSAMP
ADCBUF1
DONE
Conversion
Trigger
ADPCFG = 0xFFFB; // all PORTB = Digital; RB2 analog
ADCON1 = 0x0040; // SSRC bit = 010 implies GP TMR3
// compare ends sampling and starts
// converting.
ADCHS = 0x0002; // Connect RB2/AN2 as CH0 input ..
// in this example RB2/AN2 is the input
ADCSSL = 0;
ADCON3 = 0x0000; // Sample time is TMR3, Tad = internal Tcy/2
ADCON2 = 0x0004; // Interrupt after 2 conversions
// set TMR3 to time out every 125 mSecs
TMR3 = 0x0000;
PR3 = 0x3FFF;
T3CON = 0x8010;
ADCON1bits.ADON = 1; // turn ADC ON
ADCON1bits.ASAM = 1; // start auto sampling every 125 mSecs
while (1) // repeat continuously
{
while (!IFS0bits.ADIF); // conversion done?
ADCValue = ADCBUF0; // yes then get first ADC value
IFS0bits.ADIF = 0; // clear ADIF
} // repeat

Table of Contents

Other manuals for Microchip Technology dsPIC30F