Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm



jbitz34@xxxxxxxxx wrote:
I am trying to work out RS232 using a PIC, so I created a simple
program to send a string message which would appear in the TeraTerm
window. Here is the code snippet:

#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)

Are you using a 20MHz clock?

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif

void main() {

output_high(PIN_A0);
delay_ms(1000);
output_low(PIN_A0);
delay_ms(1000);

while(TRUE){
output_high(PIN_B4);
delay_ms(500);
output_low(PIN_B4);

Are you getting what you expect here? Is the time delay coming out
correctly?

printf("Please work\n");
delay_ms(1000);
}
}

So 12 characters from the PIC turns into 6 characters on the
display.....sounds like a baud rate issue to me. Have you tried changing
the baud in the windos program? Do you have a scope? If so, just look at
the width of the data bits to see what the PIC is sending.

====================

I have a Max232 converter in configuration according to the diagram on
page 7 of this data***:
http://www.ortodoxism.ro/datasheets/texasinstruments/max232.pdf

I am also using a device which transforms RS232 to USB and then has
drivers to emulate a COM port on the PC, since my computer has no
serial port. It is this piece:
http://www.sparkfun.com/commerce/product_info.php?products_id=198

My settings in both my device manager for COM1 (the emulated com port)
and in Tera Term are

9600 baud


8 data bits
no parity
1 stop
no flow control

When I run this program, I get the following in Tera Term:
http://bitzphoto.com/ECE445/teraterm.png
That is, a repeating sequence of incorrect characters.

I'm lost at any other settings that might need to be changed to make
the data appear correctly; any thoughts would be greatly appreciated.

Oddly, it worked correctly one time only, and it was not on the first
try; but previous and subsequent attempts have repeatedly displayed
this gibberish sequence.

Try different baud rates in teraterm to see if it suddenly starts coming in
clearly. Make sure you are really using a 20MHz clock on the PIC. Looks
like you are almost there.


.