RFID Pic Pseudocode /**** Main ***/ Initialize: Set all ports to digital Set A0-A2 as outputs Clear all PORTA InitEusart: Initialize EUSART for asynchronous, 8 bit transmit/receive Set the baud rate to 9600 InitSPI: Initialize SPI for slave InitInterrupts: Enable asynchronous receive interrupt Enable synchronous serial interrupt Enable peripheral interrupts Enable global interrupts InitVariables: Clear the ByteCounter (which byte we are receving/sending) Loop: Loop forever /**** Interrupts ***/ IntResponse: Save W and STATUS registers Check if we had a EUSART or SPI interrupt Call appropriate interrupt response Interrupt Subroutines SPIResponse: Clear SSPIF If last SPI byte, call LastSPI Else, call NormalSPI NormalSPI: Load in our current byte from RFID table Put it into SSPBUF to send the next time through Increment the ByteCounter If we loaded in the last byte, set Last_SPI flag Goto IntDone Last SPI: Done sending message, so reset ByteCounter Clear Last_SPI flag Lower the RFID_Ready I/O line Goto IntDone EusartResponse: Load byte from RCREG and store in RFID table Increment ByteCounter If we received the last byte, call Last_EUSART Goto IntDone Last_EUSART: Done receiving message, so reset ByteCounter Clear SSPIF Preload SSPPBUF so we can auto-send data when we get an SPI interrupt Increment ByteCounter Raise the RFID_Ready I/O line Return IntDone: Restore the status and W registers Return and re-enable interrupts