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



In article <1176315686.202300.315050@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
jbitz34@xxxxxxxxx says...
On Apr 11, 9:47 am, James Beck <j...@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
In article <1176248189.680111.239...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,


If I were trying to get this example working I would do the following :

1) Verify that your USB-> RS232 adapter was working as expected.
Try shorting pins 2 and 3 together, type, and see if you at least
see the chars getting echoed.
Make sure you have local echo turned off on your comm program.

In this setup the characters echo correctly.
Scratch that off the list.


2) Verify that your level shifter (MAX232) is working OK.
Same thing. Remove the PIC so it isn't trying to drive
the port lines and short your in to your out, on the logic
side of the level shifter. You should get the chars echoed
again.

They do indeed echo correctly here.
That too....


3) Make sure your oscillator is REALLY running at 20MHz.

hooking up the oscillator to a scope, I get that the period is 5
divisions with each division 10ns, which works out to 20MHz.
One more.....


4) Check to see what the error % is when setting up your
baud rate at 20MHz. We had a situation where an oscillator
was out of whack to the high end of its tolerance and our
ATEN USB to Serial adapter was out of whack to the low end
and between the 2 if was enough to trash the communications.

You should just have to do something like this :

Start a new project using the CCS project wizard.
Just setup the serial defines by specifying the clock frequency and your
desired baud rate. Make sure all other hardware is just set to OFF for
now.
When the program shell is made just add something like the following
after the hardware setup info :

printf("Hello World\n\r");
sleep();

nothing more.
Then, let's see what happens.

Here is the resulting output:

www.bitzphoto.com/ECE445/nothello.png

In a similar vein, I adjusted the original code in the following way:
char test = '0';
while(TRUE){
output_high(PIN_B4);
delay_ms(500);
output_low(PIN_B4);
printf("%c", test);
test++;
delay_ms(1000);
}

Hoping to create the ASCII list 0,1,2,3.....x,y,z. Instead I get
this:

www.bitzphoto.com/ECE445/decrements.png
(ignore the question marks, they are not part of the sequence).

So it is kind of like a decrementing sequence, except it alternates
between the numbers grouping and the letters. I will look at this for
possible patterns; one I see right away is that the one group has a
first significant ASCII bit as 0 and the other as a 1, but the
alternating isn't everytime.

I take it you have swapped the PIC out to make sure you don't have one
with a wonky UART.

Maybe the divisor is being set up wrong.
Can you change out oscillators?
You might try a different clock rate and see if that makes any
difference. I don't have any boards here that we run at 20MHz to test
the divisor settings with. That would be all I can think of off the top
of my head.

Jim

.



Relevant Pages

  • Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
    ... Verify that your USB-> RS232 adapter was working as expected. ... In this setup the characters echo correctly. ... Make sure your oscillator is REALLY running at 20MHz. ...
    (sci.electronics.design)
  • Re: Why should I (not) use an internal oscillator for 8-bit micros
    ... >> the the bit time on a uart based on that oscillator is 2% out. ... If the internal sampling clock is say 4x the baud rate, ... "The most amazing achievement of the computer software industry ...
    (comp.arch.embedded)
  • Re: Set 33600 Baud on serial port
    ... configured to this baud rate) but the define B33600 doesn't exist. ... to open your serial device and check the oscillator on it. ... maybe you can ask them to do a customization. ... company that made multi-port serial cards. ...
    (comp.os.linux.misc)
  • Re: Set 33600 Baud on serial port
    ... configured to this baud rate) but the define B33600 doesn't exist. ... My experience is for this not very popular baudrate, ... then you can change the oscillator by yourself. ...
    (comp.os.linux.misc)
  • Re: PIC code self-start execution
    ... that there could be a problem with my DC adapter. ... power on timer for the execution start delay ... I think you just turned off your oscillator. ...
    (sci.electronics.design)