<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>8-bit MicrocontrollersのトピックRe: Baud rate on QE128</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184203#M13666</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;That clears up a lot - thank you, Jim!&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Jan 2008 03:25:36 GMT</pubDate>
    <dc:creator>akak</dc:creator>
    <dc:date>2008-01-31T03:25:36Z</dc:date>
    <item>
      <title>Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184198#M13661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using a QE128 device and I would like to set the baud rate, using a bean, to 57600 or 115200. However, I noticed it will only let me set these baud rates when I have a certain clock rate set. Could I bypass this by changing the SBR12&lt;/SPAN&gt;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif"&gt;&lt;IMG alt=":smileyfrustrated:" class="emoticon emoticon-smileyfrustrated" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif" title="Smiley Frustrated" /&gt;&lt;/A&gt;&lt;SPAN&gt;BR0 registers?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Assuming I used a fixed clock rate, if I want to change the baud rate during operation, do I change the SBR12&lt;/SPAN&gt;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif"&gt;&lt;IMG alt=":smileyfrustrated:" class="emoticon emoticon-smileyfrustrated" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif" title="Smiley Frustrated" /&gt;&lt;/A&gt;&lt;SPAN&gt;BR0 registers, or is there some other way this is commonly done?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jan 2008 11:45:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184198#M13661</guid>
      <dc:creator>akak</dc:creator>
      <dc:date>2008-01-30T11:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184199#M13662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Sure you can. Just load the registers yourself.&lt;BR /&gt;However, the baud rate will still be inaccurate to some amount, and may or may not work reliably.&lt;BR /&gt;Thats because certain clock rates just don't divide down to the correct&amp;nbsp; frequency for a given baud rate.&lt;BR /&gt;Time was we would use a certain oscillator with an odd value just for that reason.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jan 2008 20:23:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184199#M13662</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-01-30T20:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184200#M13663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;If you want to change the baudrate to the SCI, you can either change the SBR12&lt;IMG alt=":smileyfrustrated:" class="emoticon emoticon-smileyfrustrated" id="smileyfrustrated" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif" title="Smiley Frustrated" /&gt;BR0 bits in the SCIxBD register, or you can change the fBUS or you can change both the register and the bus frequency.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Well the two later suggestions were not something I would do, which makes the first suggestion what I would recommend.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;But I have not tried to set the baud rate under PE.&lt;/DIV&gt;&lt;DIV&gt;Perhaps someone else has tried it?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Ake&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jan 2008 20:30:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184200#M13663</guid>
      <dc:creator>Ake</dc:creator>
      <dc:date>2008-01-30T20:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184201#M13664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks for the replies!&lt;BR /&gt;&lt;BR /&gt;How exactly does changing the SBR12&lt;IMG alt=":smileyfrustrated:" class="emoticon emoticon-smileyfrustrated" id="smileyfrustrated" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif" title="Smiley Frustrated" /&gt;BR0 registers work?&lt;BR /&gt;&lt;BR /&gt;I'm looking at this manual: &lt;A href="http://www.freescale.com/files/microcontrollers/doc/ref_manual/MC9S08QE128RM.pdf?fpsp=1" target="test_blank"&gt;http://www.freescale.com/files/microcontrollers/doc/ref_manual/MC9S08QE128RM.pdf?fpsp=1&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;On page 261 they mention baud rate generation: BusClk/ (SBR12&lt;IMG alt=":smileyfrustrated:" class="emoticon emoticon-smileyfrustrated" id="smileyfrustrated" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif" title="Smiley Frustrated" /&gt;BR0) * 16. So if my bus is currently at 7372800, and I want baud rate of 57600, then I just need SBR12&lt;IMG alt=":smileyfrustrated:" class="emoticon emoticon-smileyfrustrated" id="smileyfrustrated" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif" title="Smiley Frustrated" /&gt;BR0 to equal 8, because 7372800/(8 * 16) = 57600. Right?&lt;BR /&gt;&lt;BR /&gt;What I get confused about is on page 253. It says that SCIxBDH and SCIxBDL control the prescale divisor for baud rate generation, and to first write to SCIxBDH to buffer the high half and then write to SCIxBDL. What do they mean by buffering the high half? Sorry, I'm kind of new to all of this.&lt;BR /&gt;&lt;BR /&gt;Thanks for your help!&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 02:13:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184201#M13664</guid>
      <dc:creator>akak</dc:creator>
      <dc:date>2008-01-31T02:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184202#M13665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;unsigned long baudrate;SCIxBDH = baudrate &amp;gt;&amp;gt; 8;SCIxBDL = baudrate &amp;amp; 0xff;
