I have a 12f675 and want to have it read the AN0 every 10 seconds and if the analog input is below 0.75volts turn on GPIO.1 and if it is above 0.75 volts turn on GPIO.2, I don't need to store the value or anything just real time monitoring, what code do I need for this, I tried using the light meter example to make a code but no success.
Thanks,
ryan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The configuration word error happens to me all the time, especially when cutting and pasting code to another device. So I have to look up the device in the chipdata folder, to see what's allowed. Thats going to be right 99% of the time, OSC=INTRC_OSC_NOCLKOUT.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the message is :
compiled.asm:125:Error [113] Symbol not prevously defined (CHS2).
and
compiled.asm:146:Error [113] Symbol not prevously defined (CHS2).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Beg your pardon on the config, it looks to compile both ways. This program compiles and works fine for me.
Presuming you have GCBasic 9.3 installed, have you got the most recent update zip installed? The error is from the a-d.h file, the 12f675 does not have a CHS2, so that's why you are getting that error.
If the above still does not work, I have e-mailed you a copy of my a-d.h file, to keep you going.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a 12f675 and want to have it read the AN0 every 10 seconds and if the analog input is below 0.75volts turn on GPIO.1 and if it is above 0.75 volts turn on GPIO.2, I don't need to store the value or anything just real time monitoring, what code do I need for this, I tried using the light meter example to make a code but no success.
Thanks,
ryan
How about the ReadAD example on the online help? http://gcbasic.sourceforge.net/help/
Just substitute the Port pins, values x/256 = 0.75/5, and you are good to go. If you are still having problems, then post your code.
I m getting a assembly error when I use this code, why?
#chip 12F675, 4 'mhz
#config OSC=INTOSC, MCLRE=off, WDT=off
'Set the pin directions
dir GPIO.0 in
dir GPIO.1 out
dir GPIO.2 out
'Main routine
Start:
if ReadAD(AN0) >= 41 then set GPIO.1 on
if ReadAD(AN0) < 41 then set GPIO.2 on
goto start
The configuration word error happens to me all the time, especially when cutting and pasting code to another device. So I have to look up the device in the chipdata folder, to see what's allowed. Thats going to be right 99% of the time, OSC=INTRC_OSC_NOCLKOUT.
the error is from the "IF" line because when I take it out it goes through, it says something about a undefined character
the message is :
compiled.asm:125:Error [113] Symbol not prevously defined (CHS2).
and
compiled.asm:146:Error [113] Symbol not prevously defined (CHS2).
Beg your pardon on the config, it looks to compile both ways. This program compiles and works fine for me.
Presuming you have GCBasic 9.3 installed, have you got the most recent update zip installed? The error is from the a-d.h file, the 12f675 does not have a CHS2, so that's why you are getting that error.
If the above still does not work, I have e-mailed you a copy of my a-d.h file, to keep you going.
For anyone who reads this later, Kent's a-d.h file is now included in update.zip. Please see http://gcbasic.sourceforge.net/update.html