PDA

View Full Version : Help needed - PIC12F635- MCU does not read Ports



financecatalyst
- 15th January 2009, 07:57
Hi
This is my code:

TRISIO=%011111
Let GPIO=0
w1 VAR word
cmcon0=%111
intcon=0
Include "modedefs.bas"


START:
serin GPIO.2,N2400,["abc"],w1
pause 10
if w1=3 then yes
if w1=4 then no
if gpio.0=1 then decide
GOTO START
YES:
gpio.5=1
GOTO START
no:
gpio.5=0
goto start

decide:
toggle gpio.5
Low gpio.0
pause 500
goto start
This code above is working fine with serial communication BUT not responding to manual control via gpio.0. I have tried this with all the available ports, making them high by giving Vdd to pins but the state to gpio.5 does not change at all.
Could someone help me please.
Thanks
Damien

mackrackit
- 15th January 2009, 08:03
Try


HIGH GPIO.5
LOW GPIO.5

financecatalyst
- 15th January 2009, 08:38
I have tried almost everything, nothing worked untill now. BUT when I remove the serial input line from this code, it works well as expected manually. Could someone please tell me how I can use both features in this command?
Thanks

mackrackit
- 15th January 2009, 08:47
I have tried almost everything, nothing worked untill now. BUT when I remove the serial input line from this code, it works well as expected manually. Could someone please tell me how I can use both features in this command?
Thanks
Add a time out to the serial command. If a signal is not received then the code will not get stuck waiting for a serial command.

financecatalyst
- 15th January 2009, 10:07
Add a time out to the serial command. If a signal is not received then the code will not get stuck waiting for a serial command.

Did that and it works - BUT- now when I power up the circuit, my gpio.5 goes high after 1-2 seconds even though I haven't send any signal.
Any solutions?
Thanks

mackrackit
- 15th January 2009, 11:48
Do you have gpio.0=1 pulled down with a 10K resistor?

financecatalyst
- 15th January 2009, 11:51
Do you have gpio.0=1 pulled down with a 10K resistor?

NO, do I have to?
I am new in this field, I may sound silly but I have not used any resistor on any pins, they are connected directly to leds. What does this resistor do?

mackrackit
- 15th January 2009, 11:56
I was not meaning the pins with LEDs.

It sounds like you have gpio.0 connected to a switch of some kind.
When the switch is pressed the pin goes HIGH.
A pull down, resistor to ground(zero rail) will keep the pin LOW, not allowing false signals until the switch is pressed forcing the pin HIGH.

financecatalyst
- 15th January 2009, 12:03
I was not meaning the pins with LEDs.

It sounds like you have gpio.0 connected to a switch of some kind.
When the switch is pressed the pin goes HIGH.
A pull down, resistor to ground(zero rail) will keep the pin LOW, not allowing false signals until the switch is pressed forcing the pin HIGH.

Thank you very much. This problem is solved.
Regards