Hi Shawn,
I looked at your TX-routine and the thing that caught my eye was:
Code:
Rts = 1
For B0 = 1 To Length ' Send the response to Master
B1 = buffer[B0]
Gosub charout
Next B0
Pause 5
RTS = 0
Pause 5000
Now, you say that it all works and I can possibly see why in this particular example but in your real code do you always put the first byte of the frame at location 1 in the array? Arrays are zero-indexed so the first location of Buffer is Buffer[0] and the 6th location is Buffer[5].
The reason it works in the example you posted is because PBP doesn't have any boundry checks on arrays so when you do Buffer[6]=6 it's actually writing to the memory location AFTER the last "slot" in the array. In this case there might not BE anything of importance there but in you're real program there's a risk you're actually overwriting another variable.
Also, in this example you have the Buffer array declared as an array of words, is that what you want? It won't work properly when you try to stuff a 16 bit word into the 8bit TXReg - you'll loose the high byte which isn't a problem in this case but still....
Finally, you could replace the Pause 5 with something like
Code:
While TXSTA.1=0 : WEND
That should make it wait just long enough for the last bit to go out before turning off your transmitter.
Well, that's my thoughs...
/Henrik.
Bookmarks