This is the code I use for my serial comms
Code:
RCIF VAR PIR1.5 ' USART receive flag
Char VAR BYTE ' USART byte received
GIE VAR INTCON.7
nTest var byte
and then in the main loop of the code
Code:
FOR TempWD = 0 TO 500
IF RCIF=1 THEN GOSUB coms ; Check to see if PC application connected
PAUSE 1
next TempWD
And then the Comms subroutine
Code:
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
The Term_RX / Term_TX subroutines are then used with HSERIN or HSEROUT to receive and send data. As can be seen from the code I use Q and S as the keys to communicate with a PC application which receives variable data and populates text boxes, or if the value are changes in those text boxes and the update button clicked, the PS sends the new values for the variables..
Hope that helps
Bookmarks