English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (514/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
EXAMPLE 22-3: CONVERTING 1 CHANNEL, MANUAL SAMPLE START, TAD-BASED
CONVERSION START CODE
AD1PCFG = ~(1 << 5);
// all PORTB = Digital but RB5 = analog
AD1CON1 = 0x00E0;
// SSRC bit = 111 implies internal
// counter ends sampling and starts converting.
AD1CHS = 5 << 16;
// Connect RB5/AN5 as CH0 input
AD1CSSL = 0;
AD1CON3 = 0x1F02;
// Sample time = 31Tad
AD1CON2 = 0;
AD1CON1SET = 0x8000;
// turn ADC ON
while (1) // repeat continuously
{
AD1CON1SET = 0x0002;
// start sampling then
// after 31Tad go to conversion
while (!(AD1CON1 & 0x0001));
// conversion done?
ADCValue = ADC1BUF0;
// yes then get ADC value
}
// repeat
DS61143E-page 512
Preliminary
© 2008 Microchip Technology Inc.