First, there's the actual shiftregister into which the data is shifted bit-by-bit as it's received. You don't have access to this register (AFAIK).Since you refer to it, why is there a buffer of "2" characters? What's its use?
Once the correct number of bits have been shifted in they are copied to RCREG (where you can read it) and the interrupt flag is set. Now the user code needs to grab the byte from RCREG before a new byte is fully shifted in. So there's your two byte buffer.
Using ON INTERRUPT is tricky since all it does is poll the interrupt flag BETWEEN PBP statements. What that means is that if you have a PBP statement that takes considerable time the execution of the interrupt handler will be postponed for (up to) that amount of time. In your case, I don't see any issue but lets say that, instead of HSEROUT[SData] in the main loop, you had done HSEROUT["The received byte is: ", SData] then the execution time of that complete statement is longer than the time between two received characters and it would not work properly.Looks like a silly question, but, can I trust this code? Will it work @ 100%? Could something make it hang or stop?
/Henrik.
Bookmarks