Hi tere,

I made a design that monitors a RS485 network.
Now when I try to run the program it seems to hang at the serin2 command.
I added a timeout loop that toggles a led to check if the program is still running well. So what it should do is that the blue led is blinking but where it seems to go wrong. The timeout doesn't seem to work.

Any ideas? thoughts?

Thank you

-------------------------

Here is the code.

@ device pic16F876, xt_osc, wdt_off, pwrt_on, protect_off

DEFINE OSC 12
DEFINE I2C_SLOW 1

SYNC con 254 ' Synchronisation byte
baud con 84 ' baudrate at 9600

RxD var PORTC.7 ' Rx data pin
RxTx var PORTC.5 ' Rx / Tx function
TxD var PORTC.6 ' Tx data pin
Blue var PORTA.0 ' Blue led
Red var PORTA.1 ' Red led
SCL var PORTC.3 ' I²C Clock
SDA var PORTC.4 ' I²C Data

Function var byte

init: ADCON1=$07
TRISC=%10000000
TRISB=%00000000
PORTB=%00000000 ' Clear all outputs
pause 5000 ' wait for system to stabilize
Low RxTx ' Set to receive mode
PORTB=%00000000 ' Clear all outputs
high Red
pause 250
low Red ' init complete

loop: Serin2 RxD,baud,500,loop2,[wait (SYNC),Function]
select case Function
case 1
gosub UnitOff
case 2
gosub UnitOn
end select
goto loop
loop2:
toggle blue
goto loop