On Sat, 4 Oct 2003, Ken Pergola wrote: > No one should be calculating SPBRG values by hand with a calculator > over and over again. No one should be calculating them with calculators or spreadsheets or JavaScript web pages or slide rules or looking them up in datasheets; your compiler's preprocessor lets you implement the SPBRG calculations in your code with no cost in code space, e.g., #define SPBRG_INIT(baud) (unsigned char)(Fosc / (16. * baud) - 1 + 0.5) SPBRG = SPBRG_INIT(9600); Of course, more elaborate schemes are possible that validate the above macro generates a useful value and detect the appropriate value of BRGH. If I see code with SPBRG = 25; /* 9600 baud */ the comment is worthless; I still have to verify the math. And then I have to reach for my calculator/spreadsheet/whatever if I want to change the baud rate or the system clock. -- John W. Temples, III -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads