Whoops, sorry about that!
here's the code:
oSCCON = %01100000 ' Ocs set to 4 MHz
TRISIO = %00000000 ' Set all ports to outputs, in this example
CMCON0 = 7 ' Analog comparators off
ANSEL = 0 ' Analog select set to digital, pg 69 data
ADCON0 = 0 ' A/D turned OFF, pg 68 of data
input gpio.4
inpulse VAR Word
memory var word
low gpio.4
low gpio.3
start:
SEROUT 0, 2, [12]
start2:
PULSIN 1, 1, inpulse
if inpulse<50 then
read 5, memory
serout 0,2,[12,17, "Activating",13,"Failsafe :", #memory*10]
goto start2
else
endif
if gpio.4=1 then
write 5, inpulse
serout 0,2,[12,17,"Failsafe",13,"Stored :", #inpulse*10]
high gpio.3
low gpio.4
else
low gpio.3
endif
SEROUT 0, 2, [17,22,#inpulse*10]
PAUSE 20
GOTO start
END
OSCCON = %01100000 ' Ocs set to 4 MHz
TRISIO = %00000000 ' Set all ports to outputs, in this example
CMCON0 = 7 ' Analog comparators off
ANSEL = 0 ' Analog select set to digital, pg 69 data
ADCON0 = 0 ' A/D turned OFF, pg 68 of data
input gpio.4 '<font color=red> make input</font color>
inpulse VAR Word
memory var word
low gpio.4 <font color = red> ' Now you make it an output</font color>
low gpio.3
start:
SEROUT 0, 2, [12]
start2:
PULSIN 1, 1, inpulse
if inpulse<50 then
read 5, memory
serout 0,2,[12,17, "Activating",13,"Failsafe :", #memory*10]
goto start2
else
endif
if gpio.4=1 then '<font color=red> still an output, are you wanting an input?</font color>
write 5, inpulse
serout 0,2,[12,17,"Failsafe",13,"Stored :", #inpulse*10]
high gpio.3
low gpio.4 '<font color=red> is and should be an output</font color>
else
low gpio.3
endif
SEROUT 0, 2, [17,22,#inpulse*10]
PAUSE 20
GOTO start
END
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.
Thanks Joe,
I didn't catch that, I'll make changes and see if that fixes the input problem.
I still have the output issue though with GPIO.3, it doesn't want to run the LED.
Any thoughts?
John.
Not sure but I think that pin is input only.
Dave
Always wear safety glasses while programming.
I dunno John, I never use the High / Low convention, preferring to specify TRISIO AND GPIO instead because as I understand it , High/Low reads modify's and writes the whole port ( all the I/Os ) when you do.
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.
Thanks guys,
I think I've got it working OK now...but by copy of the picbasic compiler (with microcode studio) only limits me to 31 code lines
As much as I like Microcode Studio...is there something out there a guy can use that is much cheaper than picbasic pro AND is downloadable from the NET?
John.
Bookmarks