Error in USART Module with Baudrate Constants
Posted: Thu Dec 09, 2010 8:23 pm
From DataSheets
Baudrate = Fosc/(Fmult *(SPBRGRegister + 1))
therefore
SPBRGRegister + 1 =Fosc/(Fmult * Baudrate)
therefore
SPBRGRegister = (Fosc/(Fmult * Baudrate)) - 1
So
br300 to br115200 which goes into SPBRGRegister should be
br300 = Fosc/(Fmult * 300) - 1 + 0.5, // + 0.5 for rounding
ie no + 1 on the baudrates
Baudrate = Fosc/(Fmult *(SPBRGRegister + 1))
therefore
SPBRGRegister + 1 =Fosc/(Fmult * Baudrate)
therefore
SPBRGRegister = (Fosc/(Fmult * Baudrate)) - 1
So
br300 to br115200 which goes into SPBRGRegister should be
br300 = Fosc/(Fmult * 300) - 1 + 0.5, // + 0.5 for rounding
ie no + 1 on the baudrates