Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
- From: James Beck <jim@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 Apr 2007 14:51:46 -0400
In article <1176315686.202300.315050@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
jbitz34@xxxxxxxxx says...
On Apr 11, 9:47 am, James Beck <j...@xxxxxxxxxxxxxxxxxxxxxxx> wrote:Scratch that off the list.
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.
That too....
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.
One more.....
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.
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
.
- References:
- Trying to send RS232 with PIC sends incorrect data in TeraTerm
- From: jbitz34
- Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
- From: cbarn24050
- Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
- From: James Beck
- Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
- From: jbitz34
- Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
- From: James Beck
- Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
- From: jbitz34
- Trying to send RS232 with PIC sends incorrect data in TeraTerm
- Prev by Date: Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
- Next by Date: Re: Advice on used oscilloscope
- Previous by thread: Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
- Next by thread: Re: Trying to send RS232 with PIC sends incorrect data in TeraTerm
- Index(es):
Relevant Pages
|