<?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>Kinetis Microcontrollers中的主题 Re: K40 Set Bps Rate</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1244440#M59861</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Ensure that any rx errors (like framing error) that may occur during the baud rate change are cleared in the status register since reception is blocked when they are set.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Also when receiving with DMA you still need an rx error interrupt handler to clear such flags if ever they were to occur in normal operation.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;It may also be a good idea to disable the receiver when changing and re-enabling it again in case you don't already do it.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Mark&lt;BR /&gt;&lt;EM&gt;[uTasker project developer for Kinetis and i.MX RT]&lt;/EM&gt;&lt;BR /&gt;&lt;FONT color="#999999"&gt;Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or rapid product development requirements&lt;BR /&gt;&lt;BR /&gt;For professionals searching for faster, problem-free Kinetis and i.MX RT 10xx developments the uTasker project holds the key: &lt;A href="https://www.utasker.com/kinetis/TWR-K40D100M.html" target="_blank"&gt;https://www.utasker.com/kinetis/TWR-K40D100M.html&lt;/A&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Mar 2021 00:16:15 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2021-03-12T00:16:15Z</dc:date>
    <item>
      <title>K40 Set Bps Rate</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1239762#M59782</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a bare metal K40 project that uses the scatter/gather DMA function in conjunction with UART0 to receive serial data.&amp;nbsp; This all works fine.&lt;/P&gt;&lt;P&gt;However I am not able to successfully change the BPS rate on UART0 after it has been operating.&lt;/P&gt;&lt;P&gt;I have an external WiFi module that has an initial bps rate (115200).&amp;nbsp; But can be changed on the fly.&lt;/P&gt;&lt;P&gt;I issue the command to the WiFi module to change to a bps rate to 2000000.&amp;nbsp; Wait for all bytes to be transmitted from the K40 then change the bps rate of UART0.&amp;nbsp; Here is the code I use to change the bps rate&lt;/P&gt;&lt;P&gt;//-----------------------------------------------------------------------------&lt;BR /&gt;void UART0_SetBpsRate(int nBpsRate)&lt;BR /&gt;{&lt;BR /&gt;uint8_t temp;&lt;BR /&gt;unsigned int sbr, brfa;&lt;/P&gt;&lt;P&gt;// To update the 13-bit baud rate setting (SBR[12:0]), first write to BDH to&lt;BR /&gt;// buffer the high half of the new value and then write to BDL. The working value in BDH&lt;BR /&gt;// does not change until BDL is written.&lt;/P&gt;&lt;P&gt;// Calculate baud settings&lt;BR /&gt;sbr = (SystemCoreClock / (nBpsRate * 16));&lt;/P&gt;&lt;P&gt;// UART0_BDH: LBKDIE=0, RXEDGIE=0.&lt;BR /&gt;UART0-&amp;gt;BDH = (sbr &amp;amp; 0x1F00) &amp;gt;&amp;gt; 8;&lt;/P&gt;&lt;P&gt;// UART0_BDL&lt;BR /&gt;UART0-&amp;gt;BDL = sbr &amp;amp; 0xFF; //0x34U;&lt;/P&gt;&lt;P&gt;// Determine if a fractional divider is needed to get closer to the baud rate&lt;BR /&gt;brfa = (((SystemCoreClock * 32) / (nBpsRate * 16)) - (sbr * 32)); //=&amp;gt; 8 for 100Mhz and 2 for 96Mhz&lt;BR /&gt;temp = UART0-&amp;gt;C4 &amp;amp; ~(0x1F);&lt;/P&gt;&lt;P&gt;// UART0_C4: MAEN1=0, MAEN2=0, M10=0, BRFA=0&lt;BR /&gt;UART0-&amp;gt;C4 = temp | brfa;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;However after changing the rate I no longer receive data from UART0/DMA.&lt;/P&gt;&lt;P&gt;I verified with a logic analyzer that the WiFi module has changed rates and is transmitting.&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 23:02:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1239762#M59782</guid>
      <dc:creator>michaelmccarric</dc:creator>
      <dc:date>2021-03-03T23:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: K40 Set Bps Rate</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1241981#M59828</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I suggest you check the function UART_Init() of the SDK. In that function, you have the steps to calculate the register values to reach the desired baud-rate.&lt;BR /&gt;You may refer to that and integrate it into your code.&lt;/P&gt;
&lt;P&gt;Let me know if this is helpful, if you have more questions do not hesitate to ask me.&lt;BR /&gt;Best regards,&lt;BR /&gt;Omar&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 20:43:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1241981#M59828</guid>
      <dc:creator>Omar_Anguiano</dc:creator>
      <dc:date>2021-03-08T20:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: K40 Set Bps Rate</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1241989#M59829</link>
      <description>&lt;P&gt;Setting the bps rate is not the problem.&amp;nbsp; The following works&lt;/P&gt;&lt;P&gt;InitUART();&lt;BR /&gt;SetBps(2000000);&lt;BR /&gt;InitDMA();&lt;/P&gt;&lt;P&gt;communication works fine.&amp;nbsp; I verified the bps rate with a logic analyzer. The following does not&lt;/P&gt;&lt;P&gt;InitUART();&lt;BR /&gt;SetBps(115200);&lt;BR /&gt;InitDMA();&lt;BR /&gt;SetBps(2000000);&lt;/P&gt;&lt;P&gt;I can see byte transmissions at the 2Mbps rate.&amp;nbsp; However anything sent from the external device does not generate DMA transfers.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 21:16:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1241989#M59829</guid>
      <dc:creator>michaelmccarric</dc:creator>
      <dc:date>2021-03-08T21:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: K40 Set Bps Rate</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1244371#M59860</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I did refer to the sdk example.&amp;nbsp; As mentioned I am not having trouble setting the bps rate.&amp;nbsp; That works fine.&amp;nbsp; The problem is in changing the bps after DMA transfer has been enabled.&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 20:18:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1244371#M59860</guid>
      <dc:creator>michaelmccarric</dc:creator>
      <dc:date>2021-03-11T20:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: K40 Set Bps Rate</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1244440#M59861</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Ensure that any rx errors (like framing error) that may occur during the baud rate change are cleared in the status register since reception is blocked when they are set.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Also when receiving with DMA you still need an rx error interrupt handler to clear such flags if ever they were to occur in normal operation.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;It may also be a good idea to disable the receiver when changing and re-enabling it again in case you don't already do it.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Mark&lt;BR /&gt;&lt;EM&gt;[uTasker project developer for Kinetis and i.MX RT]&lt;/EM&gt;&lt;BR /&gt;&lt;FONT color="#999999"&gt;Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or rapid product development requirements&lt;BR /&gt;&lt;BR /&gt;For professionals searching for faster, problem-free Kinetis and i.MX RT 10xx developments the uTasker project holds the key: &lt;A href="https://www.utasker.com/kinetis/TWR-K40D100M.html" target="_blank"&gt;https://www.utasker.com/kinetis/TWR-K40D100M.html&lt;/A&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 00:16:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K40-Set-Bps-Rate/m-p/1244440#M59861</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2021-03-12T00:16:15Z</dc:date>
    </item>
  </channel>
</rss>

