17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Why is the RS-232 not working right?<br />

1. The PIC® is Sending Garbage Characters.<br />

A. Check the clock on the target for accuracy. Crystals are usually not a problem but RC<br />

oscillators can cause trouble with RS-232. Make sure the #USE DELAY matches the<br />

actual clock frequency.<br />

B. Make sure the PC (or other host) has the correct baud and parity setting.<br />

C. Check the level conversion. When using a driver/receiver chip, such as the MAX 232,<br />

do not use INVERT when making direct connections with resistors and/or diodes. You<br />

probably need the INVERT option in the #USE RS232.<br />

D. Remember that PUTC(6) will send an ASCII 6 to the PC and this may not be a visible<br />

character. PUTC('A') will output a visible character A.<br />

2. The PIC® is Receiving Garbage Characters.<br />

A. Check all of the above.<br />

3. Nothing is Being Sent.<br />

A. Make sure that the tri-state registers are correct. The mode (standard, fast, fixed) used<br />

will be whatever the mode is when the #USE RS232 is encountered. Staying with the<br />

default STANDARD mode is safest.<br />

B. Use the following main() for testing:<br />

main() {<br />

while(TRUE)<br />

putc('U');<br />

}<br />

Check the XMIT pin for activity with a logic probe, scope or whatever you can. If you can<br />

look at it with a scope, check the bit time (it should be 1/BAUD). Check again after the<br />

level converter.<br />

4. Nothing is being received.<br />

First be sure the PIC® can send data. Use the following main() for testing:<br />

main() {<br />

printf("start");<br />

while(TRUE)<br />

putc( getc()+1 );<br />

}<br />

When connected to a PC typing A should show B echoed back.<br />

368

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!