Not sure if this helps, but this is a section of code that uses an 18f4580, with four pots on port A
Code:
; config settings 18F2550/4550/18F4580, 20mhz crystal
ASM
__CONFIG _CONFIG1H, _OSC_HSPLL_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
ENDASM
DEFINE OSC 48
ADCON1 = $0F
clear
DEFINE ADC_BITS 10 ' Set-up ADC for fastest 10-bit results
DEFINE ADC_CLOCK 2
DEFINE ADC_SAMPLEUS 5
INCLUDE "DT_Analog.pbp"
MaxSetPoint CON 500 ' Pot fully clockwise - gives max setting 50 degrees
MinSetPoint CON 100 ' Pot fully counter clockwise - sets min setting 10 degrees
ADbits = 14 ' set A/D resolution to 14-bits
CMCON = 7 ' disable Comparators
ADCON1 = %00001011 ' sets up Analogue pins
ADCON2.7 = 1 ' ADFM bit isn't in ADCON1 anymore
;----[Port settings]----------------------------------------------------
TRISA = %11001111
It uses DT's analogue include file, which might be worth downloading and including in your own code
Bookmarks