<?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>LPC Microcontrollers中的主题 Re: LPC804 trim clock?</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-trim-clock/m-p/1405529#M47758</link>
    <description>&lt;P&gt;Alice,&lt;/P&gt;&lt;P&gt;Thanks for the reply.&amp;nbsp; I did see that API &lt;SPAN class=""&gt;of&amp;nbsp; set_fro_frequency() but it says pretty clearly that the options for frequency parameter are only: 18000 =&amp;gt; 18MHz, 24000=&amp;gt;24Mhz, 30000=&amp;gt;30Mhz.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;But since you (NXP TechSupport) suggested that I could use this to trim the frequency, I gave it a try.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I hacked the fsl_clock.c and changed:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/*! brief Set FRO oscillator output frequency.
 *  Initialize the FRO clock to given frequency (18, 24 or 30 MHz).
 * param freq, please reference clock_fro_osc_freq_t definition, frequency must be one of 18000, 24000 or 30000 KHz.
 *
 */
void CLOCK_SetFroOscFreq(clock_fro_osc_freq_t freq)
{
    g_Fro_Osc_Freq = (uint32_t)freq * 1000UL;
    LPC_PWRD_API-&amp;gt;set_fro_frequency(30100000UL); //(uint32_t)freq); -HACKING!
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is that the clock is running at 24MHz (not the expected 30.1MHz).&amp;nbsp; This is confirmed by my FreeRTOS &lt;SPAN&gt;xTaskGetTickCount() counting at 12.5ms instead of 10ms.&amp;nbsp; And the serial baud is lowered to 93000bps from 115200, a -20% decrease.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I also tried set_fro_frequncy(29900000UL), set_fro_frequncy(30001000UL), and set_fro_frequncy(29000000UL).&amp;nbsp; They all result in a 24MHz clock.&amp;nbsp; (I guess 24MHz is the default, so the API just silently fails and keeps the default?)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So as I had expected, the API is not allowing to trim the clock.&amp;nbsp; But I wasted some more of my time to confirm.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It seems like a lot of this chip is a "black-box" because the ROM handles clock and flash-write functions and only provides a limited API.&amp;nbsp; Why NXP doesn't allow direct access to the hardware for more fine-grained control?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;EDIT: Maybe it's available on higher-cost chips?&amp;nbsp; This article references a &lt;STRONG&gt;FREQTRIM&lt;/STRONG&gt; register on LPC chips, but it's not mentioned in the LPC804 manual.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC-Regarding-to-Internal-Clock-Calibration/ta-p/1323134" target="_blank"&gt;https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC-Regarding-to-Internal-Clock-Calibration/ta-p/1323134&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jan 2022 20:03:14 GMT</pubDate>
    <dc:creator>phatpaul</dc:creator>
    <dc:date>2022-01-26T20:03:14Z</dc:date>
    <item>
      <title>LPC804 trim clock?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-trim-clock/m-p/1404675#M47745</link>
      <description>&lt;P&gt;Is it possible to set a custom FRO frequency trim?&lt;/P&gt;&lt;P&gt;According to the manual, the bootloader loads factory trim values into the FRO.&amp;nbsp; Can we change those values to adjust the frequency slightly?&lt;/P&gt;&lt;P&gt;EDIT: or perhaps it's possible to trim the SysTick timer interval which FreeRTOS uses for timing?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 18:07:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-trim-clock/m-p/1404675#M47745</guid>
      <dc:creator>phatpaul</dc:creator>
      <dc:date>2022-01-25T18:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 trim clock?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-trim-clock/m-p/1405064#M47751</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;A id="link_12" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://community.nxp.com/t5/user/viewprofilepage/user-id/104815" target="_self" aria-label="View Profile of phatpaul"&gt;&lt;SPAN class=""&gt;hatpaul,&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;How about use the&amp;nbsp; API of&amp;nbsp; set_fro_frequency :&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alice_Yang_0-1643189752639.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/168870iC502042D121A4ACB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Alice_Yang_0-1643189752639.png" alt="Alice_Yang_0-1643189752639.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alie&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 09:36:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-trim-clock/m-p/1405064#M47751</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2022-01-26T09:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 trim clock?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-trim-clock/m-p/1405529#M47758</link>
      <description>&lt;P&gt;Alice,&lt;/P&gt;&lt;P&gt;Thanks for the reply.&amp;nbsp; I did see that API &lt;SPAN class=""&gt;of&amp;nbsp; set_fro_frequency() but it says pretty clearly that the options for frequency parameter are only: 18000 =&amp;gt; 18MHz, 24000=&amp;gt;24Mhz, 30000=&amp;gt;30Mhz.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;But since you (NXP TechSupport) suggested that I could use this to trim the frequency, I gave it a try.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;I hacked the fsl_clock.c and changed:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/*! brief Set FRO oscillator output frequency.
 *  Initialize the FRO clock to given frequency (18, 24 or 30 MHz).
 * param freq, please reference clock_fro_osc_freq_t definition, frequency must be one of 18000, 24000 or 30000 KHz.
 *
 */
void CLOCK_SetFroOscFreq(clock_fro_osc_freq_t freq)
{
    g_Fro_Osc_Freq = (uint32_t)freq * 1000UL;
    LPC_PWRD_API-&amp;gt;set_fro_frequency(30100000UL); //(uint32_t)freq); -HACKING!
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result is that the clock is running at 24MHz (not the expected 30.1MHz).&amp;nbsp; This is confirmed by my FreeRTOS &lt;SPAN&gt;xTaskGetTickCount() counting at 12.5ms instead of 10ms.&amp;nbsp; And the serial baud is lowered to 93000bps from 115200, a -20% decrease.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I also tried set_fro_frequncy(29900000UL), set_fro_frequncy(30001000UL), and set_fro_frequncy(29000000UL).&amp;nbsp; They all result in a 24MHz clock.&amp;nbsp; (I guess 24MHz is the default, so the API just silently fails and keeps the default?)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So as I had expected, the API is not allowing to trim the clock.&amp;nbsp; But I wasted some more of my time to confirm.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It seems like a lot of this chip is a "black-box" because the ROM handles clock and flash-write functions and only provides a limited API.&amp;nbsp; Why NXP doesn't allow direct access to the hardware for more fine-grained control?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;EDIT: Maybe it's available on higher-cost chips?&amp;nbsp; This article references a &lt;STRONG&gt;FREQTRIM&lt;/STRONG&gt; register on LPC chips, but it's not mentioned in the LPC804 manual.&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC-Regarding-to-Internal-Clock-Calibration/ta-p/1323134" target="_blank"&gt;https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC-Regarding-to-Internal-Clock-Calibration/ta-p/1323134&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 20:03:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-trim-clock/m-p/1405529#M47758</guid>
      <dc:creator>phatpaul</dc:creator>
      <dc:date>2022-01-26T20:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 trim clock?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-trim-clock/m-p/1406547#M47773</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;SPAN&gt;satsok_n,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I will help to check about this, while need some days, because we will have public holiday tomorrow, I will reply you &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;after come back .ASAP. Thanks for your understanding.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Alice&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 09:42:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-trim-clock/m-p/1406547#M47773</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2022-01-28T09:42:30Z</dc:date>
    </item>
  </channel>
</rss>

