<?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: calculating proper BAUD and BUSCLK</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192776#M14892</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, bigmac, what can I say?&amp;nbsp; Impeccable contributions you make.&amp;nbsp; I've bookmarked this little nugget.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Sep 2012 15:39:08 GMT</pubDate>
    <dc:creator>irob</dc:creator>
    <dc:date>2012-09-13T15:39:08Z</dc:date>
    <item>
      <title>calculating proper BAUD and BUSCLK</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192772#M14888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I'm confused.&amp;nbsp; I &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fcommunity.freescale.com%2Fthread%2F39307" rel="nofollow" target="_blank"&gt;found this thread&lt;/A&gt; which only confirms my confusion.&amp;nbsp; I'm using a 9S08QE32 (though this question applies to quite a few chips in the S08 family.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Page 21-22 of the QE32 reference manual states:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #FF0000;"&gt;&lt;EM&gt;ICSOUT — This clock source is used as the CPU clock and is divided by two to generate the&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #FF0000;"&gt;&lt;EM&gt;peripheral bus clock, BUSCLK.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #FF0000;"&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;I have the FLL selected as my ICS, so therefore my rate is 8.372 MHz.&amp;nbsp; Further, my BUSCLK would be 4.186 MHz, right?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;For my SCI port, page 222-223 says the BAUD is calculated with:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;&lt;SPAN style=": ; color: #FF0000; font-family: 'courier new,courier';"&gt;BAUD = BUSCLK / (SBR[12:0] * 16)&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;Or written a different way:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #FF0000; font-family: 'courier new,courier';"&gt;SBR = BUSCLK / (16 * BAUD)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;But my baud calculations are off.&amp;nbsp; It's as if the BUSCLK is off by that factor of two.&amp;nbsp; If I set my BAUD to 9600, the serial port actually is working at 19200.&amp;nbsp; 2x error.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #000000;"&gt;What am I missing here?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2012 01:58:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192772#M14888</guid>
      <dc:creator>irob</dc:creator>
      <dc:date>2012-08-30T01:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: calculating proper BAUD and BUSCLK</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192773#M14889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello irob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without knowing your actual register settings, it is not possible to see the precise problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula for the bus frequency would be as follows -&lt;/P&gt;&lt;P&gt;For &lt;FONT face="courier new,courier"&gt;ICSSC_DRS = 0,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;fbus = fref * 512 / 2 / Bdiv&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;For&lt;/FONT&gt; ICSSC_DRS = 1,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;fbus = fref * 1024 / 2 / Bdiv&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;The Bdiv factor will be determined by the setting of ICSC2_BDIV.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Assuming ICSSC_DRS = 0, to obtain a bus frequency of 4.186MHz would requre the&amp;nbsp;reference frequency to be trimmed to 32.703 kHz, and would also require a Bdiv divisor value of 2.&amp;nbsp; If ICSSC_DRS = 1, the Bdiv divisor would need to be increased to 4.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;The nearest SBR divider value for 9600 bits per second would be 27.&amp;nbsp; However, there will be a baud error of nearly 1 percent.&amp;nbsp; Other trim settings (and bus frequencies) will result&amp;nbsp;in exact baud rates.&amp;nbsp;&amp;nbsp;For bus frequencies within the range 4 to 5 MHz, consider the following possible settings -&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;SBR&amp;nbsp;&amp;nbsp;fref(kHz)&amp;nbsp; fbus&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;26&amp;nbsp;&amp;nbsp; 31.25&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.000&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;27&amp;nbsp;&amp;nbsp; 32.40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.147&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;28&amp;nbsp;&amp;nbsp; 33.60&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.301&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;29&amp;nbsp;&amp;nbsp; 34.80&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4.454&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;30&amp;nbsp;&amp;nbsp;&amp;nbsp;36.00&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.608&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;31&amp;nbsp;&amp;nbsp; 37.20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.762&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;32&amp;nbsp;&amp;nbsp; 38.40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4.915&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Mac&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2012 12:23:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192773#M14889</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-08-31T12:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: calculating proper BAUD and BUSCLK</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192774#M14890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;bigmac, you continue to be a valued Freescale resource on these fora!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yet I was pouring over your formulae and can't seem to find exactly where in the QE datasheet where they are referenced quite like you've paraphrased.&amp;nbsp; Can you cite a page number for your &lt;FONT face="courier new,courier"&gt;fbus&lt;/FONT&gt; formula?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The baud formula on page 211 is pretty clear.&amp;nbsp; Th eonly unknown is BUSCLK and the SBR word.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I'm confused by how you are tying SBR to to baud rate in your table.&amp;nbsp; Using your fbus formula, I can't get any of the numbers you list in the table, solving for either SBR or fbus.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would seem to me that assuming default register values for the FLL on power up, the datasheet formula for baud on pg 211 is more than enough to solve.&amp;nbsp; The question is just knowing what BUSCLK is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My full ICS register settings:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  ICSC1_CLKS = 0b00;      // use FLL  ICSC1_IREFS = 1;        // Internal reference clock selected.  ICSC1_IRCLKEN = 1;      // ICSIRCLK active.  ICSC1_IREFSTEN = 0;     // Internal reference clock is disabled in stop.   ICSC2_BDIV = 0b00;      // Divides selected clock by 1.  ICSSC_IREFST = 0;       // source of reference clock is external clock.  ICSSC_CLKST = 0b00;     // output of FLL is selected&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Throroughly confused&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:45:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192774#M14890</guid>
      <dc:creator>irob</dc:creator>
      <dc:date>2020-10-29T09:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: calculating proper BAUD and BUSCLK</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192775#M14891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello irob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formulae for calculating the bus frequency were derived from data given at a number of locations within the Reference Manual.&amp;nbsp; The primary reference is Tables 11.6 and 11.7 that&amp;nbsp;indicate a number of different DCO ranges, and the FLL factor associated with each range.&amp;nbsp; The low and mid ranges would be mostly of interest.&amp;nbsp; It is appropriate for the&amp;nbsp;internal reference use, that ICSSC_DMX32 = 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From Table 11.7, you can deduce that&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;&lt;FONT face="courier new,courier"&gt;DCO_freq = fref * FLL_factor&lt;/FONT&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;Then from Fig. 11.2 block diagram it can be observed that, when FLL output is selected,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080" face="courier new,courier"&gt;&lt;FONT color="#0000ff"&gt;ICSOUT_freq = DCO_freq / Bdiv&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;where Bdiv = 1, 2, 4 or 8, determined by ICSC2_BDIV setting&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;Further reference to section 1.3 and Fig. 1.2, show a further divide by 2 stage, so that&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="courier new,courier"&gt;BUSCLK = ICSOUT_freq / 2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;Combining these expressions will result in the previous formulae.&amp;nbsp;&lt;/FONT&gt; &lt;FONT color="#808080"&gt;For yur current register settings that use low range by default, the FLL factor will be 512, and Bdiv is 1, giving&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080" face="courier new,courier"&gt;BUSCLK = fref * 512 / 1 / 2 =&amp;nbsp;fref *&amp;nbsp;256&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;Since fref will be trimmed somewhere within the range 31.25 to 39.0625 kHz, the bus frequency will have the range 8.000 MHz to 10.000 MHz, double the frequency that you were anticipating.&amp;nbsp; If you were to trim the reference frequency for 32.703 kHz, as was previously implied, the actual&amp;nbsp;bus frequency would be 8.372 MHz.&amp;nbsp; For 9600 bits per second, the SBR setting would need to be 54 or 55, for a baud error of about 1 percent.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;With the code lines,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080" face="courier new,courier"&gt;&amp;nbsp; ICSSC_IREFST = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // source of reference clock is external clock.&lt;BR /&gt;&amp;nbsp; ICSSC_CLKST = 0b00;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // output of FLL is selected&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;these will not do anything since you are attempting to write to read-only status bits.&amp;nbsp; However, you should explicitly set the DRS and DMX32 bits, rather than relying on the POR default.&lt;FONT face="courier new,courier"&gt;&amp;nbsp;ICSSC = 0;&lt;/FONT&gt; would be more appropriate for ICS initialisation.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080"&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 20:58:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192775#M14891</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-09-06T20:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: calculating proper BAUD and BUSCLK</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192776#M14892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, bigmac, what can I say?&amp;nbsp; Impeccable contributions you make.&amp;nbsp; I've bookmarked this little nugget.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Sep 2012 15:39:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192776#M14892</guid>
      <dc:creator>irob</dc:creator>
      <dc:date>2012-09-13T15:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: calculating proper BAUD and BUSCLK</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192777#M14893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, shoot, now that I'm getting into the meat of your answer, there's one step I don't follow still.&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;bigmac wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;SPAN style="color: #808080;"&gt;Since fref will be trimmed somewhere within the range 31.25 to 39.0625 kHz, &lt;STRONG&gt;the bus frequency will have the range 8.000 MHz to 10.000 MHz&lt;/STRONG&gt;, double the frequency that you were anticipating.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Says who/where?&amp;nbsp; I can't find this relationship between bus frequency (is this BUSCLK?) and DCO.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:45:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/calculating-proper-BAUD-and-BUSCLK/m-p/192777#M14893</guid>
      <dc:creator>irob</dc:creator>
      <dc:date>2020-10-29T09:45:57Z</dc:date>
    </item>
  </channel>
</rss>

