PDA

View Full Version : Funky I/O pin behavior on PIC12F629???



charliez
- 25th July 2004, 07:08
Problem 1. For some reason, pin 0 and pin 1 will not latch the output value when another pin output follows it. Other pins work fine (I know pin 3 is input only).

The code is as follows:

i var byte

loop: 'turn on LEDs
HIGH 0
pause 5000 ' led 0 will stay on for 5 seconds
HIGH 1 ' but will turn off here, and led 1 comes on
pause 5000 ' led 1 will then stay on for 5 seconds
HIGH 2 ' led 1 will turn off here, and led 2 comes on
pause 5000
HIGH 4 ' led 4 on, led 2 stays on, while 0 and 1 are off.
pause 5000
HIGH 5 ' led 5,4,2 stays on, while 0 and 1 are off
pause 10000

For i = 0 to 5 'turn off LEDs
LOW i
next
pause 10000

goto loop

End

Problem 2. Pin 1 for some reason can not be made an input.

The code is as follows

PINS VAR PORTL

PIN0 VAR PINS.0
PIN1 VAR PINS.1

INPUT 1

IF PIN1 THEN
HIGH 0
ENDIF

END

What am I missing?

charliez
- 26th July 2004, 00:29
Ha, found the cause. GP0 and GP1 are comparator inputs.

To make them true I/O pins I needed to add the following line:

CMCON=%00000111

at the beginning