Update,
I'm stumped as to why this is happening when the 27th byte is sent. To check if it was the sending of data that was the problem, I simply made the code jump to the TX part of the program and send the data, then pause a little while before returning to the main program loop. When I ran this the PIC ran fine, sending data over and over again.
So this would suggest that the trigger is something to do with the receiving side. But what ?
The code simply jumps to either the sub-routine that receives data and updates variables or the subroutine that sends data, depending if Q or S is received. What is significant about the 27th byte !
FIXED !!!!!
I have no idea if this is just murphy's law or it was something to do with the mix of gosubs / goto's but I've re-coded as follows and it seems to work (well it's sent over 35 bytes to the PIC and it hasn't yet restarted)
Code:
;----[check for data on com port]
FOR TempWD = 0 TO 10000
IF RCIF THEN GOTO coms
PauseUs 100
NEXT TempWD
;--------------------------------
I then have the checking for Q or S
Code:
coms:
HSERIN [nTest]
SELECT CASE nTest
CASE "Q" ; if Q then send data to PC
Goto Term_TX
CASE "S"
goto Term_RX
return
Then the TX and RX simply jump back to the start of the main loop after sending or receiving data
Why placing the test for Q or S inside the RX bit caused the problem, when segregating it as a separate sub routine I have no idea... and I seem to recall I tried this the other week.... but guess I got lucky this time round
Bookmarks