Hello,
I received the Easyavr3 board this week, and its great!.
Iam abit new in this sorry.
Now I was playing with the uart but I cant get it working above 19200.
from 38400 to 115200 it doesnt work. Iam sending about 15 bytes it is receiving correct except on the mentioned speeds it doesnt receive anything in the uart terminal. Now i thought it has something to do with the Oscillator so i tried all faster speeds and the external oscillator. but still not working on bautrates above 19200. how can i solve this, I need to use the higher boatrates.
Thanks in advance
Regards Joris
PS: I tried it with the Atmega16 and Atmega8535
UART problem
For higher speed you use:
instead of USart1_Init(57600); for 8MHz clock
This software problem will be correct in next release.
Code: Select all
UBRRL := 8;
UBRRH := 0;
UCSRB := $18;
UCSRC := $86;
This software problem will be correct in next release.
I checked the atmega datasheet, and I found a formula for it:
UBRR = Fosf / 16*baud -1, so I wrote it like this
Fosf = System Oscillator clock frequency ( 8 mhz )
but its not completely ok, I suppose I could manualy add some delay etc
.
However I think iam doing something wrong could you explain the OK formula or just post the correct settings for the mentioned speed in my last post.... sorry for abit double posting.
Regards Joris
UBRR = Fosf / 16*baud -1, so I wrote it like this
Fosf = System Oscillator clock frequency ( 8 mhz )
Code: Select all
testing := 8000000/921600; // testing is a real number
testing := testing -1;
UBRRL := testing;
UBRRH := 0;
UCSRB := $18; // To enable Tx and Rx ?
UCSRC := $86; // To set data frame 8 bits, one stop bit, no parity ?
.
However I think iam doing something wrong could you explain the OK formula or just post the correct settings for the mentioned speed in my last post.... sorry for abit double posting.
Regards Joris
First of all sorry for my Laziness:)
I search abit more in the datasheet, and found UBRR tables. However it still doesnt work good at 57600.
Will try all values giving in it. but I got a 7.3728 xtal it supposed to have 0% error but not sending ok, I think I could have some settings wrong ?
Iam sorry but I never coded anything for a mcu befor.
Regards joris
PS: how to use xtall above 12mhz
I search abit more in the datasheet, and found UBRR tables. However it still doesnt work good at 57600.
Will try all values giving in it. but I got a 7.3728 xtal it supposed to have 0% error but not sending ok, I think I could have some settings wrong ?
Iam sorry but I never coded anything for a mcu befor.
Regards joris
PS: how to use xtall above 12mhz
Original code for init :
For some reason it does not work for hi frequency.
Best way is to read datasheet for chip ATmega16.
Code: Select all
procedure Usart1_Init(baud_rate : longint);
var tmp: longint;
begin
tmp := Clock_kHz_ * 1000;
tmp := tmp div baud_rate;
tmp := tmp shr 4;
dec(tmp);
UBRRL := tmp;
UBRRH := longint(tmp shr 8);
UCSRB := $18;
UCSRC := $86;
end;
Best way is to read datasheet for chip ATmega16.