Here is the reply I go from Melanie on this subject:
When you first power-up, your hardware, registers, buffers can have all kinds of crap lurking. There's no real way of flushing this out, so the best thing I do is send a dummy line containg a dozen Nulls ($00) or so and terminate that with a CR LF. From then onwards, we're open for business.
Now, it all depends what is connected to what... if at the receiving end you've got an ANSI Terminal, then the next thing you'll send is a Clear-Screen, if it's an Invoicing printer, then you'd send a Page-Feed, POS Terminal you'd eject a couple of inches of paper along with a paper-cut command, etc etc...
If one PIC is connected to another, then I tend to send things in packets, and I always prefix the packet with some NULLs and a CR LF. The packet always has to have a valid header and a Checksum, otherwise it's dumped.
Generally, I've found that the first thing out of the SEROUT business in wrong/odd/missing and so design your code accordingly.
Regards Bill Legge
Bookmarks