PDA

View Full Version : Need help with timeout



Christopher4187
- 10th June 2006, 15:05
I have RTFM about serin2 and I think I need a timeout function. The program works fine but if I the communication is lost for a second, the program locks up. I think I need a timeout but it is not fully explained in the manual. When the program "locks" up (I think it's just getting stuck at the serin2 part), I have to cycle the power on the PIC or reload the program and then it's OK. I have searched this forum for related topics and I found some but I am lost. If I was communicating PIC to PIC I would be fine but I am communicating with the Parallax PINK.

------------------------code--------------------------------------------

@ DEVICE PIC16F876, HS_OSC, WDT_On, PWRT_ON, BOD_on, LVP_OFF , DEBUG_OFF, PROTECT_OFF
define OSC 20
low portc.3

PAUSE 1000
HIGH PORTB.5
PAUSE 10
LOW PORTB.5
TRISC= %00100000
ADCON1=7
X VAR BYTE
X=0

NBVAR VAR BYTE
LCD VAR PORTC.5

MAINLOOP:

SEROUT2 PORTC.7,396,["!NB0R03"]

SERIN2 PORTC.6,396,[dec NBVAR]

serout2 lcd,16468,[254,1," VARIABLE #3: ", DEC nbvar]
if nbvar=11 then
HIGH PORTB.5
ELSE
LOW PORTB.5
endif

GOTO MAINLOOP

Christopher4187
- 10th June 2006, 15:38
Nevermind. I found a post from BobK on the 30th of January and his line of code worked perfect!

SERIN2 serpin,36081,300,Main,[Wait ("A"),dec3 B7]

Thanks!