For sure ADCIN will work for any PIC. This is the easy solution to get from them. But it takes a bit more code space than if you access directly to the registers.
i attach an example from melabs website.
Code:
adval var word 'Create adval to store result
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and RIGHT justify result
ADCON0 = %11000001 ' Configure and turn on A/D Module
Pause 500 ' Wait .5 second
loop: ADCON0.2 = 1 'Start Conversion
notdone: pause 5
if ADCON0.2 = 1 Then notdone 'wait for low on bit-2 of ADCON0, conversion finished
adval.highbyte = ADRESH 'move HIGH byte of result to adval
adval.lowbyte = ADRESL 'move LOW byte of result to adval
Lcdout $fe, 1 'Clear screen
Lcdout "Value: ", DEC adval 'Display the decimal value
Pause 100 'Wait .1 second
Goto loop 'Do it forever
End
Some programmer prefer to use this way... nobody's working the same way.
regards
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks