Balloon Monitor Pseudocode define ports define registers: Q_temp BYTE_COUNT W_TEMP STATUS_TEMP LAST_RX AA BB CC DD EE CK Main: Clear ANSEL Clear ANSELH Set debugging ports as outputs Set QueryPin as output Set RX pin as input Set up UART disable sync set up baud rate for 9600 enable serial module enable receiver (don't need transmitter) enable receive complete interrupt Set up Timer1 Set prescale for timer 1 to 8 Set up CCP1CON so in compare mode, generate a software interrupt, and toggles CCP1 pin upon match. enable CCP1 interrupt put 31250 into CCPR1 register initially turn Timer1 on, use Fosc/4 (5Mhz) Set Q_temp high EnableInterrupts LoopForever, responding to Interrupts as follows Interrupt responses Save working and status registers Check for RX interrupt (RCIF flag) go to RxInterrupt if there is Check for Timer1 OC interrupt (CCP1F) go to Tmr1Interrupt ISRcomplete: Restore status register Restore working register Return to file, enable global interrupts Tmr1Interrupt Clear CCP1IF interrupt flag If Q_temp is 1, put 31250 into CCPR1 registers (50 ms) set Q_temp to 0 goto ISRcomplete else put 2500 into CCPR1 registers (4ms) set Q_temp to 1 goto ISR complete RxInterrupt load newest receive byte, clearing the RCIF flag If there's a framing error go to RxError If there's a receiver overrun error go to RxError Save received byte in working register to LAST_RX If LAST_RX == 0x02 Set BYTE_COUNT to 1 go to ISR complete else (NotFirstByte) If BYTE_COUNT = 1 Store LAST_RX as AA Set BYTE_COUNT to 2 goto ISRcomplete else If BYTE_COUNT = 2 Store LAST_RX as BB Set BYTE_COUNT to 3 goto ISRcomplete else If BYTE_COUNT = 3 Store LAST_RX as CC Set BYTE_COUNT to 4 goto ISRcomplete else If BYTE_COUNT = 4 Store LAST_RX as DD Set BYTE_COUNT to 5 goto ISRcomplete else If BYTE_COUNT = 5 Store LAST_RX as EE Set BYTE_COUNT to 6 goto ISRcomplete else If BYTE_COUNT = 6 Store LAST_RX as CK Set BYTE_COUNT to 7 goto ISRcomplete else If BYTE_COUNT = 7 if LAST_RX not equal to 0x03 go to ByteFailed else Set BYTE_COUNT to 0 Check checksum if resulting XOR is not 0 go to ByteFailed else (correct checksum) clear LEDs if CK = 0x5f balloon is Intact light green LED go to ISRcomplete else balloon is popped light red LED go to ISRcomplete else go to ByteFailed RxError: Light yellow LED go to ISRcomplete ByteFailed: Light yellow LED go to ISRcomplete