PDA

View Full Version : Problem setting pins on 12f675



srnet01
- 15th February 2009, 09:05
I have been trying some simple programs to test the PICkit 2 logic probe.

The following code should set gpio.0 to 1 (this is used as a trigger pulse for the PICkit2). The gpio.0 pulse is 1ms wide, it waits 5ms then sets gpio.1 high, waits 5ms, sets gpio.2 high, waits 5ms and then clears all pins and loops.

It does not work as expected.

The 1ms pulse on gpio.0 is OK, and gpio.1 goes high and stays there for 5ms.

BUT .... when gpio.2 is set to 1, gpio.1 is cleared to 0 at the same time, I expected it to stay high.

Swaping the sequence of gpio.1 and gpio.2 shows the same effect, seting one of the gpio.1 or gpio.2 to 1 clears the other one to 0.

Is there a problem in PICBASIC setting pins on a 12f675 individually ?

I tried the code on the 16f887 demo board that comes with the PICkit2 and it works just fine.



ANSEL = 0

loop:
output gpio.0
output gpio.1
output gpio.2
high gpio.0 'send high for trigger
pause 1 '1ms wide pulse
low gpio.0 'send it low
pause 5 'wait 5ms
high gpio.1 'send gpio.1 high
pause 5 'wait 5ms
high gpio.2 'send gpio.2 high
pause 5 'wait 5ms
low gpio.1 ' set low
low gpio.2 ' set low
pause 20 'wait 20ms with all pins low
Goto loop 'Go back to loop and do pulses forever

End

mister_e
- 15th February 2009, 10:34
how about CMCON register?

srnet01
- 19th February 2009, 15:58
You were right.

Guess I was guilty of assuming that when the manual says a pin will automatically be made an input (or output) it does not mean the pin will be a fully functional input ........