As I step through some software I've written in the debugger I've noticed my ISR doesn't run correctly if I only inject 1 byte into RCREG. It seems to "bounce" out of the ISR as soon as I read RCREG. I've experimented by injecting 2 bytes into the register and this fixes the issue. Is this caused by the clearing of RCIF after RCREG is empty? I would think the ISR would at least complete once before returning back to the main program? It isn't a big deal to send two bytes instead of one but it just seems strange the ISR would end so abruptly. Using MPLAB X and XC8
Unfortunately I don't have the actual code with me but here is an example of what I'm trying to do. NOTE TO MODS: THIS IS PSEUDO CODE BELOW
Unfortunately I don't have the actual code with me but here is an example of what I'm trying to do. NOTE TO MODS: THIS IS PSEUDO CODE BELOW
Code:
Rx interrupt
buffer = RCREG; // Program abruptly leaves ISR if there is only one byte in the buffer
parse byte using bitwise operators and if statements
use result of ifs to set certain variables true or false
while(RCREG); // empty buffer and clear RCIF
Last edited: