EFTON

Percentual error in P89V51RD2 bootloader autobauding

Disclaimer: No warranty/liability for the facts/results presented herein.


In the following text it is assumed, that the P89V51RD2 is in the 12-clock mode (as this is how it comes from the factory).

People often complain that getting into bootloader in P89V51RD2 is unreliable, especially at higher baud rates.

The bootloader attempts to set the proper baudrate by measuring a negative pulse in a "U" character (01010101 binary) and then setting Timer2 as a baudrate generator accordingly. Autobauding implies a couple of inevitable problems:
  • in RS232 transfers, there is usually an asymmetry between the positive and negative pulses. Calculating the baudrate only from negative pulses may introduce some error.
    In an experimental setup with a common PC with onboard serial port, MAX232B as a level convertor on the '51 side, and 2m of common serial cable this difference was -0.3us (17.0us vs. theoretical 17.3us for 57600bps).
  • measuring can be done only in program, using jb rx,$ and jnb rx,$ commands to detect the pulse edges. This involves an uncertainty of detecting the proper pulse length of 2x12/fOSC for each jb, jnb
  • calculating the reload value for the timer involves rounding, as the "measured" value is a multiple of 6, and the reload value needs to be divided by 16.
  • all these errors can cancel or enhance themselves
  • due to these errors the autobaud routine results in one of two reload values (hence actual baudrates) with non-equal probability
To find out which baudrate for a given fOSC is "safe", the deviation from the actual baudrate and the probability of occurence of both reload values are calculated in the following table.
Using a baudrate which has not "red" deviations should be fairly safe, unless other effects prevail (instable fOSC, jitter in RS232 pulses).


24/02/2005 - wek at efton dot sk