Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] STK500/Mega168 RS232 problems - Solution

2007-09-01 by Ricardo Callejo

Okay Jim, i found my problem. Suddenly i changed the baud rate to 8MHz and
the programs started to run with any baud rate i selected.

When i try to think what was happening, i remembered that atmel ships micros
programmed with the internal clock.

I checked the fuses and eureka!!!

 

 

ON page 28 doc2545.pdf

 

7.2 Clock sources

 

7.2.1 Default Clock Source

 

The device is shipped with internal RC oscillator at 8.0MHz and with the
fuse CKDIV8 programmed,

resulting in 1.0MHz system clock. The startup time is set to maximum and
time-out

period enabled. (CKSEL = "0010", SUT = "10", CKDIV8 = "0"). The default
setting ensures that

all users can make their desired clock source setting using any available
programming interface.

 

Thanks.

 

Ricardo Callejo

SURbyte SRL

San Martin 952

(9000) Comodoro Rivadavia

Chubut – Argentina

 

 

  _____  

De: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] En nombre de
Jim Wagner
Enviado el: sábado, 01 de septiembre de 2007 12:05
Para: AVR-Chat@yahoogroups.com
Asunto: Re: [AVR-Chat] STK500/Mega168 RS232 problems

 

Ricardo -

Odds are your baud rate is not correct. Either the
processor clock is not what you think it is, or you are
putting an incorrect value into the baud rate generator.

Jim

On Sat, 1 Sep 2007 10:57:25 -0300
"Ricardo Callejo" <surbyte@speedy. <mailto:surbyte%40speedy.com.ar> com.ar>
wrote:
> Hi everyone.
> 
> I follow AVRSTUDIO HELP to configure STK500 with
> ATMEGA168.
> 
> I flashed some simple programs working with LEDs,
> switches, timers to verify
> the system. 
> 
> I find troubles when i work with the UART.
> 
> I wrote a simple code that works fine with other micros
> like AT90S4433 or
> ATMEGA163, but with ATMEGA168 the program echoes strange
> chars.
> 
> 
> 
> I am using cvavr 
> 
> 
> 
> #include <mega168.h>
> 
> 
> 
> // Standard Input/Output functions
> 
> #include <stdio.h>
> 
> 
> 
> // Declare your global variables here
> 
> 
> 
> void main(void) {
> 
> // Declare your local variables here 
> 
> char k;
> 
> 
> 
> // The other setting were deleted 
> 
> /// PORTs, TIMERs, ADC, etc.
> 
> /// ....
> 
> 
> 
> // USART initialization
> 
> // Communication Parameters: 8 Data, 1 Stop, No Parity
> 
> // USART Receiver: On
> 
> // USART Transmitter: On
> 
> // USART0 Mode: Asynchronous
> 
> // USART Baud rate: 19200
> 
> UCSR0A=0x00;
> 
> UCSR0B=0x18;
> 
> UCSR0C=0x06;
> 
> UBRR0H=0x00;
> 
> UBRR0L=0x0B;
> 
> 
> 
> while (1) {
> 
> 
> 
> /* receive the character */
> 
> k = getchar();
> 
> /* and echo it back */
> 
> putchar(k);
> 
> };
> 
> }
> 
> 
> 
> What's wrong?
> 
> 
> 
> Ricardo Callejo
> 
> SURbyte SRL
> 
> San Martin 952
> 
> (9000) Comodoro Rivadavia
> 
> Chubut - Argentina
> 

----------------------------------------------------------
The Think Different Store
http://www.thinkdif <http://www.thinkdifferentstore.com/> ferentstore.com/
For All Your Mac Gear
----------------------------------------------------------

 


  _____  

E-mail clasificado por el Idenfificador de Spam Inteligente. Para modificar
la categoría clasificada acceda a su webmail 


  _____  

Este mensaje ha sido verificado por el E-mail Protegido. Antivirus
Actualizado en 31/08/2007 / Versión: 5.1.00/5110 



[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.