I have a program with ReadAD, I get back, or think I get back a 0, not sure why ReadAD is not working, but wrote a small routing to blink an LED with the count from it (maybe it will not load in a byte.
Now I get a compiler error :23 I believe. 23 is a Loop, but I moved it and still get the :23 on the end. Here is the code that will not compile. I only changed if then's TO do until loop and that broke it.
#chip 12F675, 4
#config osc = int
#define LIGHT AN0 'ADC input from AC lit LED
#define LED GPIO.2 'LED to blink for AD value
Dir LIGHT In
Dir LED Out
Dim i as byte
Do
blink
blink
blink
wait 1500 msec
i = ReadAD(LIGHT)
'100s
do until i < 100
blink
i=i-100
loop
wait 1500 msec
blink
blink
blink
wait 1500 msec
'10s
do until i < 10
blink
i-i=10
loop
wait 1500 msec
blink
blink
blink
wait 1500 msec
for i = 1 to i
blink
next
wait 1500 msec
loop
end
sub blink
set LED on
wait 250 msec
set LED off
wait 250 msec
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a program with ReadAD, I get back, or think I get back a 0, not sure why ReadAD is not working, but wrote a small routing to blink an LED with the count from it (maybe it will not load in a byte.
Now I get a compiler error :23 I believe. 23 is a Loop, but I moved it and still get the :23 on the end. Here is the code that will not compile. I only changed if then's TO do until loop and that broke it.
#chip 12F675, 4
#config osc = int
#define LIGHT AN0 'ADC input from AC lit LED
#define LED GPIO.2 'LED to blink for AD value
Dir LIGHT In
Dir LED Out
Dim i as byte
Do
blink
blink
blink
wait 1500 msec
i = ReadAD(LIGHT)
'100s
do until i < 100
blink
i=i-100
loop
wait 1500 msec
blink
blink
blink
wait 1500 msec
'10s
do until i < 10
blink
i-i=10
loop
wait 1500 msec
blink
blink
blink
wait 1500 msec
for i = 1 to i
blink
next
wait 1500 msec
loop
end
sub blink
set LED on
wait 250 msec
set LED off
wait 250 msec
end sub
Just realized the error was in the ASM line 23 not the source. Offending translation from the above program to ASM
Will this function maybe not read AD to a variable?
ADREADPORT EQU 36
ADTEMP EQU 38
I EQU 39
I-I EQU 40 <----------- this is :23
READAD EQU 41
I think the "I-I" is coming from here:
'10s
do until i < 10
blink
i-i=10
loop
The compiler probably should be a bit more helpful there, I will see if I can add a new error message.
Found the typo/error..
'10s
do until i < 10
blink i-i=10 <--- Duhh.
loop
Anyone see any problem with the ReadAD into a byte? Change the define from AN0 to GPIO.0 as well but have not tested it.
The
i = ReadAD(LIGHT)
byte I seems to be zero assuming my code is working. I dropped a scope on the pin and it is floating from 4-5volts.
Does the ReadAD to all the A/C setup aotumatically? Maybe I have a bad chip, will try another with a pot from VDD/VSS/the_pin today…
Anyone else using the 675 and GPIO.0 and it works?
Thanks