-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
I'm very new in C Language and working with Arduino.
Making a Projekt using 300 Baud i got Mismatch and therefore i had a Look on the Code.
Most Programmers on AVR Microcontrollers and i also use the alternative Formula to calculate the Register Value wich is (F_CPU/8/Baud -1) / 2 and set the U2X bit 1 or UCSRA=2
this is for 300 Baud 3332 wich is doubled by U2X =1 so you get 6664.
In HardwareSerial Routine the first Calculation is F_CPU/4.......this calculates the Registervalue direct and puts it with U2X=0 in the Register ,so the Baud is not doubled. ( for 300 Baud = 6666 )
While 6666 is greater than 4095 the Register will overflow.
To solve this Prob the second Calculation F_CPU/8 calculates the right value but with UCSRA=0 it will not be doubled and is therefore wrong. UCSRA must be 2 to double it !
Hope there is anyone here who can solve this in next package.
Is there any way to change these registers fromin the Arduino Code ?