Hi there,
Maybe you've [seen this/done this/fixed this...]
PIC16F628
If I try to compile with ADCON:
symbol priviously undefined ADCON0 and GO_DONE
If I try without ADCON: syntax error
There is no reference to adcon in the datasheet.
CMCON does nothing for me either.
If the ANx pins are powered up as comparators, how do I set them to analog inputs to read a pot? Yes, I made an honest attempt at the datasheet.
CODE:
'Read a POT on AN0
'Code converted from F876 to F628 to test ICD with realtime input
'DEFINES
Define ADC_BITS 8
define ADC_CLOCK 30
define ADC_SAMPLEUS 50
define OSC 4
define ADCON1
cmcon = %00000001
'VARIABLES
adval var byte
v_in var byte
Init:
portb = $00
trisb =$0
v_in = porta.1
Main:
trisa = %00000001
trisb = %11111111
loop:
adcin v_in,adval 'Read channel 0 adval
ledtst1:
if adval > 5 then tst2
portb = %00000001
goto cont
tst2:
if adval > 10 then tst3
portb = %00000011
goto cont
tst3:
if adval > 20 then tst4
portb = %00000111
goto cont
tst4:
if adval > 40 then tst5
portb = %00001111
goto cont
tst5:
portb = %00011111
cont:
pause 100
goto loop
end
Bookmarks