You conversion clock seems a bit high @48MHz operation, and your first example in C used ANCON0, not yours.... yet...
While it's not a problem for now, one day you may need to disable some analog feature on this PIC... however, seems ANCON0 and ANCON1 are not included in PBP 2.50c, so I guess the following would be handy one day or another.
EDIT: for some odd reason, ANCON0 & ANCON1 are commented in PIC18EXT.BAS, i'd sent an e-mail to Melabs, obviously they must have a reason for that.Code:' ' Configure ADC ' ============= ANCON0 VAR BYTE EXT ' not included in PBP2.50c ANCON1 VAR BYTE EXT ' not included in PBP2.50c ANCON0 = %10011110 ' -xx------ Not Implemented ' 1--1111-- AN7, & AN<4:1> = Digital ' -------0- AN0 = Analog ANCON1 = %11111111 ' 11111111- AN<15:10> = Digital ADCON0 = %00000001 ' 0-------- VCFG1, Vref- 0 = AVss (1=AN2) ' -0------- VCFG2, Vref+ 0 = AVdd (1=AN3) ' --0000--- CHS<3:0>, Channel select -- 0 ' ------0-- Go/Done, don't care for now ' -------1- ADON, Enable ADC ADCON1 = %10000111 ' 1-------- ADFM, Right justified result ' -0------- ADCAL, Normal A/D converter operation ' --000---- ACQT<2:0>, A/D Aquisition time = 0 Tad ' -----111- ADCS<2:0>, A/D conversion clock = FRC ' ' Hardware Aliases ' ================ GoDone var ADCON0.1 ' StartConversion = 1, Conversion done = 0 ' ' Software Variables ' ================== @ADVal = ADRESL ADVal VAR WORD EXT Start: pauseus 10 ' Acquisition time GoDone = 1 While GoDone : Wend LCDOUT $FE, 1, "Value: ", DEC ADVal PAUSE 250 GOTO START




Bookmarks