Serial garbage using ATmega8, STK500, CodeVisionAVR

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View


Hi All,

I'm new to the ATmega8 and I'm trying to do some serial communication, but
all I get out is garbage!?  (look bottom).

I use STK500 and CodevisionAVR. Using code wisard generates this.

// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud rate: 19200
UCSRA=0x00;
UCSRB=0xD8;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x19;

And acording to the datasheet, that looks correct.
But as you can see below, what I get back I can't decode?!? There are to
many data and many are equal? I just do not get it.!
What have I forgotten, what is it I have missed?

Hope some one can help me with this problem..!

Henning


Program cut:

        for(g=0;g<255;g++)                //run trough all chars 0-255
        {
            for(t=0;t<10000;t++);        // Delay
            putchar(g);                        //send the char
        };

And this is what I recive: (using the codeVisionAVR terminal 19200,8,1,N)

00 06 00 18 00 1E 00 E0 00 E6 00 F8 00 FE 00 00
00 06 00 18 00 1E 00 E0 00 E6 00 F8 00 FE 00 00
E0 06 03 18 03 1E 03 E0 03 E6 03 F8 03 FE 03 00
E0 06 E0 18 E0 1E E0 E0 E0 E6 E0 F8 E0 FE E0 00
F8 06 0C 18 0C 1E 0C E0 0C E6 0C F8 0C FE 0C 00
06 06 06 18 06 1E 06 E0 06 E6 06 F8 06 FE 06 00
F8 06 0F 18 0F 1E 0F E0 0F E6 0F F8 0F FE 0F 00
F8 06 F8 18 F8 1E F8 E0 F8 E6 F8 F8 F8 FE F8 00
FE 06 30 18 30 1E 30 E0 30 E6 30 F8 30 FE 30 00
18 06 18 18 18 1E 18 E0 18 E6 18 F8 18 FE 18 00
E6 06 33 18 33 1E 33 E0 33 E6 33 F8 33 FE 33 00
E6 06 E6 18 E6 1E E6 E0 E6 E6 E6 F8 E6 FE E6 00
FE 06 3C 18 3C 1E 3C E0 3C E6 3C F8 3C FE 3C 00
1E 06 1E 18 1E 1E 1E E0 1E E6 1E F8 1E FE 1E 00
FE 06 3F 18 3F 1E 3F E0 3F E6 3F F8 3F FE 3F 00
FE 06 FE 18 FE 1E FE E0 FE E6 FE F8 FE FE FE 00
06 C0 18 C0 1E C0 E0 C0 E6 C0 F8 C0 FE C0 00 E0
06 E0 18 E0 1E E0 E0 E0 E6 E0 F8 E0 FE E0 00 F8
06 C3 18 C3 1E C3 E0 C3 E6 C3 F8 C3 FE C3 00 F8
06 F8 18 F8 1E F8 E0 F8 E6 F8 F8 F8 FE F8 00 FE
06 CC 18 CC 1E CC E0 CC E6 CC F8 CC FE CC 00 E6
06 E6 18 E6 1E E6 E0 E6 E6 E6 F8 E6 FE E6 00 FE
06 CF 18 CF 1E CF E0 CF E6 CF F8 CF FE CF 00 FE
06 FE 18 FE 1E FE E0 FE E6 FE F8 FE FE FE 00 06
F0 18 F0 1E F0 E0 F0 E6 F0 F8 F0 FE F0 00 F8 06
F8 18 F8 1E F8 E0 F8 E6 F8 F8 F8 FE F8 00 FE 06
F3 18 F3 1E F3 E0 F3 E6 F3 F8 F3 FE F3 00 FE 06
FE 18 FE 1E FE E0 FE E6 FE F8 FE FE FE 00 06 FC
18 FC 1E FC E0 FC E6 FC F8 FC FE FC 00 FE 06 FE
18 FE 1E FE E0 FE E6 FE F8 FE FE FE 00 06 FF 18
FF 1E FF E0 FF E6 FF F8 FF FE FF 00 06 18 1E E0
E6 F8



Re: Serial garbage using ATmega8, STK500, CodeVisionAVR


What crystal are you using? The baudrate depends on this...

SFC

Quoted text here. Click to load it



Re: Serial garbage using ATmega8, STK500, CodeVisionAVR


The crystal is a 8.000Mhz

I tried all speeds down to 600 baud with the asme result.. :(

Something else is going wrong!?

Henning

Quoted text here. Click to load it



Re: Serial garbage using ATmega8, STK500, CodeVisionAVR


Quoted text here. Click to load it

Are the fuse bits set to run from external crystal? By default I think
the chip runs on internal oscillator.

Tom

Re: Serial garbage using ATmega8, STK500, CodeVisionAVR


 
Quoted text here. Click to load it

I don't see any code here that actually writes the character to the usart
register.

Please post the WHOLE loop.



Re: Serial garbage using ATmega8, STK500, CodeVisionAVR



Quoted text here. Click to load it
[snip...snip...]
Quoted text here. Click to load it

Setting the fuse to run from an external crystal instead of the
(default) internal RC oscillator.

It *is* documented but it is also easy to miss if you don't know to look
for it. Would be handy if Atmel included a "boilerplate setup" section
that collected all the notes like this, probably somewhere around the
section where they detail the typical interrupt vector table.

--
Rich Webb   Norfolk, VA

Re: Serial garbage using ATmega8, STK500, CodeVisionAVR


I have now set up the fuses to run from the external crystal, and found out
that a jumper (oscsel) on the STK500 was set up to use the omboard clock
generator instead of the crystal.
Well it only took 4-5 days to figure out :/

Thanks alot for everybodys help :)

Henning

---- It WORKS----


Quoted text here. Click to load it



Site Timeline