Here are some snippets of code from a project of mine using a PIC18F45K80. I think you should remove this section from your code. When not using adcin, I prefer to manually set the adc registers.
Maybe something here will help you get it running.Code:'---------------------------------------------------------------------------------------- 'Define the Analog to Digital conversions DEFINE ADC_BITS 12 '12-bit resolution ' DEFINE ADC_CLOCK 5 'Set clock source to Frc/16 DEFINE ADC_CLOCK 6 'FOSC/64, 0.8uS @ 64Mhz DEFINE ADC_SAMPLEUS 50 'Sample time in uS before A/D conversion is started '-----------------------------------------------------------------------------------------
Code:'ADC----------------------------------------------------- ADCON0 = %00000001 ' A/D module enabled ADCON1 = %01110000 '%01110000 Vref = INT 4096, TRIG ctmu, NEG REF VSS ADCON2 = %10010100 ' Right justified, 12 Tad, Frc clock ANCON1 = %00000000 'Select Digital or Analog AN8 - AN14 '------------------------------------------------------------- TRISA = %00000011 ADC_AN0 var word ADC_AN1 var word '======================================================================= GET_AD0: ADCON0 = %00000001 'AN0 ENABLED ADCON0.1 = 1 @ nop @ nop @ nop @ nop @ nop @ nop @ nop @ nop WHILE ADCON0.1 = 1 ' A/D complete? @ nop @ nop WEND ADC_AN0.lowbyte =ADRESL ADC_AN0.highbyte = ADRESH '=================================================================== GET_AD1: ADCON0 = %00000101 'AN1 ENABLED ADCON0.1 = 1 @ nop @ nop @ nop @ nop @ nop @ nop @ nop @ nop WHILE ADCON0.1 = 1 ' A/D complete? @ nop @ nop WEND ADC_AN1.lowbyte =ADRESL ADC_AN1.highbyte = ADRESH '===================================================================




Bookmarks