This tip is almost trivial, but it's a D'uh moment too. Just in case anyone else has missed the obvious. here's a quick tip.
I usually use Swordfish's hardware UART routines and I don't recommend Swordfish's software UART for input, where there are some "gotcha's." The software UART does work great for output.
A UART output is often handy for keeping an eye on program parameters and status. I usually use the hardware UART, and in fact have a dedicated connector for the TAP-28 board just for that purpose. In my icemaker control project I'm running out of port pins and the hardware UART pins are used for other tasks. I can use them for troubleshooting,but this requires changing a few lines in the program so it's either "test mode" or fully operational. I need to monitor the output of the pressure sensor used for level sensing because I'm having a issues with leaks in the pressure sensing tube.
The answer hit me in a moment of clarity. If I use the software UART, I can specify the port pin used to transmit data. Taking that one step further, I can use the port pin on the ICSP connector that the PICkit 2 uses for the UART tool input! This means I can program the chip with the PICkit 2 normally, then, without making any changes, I can open the PICkit 2 UART tool and monitor the program's output! I like to leave the ICSP pins open anyway, so this is awesome!
'software UART test
Device = 18F242
Clock = 20
Include"suart.bas"
UART.SetBaudrate(sbr9600)
UART.SetMode(umTrue)
uart.settx(portb.7) ' matches the PICkit 2 UART tool input pin when connected to the ICSP connector
while 1 = 1
uart.write("my name is fred", 13, 10)
uart.write("I like pizza", 13, 10)
delayms(2500)
wend
There are only two points to note here:
Works like a champ. If desired, a TTL-serial USB adapter or a serial LCD display could be connected to the ICSP connector for long-term monitoring.