I am using timer 2 for baud rate generater, mode 1. When I use the code below to calcultate the value, it gave wrong results. WORD w = 65536-OSC/(12L*Baudrate);
With OSC = 110592, and Baudrate = 19200, w = 65488 But the correct result is 65518.
Could you tell me how to resolve this?
I'm sure you already know about the baudrate calculator at: http://www.keil.com/c51/baudrate.asp
You calculation looks OK and seems to work fine with a calculator. But, you may have problems in C because of type range limits.
Have you tried reorganizing the calculation? For example:
WORD w = 65536UL - ((OSC/12)/Baudrate);
Jon