tobyjaffey / bus-ninja

AVR Bus-Pirate-a-like
http://blog.hodgepig.org/busninja/
89 stars 33 forks source link

Use proper formula to calculate baud rate, use doublespeed mode if needed #7

Closed pfalcon closed 12 years ago

pfalcon commented 12 years ago

Formula as given on page 174 of atmega168 datasheet (doc2545) of course assumes real numbers and proper rounding. Using integers and truncation makes 57600 the last working speed for Arduino Duemilanove, while proper formula allows to work with 230400 (can't get higher due to Linux ft232 driver limitation).

Also, on higher baud rates, switch to double-speed mode to improve match between atmega baud rate and standard baud rate values (see page 198), otherwise 230400 doesn't really work due to high error.

Finally, allow to override baud rate from command line/*.mk file.