PDA

View Full Version : Trouble pulling pin Low



pdegior
- 9th August 2005, 14:54
I have portb.4 going out to a camera controller. The pin is held high with a 10k resistor. In order to turn the camera on, I have to take the pin to ground for about 200ms. It seems to work a couple of times and then stops working. I've tried to monitor the pin with an O-scope, and it doesn't appear to be going low. I wrote a real simple program to test.

loop:
if portb.1 = 1 then
low portb.4
pause 200
high portb.4
goto loop
endif

I'm using a 16F628. I've tried another pic to make sure I haven't damaged the original. It seems strange though that it will work once or twice and then stop. I also removed the camera from the equation and just put my scope on the pin. Same thing...goes low once or twice and then stays high. Maybe there is an electrical issue here I'm missing.

mischl
- 9th August 2005, 15:05
take a look where the goto command is... so it jumps only to the loop marker if your condition is true!

if portb.1 = 0 then the programms doesn't execute the lines between if and endif and jumps to the next command after endif. probaply there is nothing or only an end command. which finish the programm.

take this structure :

loop:
if portb.1 = 1 then ' only when condition is true
low portb.4
pause 200
high portb.4
endif

goto loop ' infinity

end

crematory
- 9th August 2005, 20:49
Hello

You may want to try this too:

DEFINE OSC 4 ' 4 MHz Crystal

TRISB.4 = 0
PORTB.4 = 1

WHILE 1
IF PORTB.1 == 1 THEN
PULSOUT PORTB.4, 20000 ' Generates accurate 200 ms High-Low-High pulse
ENDIF

WEND ' Infinitly repeat this loop

END