Hello, I have got AVR ATmega16. I attached 11059000 Hz oscilator to XTAL1 and XTAL2 (+capacitors). I can send data to the processor (UART) but got wrong characters. Probably, I haven`t set frequency parameters correctly. Do I have to set some extra things in the code to use external oscilator for UART? What to do to make AVR's UART working with 11,059MHz oscilator? Piece of the code: UART.h: ---------- #ifndef _UART_H_ #define _UART_H_ enum { RECVBUF_MAX = 16, FCPU = 11059000, VUART = 57600, VUBRR = FCPU / (VUART * 16) - 1 }; void initUART(void); #endif UART.c: ---------- #include <avr/io.h> #include <avr/interrupt.h> #include <avr/signal.h> #include <string.h> #include "uart.h" void initUART(void) { UBRRH = (unsigned char)(VUBRR >> 8); UBRRL = (unsigned char)VUBRR; UCSRB = (1 << RXCIE) | (1 << TXCIE) | (1 << RXEN); /* 8, 1 stop */ UCSRC = (1 << UCSZ1) || (1 << UCSZ0); sei(); } char recvBuf[RECVBUF_USER_MAX] = "\0"; volatile char *recvBufPtr = recvBuf; volatile int flagaaa = 0; SIGNAL (SIG_UART_RECV) { if (recvBufPtr - recvBuf < RECVBUF_MAX) *recvBufPtr++ = UDR; }

AVR, UART
Started by ●May 12, 2004
Reply by ●May 12, 20042004-05-12
"Umpa" <����@umpaumpalala.com> wrote in news:c7tot0$nf7$1 @atlantis.news.tpi.pl:> Hello, > > I have got AVR ATmega16. > I attached 11059000 Hz oscilator > to XTAL1 and XTAL2 (+capacitors). > > I can send data to the processor (UART) but > got wrong characters. > Probably, I haven`t set frequency > parameters correctly. > > Do I have to set some extra things > in the code to use external oscilator > for UART? > > What to do to make AVR's UART > working with 11,059MHz oscilator?Have you set the fuses to use an external XTAL ? if you have not you will still be using the internal 1MHz RC-oscilator (as that's how Mega16's come out of the factory :) ). Note when setting the fuses be carefull to set them for external XTAL and *NOT* external oscilator. Hope that helps. Phill.
Reply by ●May 13, 20042004-05-13
> Have you set the fuses to use an external XTAL ? if you have not you will > still be using the internal 1MHz RC-oscilator (as that's how Mega16's > come out of the factory :) ). >In the aplication I use to program my processors there are a few fuses for XTAL: XTAL<0.4MHz, XTAL 0.4-0.9 MHz, XTAL 0.9-3 MHz, XTAL 3-8 MHz. I have got about 11 MHz oscilator which is faster than the fasters fuse XTAL 3-8 MHz. I don`t know what to set. Umpa.
Reply by ●May 13, 20042004-05-13
"Umpa" <����@umpaumpalala.com> wrote in message news:c7vap2$n7e$1@atlantis.news.tpi.pl...> > Have you set the fuses to use an external XTAL ? if you have not youwill> > still be using the internal 1MHz RC-oscilator (as that's how Mega16's > > come out of the factory :) ). > > > In the aplication I use to program my processors there are a few > fuses for XTAL: XTAL<0.4MHz, XTAL 0.4-0.9 MHz, > XTAL 0.9-3 MHz, XTAL 3-8 MHz. > I have got about 11 MHz oscilator which is faster than the fasters > fuse XTAL 3-8 MHz. I don`t know what to set.Do yourself a favour and download the most recent version of AVRStudio at www.atmel.com Meindert
