Hi Andy,
I don't have the time to rig something up here at the moment but I took a look at your code again and here are a couple of suggestions.
For the master you don't need interrupts at all. Since it's querying the slave for data it already knows when data is supposed to come in. What you may want to do is add a timeout to the HSERIN though in case something goes wrong. The defines for the LCD, at the top of the program, needs to be UPPER CASE or they won't have any effect. So, for the master, remove the interrupt stuff then go directly from HSEROUT to HSERIN, something like this:
Code:
Main:
lcdout $fe,1
lcdout $fe,128,"Test RX-Tx"
lcdout $fe,192,"Reading"
pause 1000
lcdout $fe,1
lcdout $fe,128,#m[0],#M[1],#M[2],#M[3]
lcdout $fe,192,"Transmitting!"
High en
high led
hserout ["P",$88]
' Wait for the data to go out before pulling the EN signal to
' the tranceiver - IF that's what the EN-signal is doing.....
While TXSTA.1 = 0 : WEND
low en
low led
Hserin [wait("S0"),m[0], wait("S1"),m[1], wait("S2"),M[2], wait("S3"),m[3]]
toggle led
lcdout $fe,1
lcdout $fe,128,"Received!"
LCDOUT $fe,192,#m[0],"*",#M[1],"*",#M[2],"*",#M[3]
pause 1000
goto main
For the slave, what you can do if you want to keep the ON INTERRUPT and still have your blinking LED in the main is to replace the long PAUSE with loop consisting of many short pauses instead. That way the interrupt flag will be polled after each of those short pauses instead of after the single long one. Much less risk of flooding the buffer. Something like this perhaps:
Code:
i VAR WORD
main:
toggle led
low en 'My stuff
For i = 0 to 299
PAUSEUS 500 ' Pause for 150ms
NEXT
goto main
Disable interrupt ' Don't check for interrupts in this section
serialin:
' Read USART and store character to next empty location
Hserin [wait("P"),start]
high en
if start =$88 then
for j=0 to 3 ' Producing ODD numbers (Just for checking of continuous communication)
i=i+1
m[j]=(2*i)+1
if m[j]>100 then
i=0
m[j]=j+1
endif
next j
hserout ["S0",m[0],"S1",m[1],"S2",M[2],"S3",m[3]]
' Wait for the data to go out before pulling the EN signal to
' the tranceiver.
While TXSTA.1 = 0 : WEND
low en
endif
enable interrupt
Resume ' Return to program
goto main
Please note that I have not tested it but it is what I would do given the circumstances. As for DT-INTS what he claimed really is true, once you've used it you'll never want to use ON INTERRUPT again. Yes, it's little bit trickier to use but really not that much. I suggest you look around the forum, there are plenty of examples of how to use it.
/Henrik.
Bookmarks