OR to load 8
SCIxBDH = 0;
SCIxBDL = 8;
&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:35:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184202#M13665</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2020-10-29T09:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184203#M13666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;That clears up a lot - thank you, Jim!&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 03:25:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184203#M13666</guid>
      <dc:creator>akak</dc:creator>
      <dc:date>2008-01-31T03:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184204#M13667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;akak wrote:&lt;BR /&gt;What I get confused about is on page 253. It says that SCIxBDH and SCIxBDL control the prescale divisor for baud rate generation, and to first write to SCIxBDH to buffer the high half and then write to SCIxBDL. What do they mean by buffering the high half? Sorry, I'm kind of new to all of this.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;The reason for this is described right below the portion you read on page 253.&amp;nbsp; The values in SCIxBDH&lt;IMG alt=":smileyfrustrated:" class="emoticon emoticon-smileyfrustrated" id="smileyfrustrated" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-frustrated.gif" title="Smiley Frustrated" /&gt;CIxBDL are not used until you write to SCIxBDL.&amp;nbsp; If you write to SCIxBDL then to SCIxBDH,&amp;nbsp;the value put into SCIxBDH won't be used to update the modulo divide rate for the SCI baud rate generator.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Also, in Jim's example he used an unsigned long but it should be an unsigned int.&amp;nbsp; You might also want to mask the upper&amp;nbsp;nibble of baudrate&amp;nbsp;and&amp;nbsp;bitwise OR it&amp;nbsp;with&amp;nbsp;a masked SCIxBDH&amp;nbsp; to preserve the status of LBKDIE and RXEDGIE.&amp;nbsp;&amp;nbsp;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;unsigned int baudrate;baudrate = 8;  SCIxBDH = (SCIxBDH &amp;amp; 0xE0) | ((baudrate &amp;gt;&amp;gt; 8) &amp;amp; 0x1F); // Preserve the bits not associate with the baud rateSCIxBDL = baudrate &amp;amp; 0xff;&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;If you ever think&amp;nbsp;you might want to enable either of these interrupts you would want to use the above code.&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by allawtterb on &lt;SPAN class="date_text"&gt;2008-01-30&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;08:04 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:35:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184204#M13667</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2020-10-29T09:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184205#M13668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;He is right about the hi bits - on HCS12 and 08QG the are unused.&lt;BR /&gt;Its long because I calculate bauds rate on the fly.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 04:43:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184205#M13668</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-01-31T04:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184206#M13669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I'm curious, do you ever have a case where the baud rate modulo&amp;nbsp;uses more than 16-bits?&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The variable name baudrate in this case is actually misleading as it is the baudrate modulo and not the actual baud rate(which could certainly&amp;nbsp;need more than 16-bits)&amp;nbsp;the value is holding.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 04:59:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184206#M13669</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-01-31T04:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184207#M13670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;Ok, wise guy :smileyhappy:.&lt;BR /&gt;&lt;BR /&gt;#define CLK&amp;nbsp; (12000000L)&lt;BR /&gt;void SetBaud( unsigned long baudrate)&amp;nbsp; // up to 115200, so 16 bit not enough.&lt;BR /&gt;{&amp;nbsp; // For chips with nothing in the upper byte!&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; baudrate =&amp;nbsp; ((CLK)/baudrate)/32L;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; h = baudrate &amp;gt;&amp;gt; 8;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l = baudrate &amp;amp; 0xff;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;It might seem weird how I did that, but the term (CLK)/baudrate is the one likely to be truncated due to integer math, so by adding extra places it keeps it more correct, and /32 is just shifting. Perhaps you could live with out it, but I didn't feel like checking all the values.&lt;BR /&gt;&lt;BR /&gt;I suppose I could have created an intermediate value, but why?&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;SPAN class="time_text"&gt;BTW: If you go into the PE dialog on the SCI set up bean, and click the "..." button next to the baud rate box, and get on the timing - Baud Rate Dialog you can set the Error Allowed, and he will the generate the baud rate. If you enter in all the baud rates you want in the dialog, he will make a table of them. Also, the % error will be displayed. Also, if you go change the clock he will regenerate the table to match.&lt;BR /&gt;&lt;BR /&gt;In my case I can't change the clock, and it seems that 115200 with an 8.5% error talks to the pc fine.&lt;BR /&gt;I'm starting to like PE.&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="time_text"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by JimDon on &lt;SPAN class="date_text"&gt;2008-01-30&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;05:24 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 06:04:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184207#M13670</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-01-31T06:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184208#M13671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Not trying to nitpick or be a wise-guy at all, the only reason&amp;nbsp;I asked was&amp;nbsp;to point out why I suggested an&amp;nbsp;unsinged int instead of an unsigned long.&amp;nbsp; The function that you posted above is exactly what I would suggest for the original poster because he mentioned wanting to change baud rates during code operation.&amp;nbsp; The only benefit I could see for having an intermediate value of an unsigned int would be you wouldn't have to perform a shift on a 32-bit value, which might save some time.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If you use standard baud rates then a few extra #defines and let the pre-processor do the work would save quite a bit of time on an 8-bitter.&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by allawtterb on &lt;SPAN class="date_text"&gt;2008-01-30&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:05 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 07:05:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184208#M13671</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-01-31T07:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184209#M13672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thanks for your help. I'm kind of unsure how to actually write to the register, though. From what I understand usually you have an include file like mcxxxqe128.h that defines all the registers for you, but I'm using Processor Expert and it seems it already defined things (so I can't use that .h file). Is there supposed to be some special way to write to registers using PE? Thanks for bearing with me.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 08:14:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184209#M13672</guid>
      <dc:creator>akak</dc:creator>
      <dc:date>2008-01-31T08:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184210#M13673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Whoops, nevermind, found it in the PE help. You have to use the getReg and setReg functions, I think.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 08:25:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184210#M13673</guid>
      <dc:creator>akak</dc:creator>
      <dc:date>2008-01-31T08:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184211#M13674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&amp;nbsp;allawtterb,&lt;BR /&gt;I was just kidding you. Sorry.&lt;BR /&gt;Anyway, on a routine like this who cared (with in reason)? You only call it once.&lt;BR /&gt;People spend way too much time fretting about how long it takes.&lt;BR /&gt;You have to consider the way in which a piece of code is being used before you spend time fretting about how long it takes.&lt;BR /&gt;&lt;BR /&gt;To be sure there is a time to care, and in fact how often a routine is called is a strong indicator of how much time you need to spend on speed.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 11:14:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184211#M13674</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-01-31T11:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184212#M13675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I seem to recall a previous thread on one of these forums (although I could not find it), that addressed the issue&amp;nbsp;of 16-bit registers, where high byte must be written first.&amp;nbsp; It was confirmed that these registers may be properly handled by&amp;nbsp;writing a 16-bit value directly to the register, rather than two separate 8-bit values.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;For example, in assembler the following&amp;nbsp;behaves as required -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; LDHX&amp;nbsp; #8&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; STHX&amp;nbsp; SCI1BD&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The CW compiler should also give the correct result for the&amp;nbsp;following code -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;SCI1BD = 8;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I don't consider a run-time calculation for the baud rate divider value to be a good method.&amp;nbsp; I would not be concerned about the number of cycle, but the number of bytes of flash wasted by the calculations.&amp;nbsp; Even if multiple rates are required, for the majority of instances they will conform with standard rates, and are best handled as a look-up table of divisor values IMHO.&amp;nbsp; Perhaps something like the following code would work&amp;nbsp;-&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; BUSCLK&amp;nbsp; 12000000L&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; SCICLK&amp;nbsp; BUSCLK/16&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; DIV1152 SCICLK/115200&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; DIV576 &amp;nbsp;SCICLK/57600&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; DIV384 &amp;nbsp;SCICLK/38400&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; DIV192 &amp;nbsp;SCICLK/19200&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; B1152&amp;nbsp;&amp;nbsp; 0&amp;nbsp; /* baudndx values */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; B576&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; B384&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; B192&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;const word baudtab[4] = {DIV1152, DIV576, DIV384, DIV192};&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;void setbaud1( byte baudndx)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;{&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; word temp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; temp = SCI1BD &amp;amp; 0xC000;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp; SCI1BD = baudtab[baudndx] | temp;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;}&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Arial"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;JimDon wrote:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;In my case I can't change the clock, and it seems that 115200 with an 8.5% error talks to the pc fine&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;This amount of error is about twice the maximum allowable baud rate error for the SCI module (assuming the PCs baud rate setting&amp;nbsp;has zero error).&amp;nbsp; It is possible that this amount of error may seem to give correct operation, due to the re-synchronisation process within the receive part of the SCI module.&amp;nbsp; Any timing errors are corrected at each data transition, and will prevent errors occurring provided the number of sequential 0's or 1's is limited.&amp;nbsp; You may find that errors start to occur for received characters&amp;nbsp;containing four or more successive 0's or 1's.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 17:49:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184212#M13675</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-01-31T17:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184213#M13676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello again, I have exceeded the edit period for my previous post ...&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;It occurred to me, that with the baud rate calculations previously presented, any remainder associated with the integer division process will be truncated, resulting in an actual&amp;nbsp;baud rate that will always equal, or exceed the nominal baud rate.&amp;nbsp; The error&amp;nbsp;will&amp;nbsp;often be a lower value if a rounding process is used within the calculation, so that the baud rate error may range both sides of the nominal baud rate.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;My previous macros might be modified, thus -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; SCICLK&amp;nbsp; BUSCLK/16&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; DIV1152 (SCICLK+57600)/115200&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; DIV576 &amp;nbsp;(SCICLK+28800)/57600&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; DIV384 &amp;nbsp;(SCICLK+19200)/38400&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#define&amp;nbsp; DIV192 &amp;nbsp;(SCICLK+9600)/19200&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;It should also be possible to test (at compile time) whether the the highest baud rate will be sufficiently accurate, for the chosen bus frequency.&amp;nbsp; If the highes baud rate is within tolerance,&amp;nbsp;any lower rates that are an even sub-multiple of the highest rate,&amp;nbsp;should have lower error.&amp;nbsp; Perhaps something similar to the following untested code for inclusion within the same header file&amp;nbsp;as the above macros -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#if&amp;nbsp;&amp;nbsp;&amp;nbsp; ((DIV1152*115200L-SCICLK)*100&amp;gt;SCICLK*4)&amp;nbsp; // +4 percent error test&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#error "Invalid bus frequency for 115200 baud"&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#endif&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#if&amp;nbsp;&amp;nbsp;&amp;nbsp; ((SCICLK-DIV1152*115200L)*100&amp;gt;SCICLK*4)&amp;nbsp; // -4 percent error test&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#error "Invalid bus frequency for 115200 baud"&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;#endif&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 19:34:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184213#M13676</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-01-31T19:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184214#M13677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;FONT size="2"&gt;I&lt;I&gt;t occurred to me, that with the baud rate calculations previously presented, any remainder associated with the integer division process will be truncated, resulting in an actual&amp;nbsp;baud rate that will always equal, or exceed the nominal baud rate.&lt;/I&gt;&lt;BR /&gt;&lt;BR /&gt;This is simply not correct in the case of the calculation I presented. The /32 after the divsion prevents just that. I have tested it and it generates the &lt;B&gt;exactly&lt;/B&gt; correct values.&amp;nbsp; I simply ask that before you delcare this to be a fact, you inspect the equation and submit it to a fair test. In the context presented, it is correct.&lt;BR /&gt;&lt;BR /&gt;As for the 8.5% error I agree that it certainly does not sound right. It is a demo for a USB serial and I will have to invesigate to see if this is correct (which is why I said &lt;I&gt;seems)&lt;/I&gt;. I had thought that the 12 Mhz xtal was for USB timing - also if you have a 12 Mhz xtal you can not us the FLL, so either it is running at 12 Mhz or they are running of the internal clock.&lt;BR /&gt;&lt;BR /&gt;Note I do not ask the compiler to do any math.&lt;BR /&gt;&lt;BR /&gt;#define CLK&amp;nbsp; (12000000L)&lt;BR /&gt;unsigned long baudrate = 600;&lt;BR /&gt;&lt;BR /&gt;baudrate =&amp;nbsp; ((CLK)/baudrate)/32L;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by JimDon on &lt;SPAN class="date_text"&gt;2008-01-31&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;08:52 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2008 21:48:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184214#M13677</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-01-31T21:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184215#M13678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Of course, as accurate as possible given the clock and desired baud rate.&lt;BR /&gt;&lt;BR /&gt;As has been pointed out, with a given clock the closest value for the register may not give a closed enough baud rate.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2008 04:20:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184215#M13678</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-02-01T04:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184216#M13679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Jim,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Firstly, if your CLK parameter is meant to represent the bus frequency, I would question whether the final divisor should be 16, rather than 32.&amp;nbsp; For the purpose of the following discussion, I will assume a value of 16.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Of course your calculation method will provide the correct division ratio when there is an integral relationship between the bus frequency and the baud rate.&amp;nbsp; The rounding process is intended to compensate, when this relationship is non-integral,&amp;nbsp;so the&amp;nbsp;calculated&amp;nbsp;division ratio&amp;nbsp;provides the closest baud rate to the nominal value.&amp;nbsp; The rounding process is most important for very high baud rates, and of lesser importance for lower baud rates where the baud rate divisor is a much larger value.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Consider the following example, where the required baud rate is 115200 bits per second, and a division ratio of 8 is used.&amp;nbsp; To provide the exact baud rate, this would require a bus frequency of 14.7456 MHz.&amp;nbsp; Assuming the actual baud rate should remain within a tolerance of +/- 4 percent, this would give an allowable range&amp;nbsp;for the&amp;nbsp;bus frequency of 14.156 to 15.335 MHz, for the particular division ratio.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Plugging any frequency, within this range, into the formula for calculating the required baud rate divisor, should produce a value of 8.&amp;nbsp; This is not the case with your calculation using integer division.&amp;nbsp; For any bus frequency less than the nominal&amp;nbsp;frequency,&amp;nbsp;for example&amp;nbsp;14.745 MHz, the result of the calculation would be the inappropriate value of&amp;nbsp;7.&amp;nbsp; The rounding process previously considered takes into account the truncation of the remainder of the division process, and should produce the correct result.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-02-01&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;02:28 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2008 11:23:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184216#M13679</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-02-01T11:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Baud rate on QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184217#M13680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;I dont' know where you got 8 from.&lt;BR /&gt;Since you started with the clock frequency, not the bus clock you SHOULD be dividing by 32.&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;14.7456 MHz is a "magic" oscillator frequency that makes all standard baud rate come out exact. I actually have 4 of them in my parts drawer from the good old days, when systems were very intolerant of such errors. (sparkfun has them for 1.50).&lt;BR /&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;Well, in any case you meant&amp;nbsp; 4, but the point is well taken. If your clock frequency goes out to more that 3 significant digits the biased integer divsion will not work. Of course don't go out of your mind worrying about this, as most clock frequencies are fine, but his magic value does give 0% error. However, if you are designing a USB to serial converter, you should go with this magic value.&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;BR /&gt;For 14.7456 ONLY&lt;BR /&gt;&lt;/DIV&gt;&lt;PRE&gt;#define 115200baud         0    #define 57600baud          1    #define 38400baud          2    #define 19200baud          3    #define 14400baud          4    #define 9600baud           5    #define 4800baud           6    #define 2400baud           7    #define 1200baud           8    #define 600baud            9   

static const  byte BaudH[10] = {0,0,0,0,0,0,0,0,1,3};
static const  byte BaudL[10] = {4,8,12,24,32,48,96,192,128,0};

void SetBaud(byte b)
{
 SCIxBDH = BaudH[b]; 
 SCIxBDL = BaudL[b];
}
&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:35:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Baud-rate-on-QE128/m-p/184217#M13680</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2020-10-29T09:35:14Z</dc:date>
    </item>
  </channel>
</rss>

