View Single Post
Old 10-17-2016, 12:36 PM   #13 (permalink)
t vago
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,807

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 830
Thanked 708 Times in 456 Posts
Quote:
Originally Posted by skybolt View Post
No code with string 192, no easy math that maps to 19200 given 20/16MHz change, no identifiable myubbr string. **sigh**

There is a nice line
Code:
const unsigned int myubbr = (unsigned int)(processorSpeed * 625ul / 96ul - 1);
, but altering the 96 to any other multiple I can think of hasn't worked yet. I'm busy doing other things, so I haven't divided 625/96 or 96/625 but I will say then when it was compiled for 20MHz on a 16MHz microcontroller, data read properly at 19200 (or was it 9600?). Point is, the 16/20MHz change and relationship to 625 merits a quick run through a calculator. 625 is .625 which is 5/8 I believe, but 96 to 192 is a 1/2.
I think I may have oversimplified that myubbr calcuation. Here's what it should look like:

Code:
const unsigned int myubbr = (unsigned int)((processorSpeed * 62500ul / 9600ul) - 1);
With that line re-written as above, you should be able to replace '9600ul' with any legal baud rate that the Arduino can support.

I'll take a look at your other question when I get the time. Thanks again!
  Reply With Quote