Serial garbage using ATmega8, STK500, CodeVisionAVR

Feb 13, 2006 6 Replies

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


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

SFC

"Henning M" schreef in bericht news:aba91$43f0d6c4$3e3d8433$ snipped-for-privacy@news.arrownet.dk...

The crystal is a 8.000Mhz

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

Something else is going wrong!?

Henning

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

Please post the WHOLE loop.

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

Tom

[snip...snip...]

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

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----

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required