constants [[rcreg $fae] [rcsta $fab] [spbrg $faf] [pir1 $f9e] [txsta $fac] [txreg $fad] [t2con $fca]] global [position destonation place rec-cmd] to powerup write spbrg 25 ; sets baud rate to 19200, assuming 4MHZ write rcsta $90 ; enable data RX portc 7 write txsta $24 ; was$04 write t2con $06 setbit 6 portc-ddr ;make the TX pin an input for now main end to startup uart-send $55 main end ;in your main program make a loop that regularly looks at bit 5 of pir1 ;if it is high then read the received data byte from rcreg like this: to main loop[ wait 2 if testbit 5 pir1 [ flash ;clearbit 0 portc wait 10 setbit 0 portc print read rcreg clearbit 5 pir1 ] if testbit 2 rcsta [ clearbit 4 rcsta mwait 10 setbit 4 rcsta flash ] ] end ;when you want to transmit to your master call this function ;with the data byte you want to send like this: (uart-send 55) to uart-send :n write txsta $24 ; enable the TX portc 6 write txreg :n ; send the data byte out waituntil [testbit 1 txsta] ; wait til its finished write txsta $04 ; disable the TX setbit 6 portc-ddr ; make the TX pin an input end