ANSEL turns the ADC on or off on the 12F675.
Use this to disable all ADC
ANSEL=%00000000
CMCON=7
ANSEL turns the ADC on or off on the 12F675.
Use this to disable all ADC
ANSEL=%00000000
CMCON=7
Dave
Always wear safety glasses while programming.
Thanks guys, you were both right; rookie mistaek on my part. It works now - onward and upward. Now the button turns on LED2 and off LED1. SWEET!
ANSEL = $9F 'FIRST FOUR BITS MAKE IT DIGITAL INPUT
ANSEL = %00000000
ADCON0 = $1F
ADCON0 = %00000000 'TURN OFF CONVERTER
CMCON = $19 'MAKE PINS DIGITAL
CMCON = %00000111
GPIO = %00000010 ' Set GPIO 1 high to turn on LED1
TRISIO = %00000001 ' set GPIO 1 & 2 to INputs, GPIO 0 OUTput
Main:
'*** Test the switch state ***
if GPIO.0 = 0 then led2 'If switch is pressed then jump to LED2 routine
GPIO.1 = 1 ' Turn LED1 on
GPIO.2 = 0 ' Turn LED2 off
goto Main ' Jump to the top of the main loop
LED2:
'*** Turn LED2 on ***
GPIO.2 = 1 ' LED2 on
GPIO.1 = 0 ' LED1 off
goto Main ' Jump to the top of the main loop
Welcome back Jeff,
3 years almost. I think what trips up people is this statement,
CMCON = $?? 'MAKE PINS DIGITAL
Which seems to reappear on a regular basis, perhaps copy paste, it should more factually report,
CMCON = $?? 'Disable input Comparators
The ANSEL is the 'MAKE PINS DIGITAL part of the equation, as you found out, My post here is for the future newbies who read this post.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
3 years...yes, i probably gave up for 3 years because of this. Also, i was using picbasic, not pro. Pro is SOOOOO much easier. it is worth the lute. I was struggling with the stupid button command for a couple weeks and gave up. Then i read Chuck Hellebuyck's book; "Programming PI uC's with picbasic" and he mentioned a workaround by directly addressing memory. I am finally starting to 'get it'. Thanks.
Glad to see you back, You are right, PBP IS worth the extra money.
I think the Button command is overly complicated vs 2 ifs, but maybe it saves codespace? Anyway keep on coding, the forum is here when you need it.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks