Chris,
You already have a buffer, it doesn't need to be a "ring".
But it does need to work properly.
In your original routine...
Code:
'******************* interrupt routine *********************
disable
myroutine:
if PIR1.5=1 then
PELCO[BYTECOUNT]=RCREG
IF RCREG=$AF THEN
GOSUB SENDATA
PIR1.5=0
ELSE
BYTECOUNT=BYTECOUNT+1
GOTO MYROUTINE
ENDIF
ENDIF
resume
enable
When testing the value of RCREG, it also removes a byte from the USARTs buffer (if one's available).
And, there's currently no way to reset BYTECOUNT, it just keeps counting, which then overwrites memory areas that you don't want it to.
Try this...
Code:
'******************* interrupt routine *********************
disable
myroutine:
if PIR1.5=1 then
temp = RCREG
if temp = $A0 then BYTECOUNT = 0
if BYTECOUNT < 8 then
PELCO[BYTECOUNT]=temp
BYTECOUNT=BYTECOUNT+1
IF (BYTECOUNT = 8) and (temp=$AF) THEN GOSUB SENDATA
GOTO MYROUTINE
ENDIF
ENDIF
resume
enable
HTH,
Bookmarks