Hi all, after suffering with my previous problem I was wondering if someone
has a sample code to do some interupt driven Hserin
I need to do the following:
Read a serial string at 9600bd containing a start command "#" then 5 variables of each 3 Decimal digits separated by a ";" (let's say byte in decimal presentation)
then I need to read 5 AD values on RA0-RA4
Then i need to write those variables to an LCD display 4x20)
and send them back and to some the serial port using HSEROUT
finally I need to write some variables or bits to some hardware
ports like (PortB,PortE,PortD)
Mean while I may receive an updated string on the serial port using HSERIN
If I use the following example from Mister E to play with Hserin and interupt
it works,
' Serial communication definition
' ===============================
' Using internal USART and MAX232 to interface to PC
'
RCSTA = $90 ' enable serial port,
' enable continuous receive
'
TXSTA = $24 ' enable transmit,
' BRGH=1
'
SPBRG = 103 ' set baudrate to 2400
' Alias definition
' ================
'
'
RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty)
TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full)
OERR var RCSTA.1 ' Overrun error
CREN var RCSTA.4 ' Continuous receive
' Hardware initialisation
' =======================
'
'
pause 10 ' safe start-up delay
Main:
if oerr then ' Overrun error?
cren=0 ' clear it
cren=1
endif
if RCIF then ' incomming data?
TXREG=RCREG ' take it, send it
while TXIF=0 ' wait untill transmit buffer is empty
wend
endif
goto main
But as soon as I add multiple commands like Hserout,LCDout,etc...
I miss some values on the HSERIN or get stucked on the "WAIT" command
Any help or example how to do a proper interupt driven HSERIN while
still displaying on the LCd and HSEROUT ?
Bookmarks