I've already said in other posts that I'm no expert, but I'm sure I'm missing something here...
The manual states
Quote:
SERIN2 DataPin{\FlowPin},Mode,{ParityLabel,} {Timeout,Label,}[Item...]
Taking your line of code
Quote:
Serin2 RX_IN,84,1000,TIMEOUT,[WAIT("CMD"),RX]
So RX_IN is the pin, 84 is mode (which equates to 9600 baud rate ?), and then your have the optional parity and time out labels.
The manual states
Quote:
An optional Timeout and Label may be included to allow the program to continue if a character is not received within a certain amount of time. Timeout is specified in units of 1 millisecond. If the serial input pin stays idle during the Timeout time, the program will exit the SERIN2 command and jump to Label.
So I'm guessing that the code loops through your LOOP_PRINCIPLE main program, reads the serial pin, if it finds no data, jumps out to the timeout subroutine to read the temperature and send that via serial (which I'm guessing is connected somehow to a PC running a terminal applications ?), then jumps back to the main loop. However if the code detects an A,B,C,D it then sets or releases a relay connected to the pins RELE1 and RELE2.
I'm just wondering if the code is running too fast.. I use HSERIN on my projects, but I'm sure that's not relevant to this, and the code can be used with a SERIN pin / command
Code:
FOR TempWD = 0 TO 500
IF RCIF=1 THEN GOSUB coms ; Check to see if PC application connected
PAUSE 1
next TempWD
This is the routine I use to check for a character from the PC application sent to the com port.
Prior to this I have a flag variable
Code:
RCIF VAR PIR1.5 ' USART receive flag
The case select is then handled by
Code:
coms:
HSERIN [nTest]
SELECT CASE nTest
CASE "Q" ; if Q then send data to PC
Goto Term_TX
CASE "S" ; if S then receive data from PC
goto Term_RX
return
This is basically the reverse of your code, in that you can have the main loop running the read temperature and sending the results out, but each time the loop runs it checks the serial port, and only jumps to the relay section if it finds an ABC or D in the buffer and placed into the RX variable...
Like I said, I'm no expert, and your code may need to run at a higher speed than the projects I've worked on, but maybe you can pull something from the suggestions and it will stop it locking up