I am relatively new in Atmega MCU's (too used with graphical interfaces). I am using an external clock with 8MHz in my Atmega2560. My problem is that I cannot use UART communication with PIC18->Atmega2560 and STM32F4->Atmega2560 (no acknowledgements).
I thought that it is my baud rate that is not right, maybe the Atmgea2560 is using prescaler div by 8 in default (not familiar with Atmega). So, I forcely changed the prescaler to div by 1 using this little code:
Code:
void setup() {
noInterrupts();
CLKPR = 0x80; /*Enabling the clock prescaler function*/
CLKPR = 0x00; /*Setting the prescaler to div by 1*/
interrupts();
}
I also use this one in the bootloading/programming:
Now, when setting the Atmega2560 Serial, Serial1, Serial2, and Serial3 to 9600 baud rate and PIC18/STM32F4 to 9600 baud rate, can my problem in UART be vanished (ack's will receive)? -theoretically
I cannot verify it now since it is weekend, things are in the office.
To those who are expert in this things, your help is much appreciated.
The ATMega comes with a datasheet. It is for free.
Read it. There isva UART chapter.
There are tabke with UART baudrates vs clock frequencies.
In addition there is a formula.