PDA

View Full Version : Debug in + Floating pin = stop program execution?



jamie_s
- 9th November 2005, 07:12
I have a picbasic program that with some intermediate testing seemed to work well, however, when the serial interface cable was removed, the program would intermittantly halt, where the debigin command is:

A snip of the code is below:



DEBUGIN 10000,runmode,[WAIT("x"), TriggerChar] ' TriggerChar = X

If TriggerChar = "x" then GOTO Setup

runmode:
SerOut So, N9600, [27,"[2J"] ' Clear Terminal Screen ' Output
SerOut So, N9600, ["Entering Run Mode, Disconnect Programming Cable."] ' Output
pause 500


What happens is when the serial cable between the pic pcb and PC is removed, the program will stop around the debugin command, however the debugin pin is floating (only an 18k resistor in series with the DB9 pin socket.

Tying the pin low (via another resistor) seems to correct the issue, however scoping the pin without the resistor shows less than 5mv fluctuation on the pin - is this enough to cause the issue?

Should i tie the pin low with a 47k resistor or is my problem somewhere else?
Do i also need to tie all unused pins low, or is it simply ok to have them set as outputs?

Melanie
- 9th November 2005, 08:46
Unless the pin is held low during either no connection or periods of data idle, the software will never time out... even an odd pulse of random noise will be enough to keep resetting the timeout and your program will appear to hang at that statement. Your scopes probe (even on x10 setting) is probably enough to drag the pin low and give a false impression that you only have a few mV of input... if you really want to know the truth (can you handle it?) put a good quality VVM on the input pin and look at the horror story of what it's really doing...

As one solution (of many approaches), see also http://www.picbasic.co.uk/forum/showthread.php?p=9765#post9765