Hi all:
I am pulling out what little hair I have left on this.
Such a simple program segment, that I cannot get to work using GPIO.3 as an input.
I simply want to turn on a test LED connected to GPIO.4 for a short time (PAUSE 2000), after GPIO.3 is momentarily pulled low, and then turn it off, and loop till GPIO.3 is momentarily pulled low again. This is only to confirm whether this module is working or not.
It works fine with other GPIO's set up as inputs / outputs, but when I try to use GPIO.3 as the input, it does the following:
The test LED instantly comes on, and stays on, until GPIO.3 is pulled low, it will then turn off and stay off out as long as GPIO.3 is pulled low. (I have a 10K pull-up on GPIO.3 , probably do not need it but it's there.)
I have searched the forum, read Melanies thread on fuse configs, etc , but must be missing something very basic.
The simple program segment is below:
ANSEL = %00000000
CMCON0 = 7
CMCON1 = 7
ADCON0 = %00000000
INTCON = 0
define OSC 8
@DeviceMCLR_OFF
TRISIO = %101000
Main:
GPIO.4 = 0
IF GPIO.3 = 1 THEN Main
GPIO.4 = 1 'TEST LED IS TURNED ON HERE
PAUSE 2000
GPIO.4 = 0 'TEST LED IS TURNED OFF HERE
GOTO Main
For test purposes I have nothing else connected to the PIC.
As you can see, I have the TRIS register configured to also use GPIO.5 as an output rather than .3 , which does indeed work fine.
Can someone please enlighten me?
Thanks
Ken
Bookmarks