<?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: LPC11U68 PWM frequency</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11U68-PWM-frequency/m-p/1416306#M47943</link>
    <description>&lt;P&gt;Any help? &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Feb 2022 09:12:53 GMT</pubDate>
    <dc:creator>castle</dc:creator>
    <dc:date>2022-02-20T09:12:53Z</dc:date>
    <item>
      <title>LPC11U68 PWM frequency</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11U68-PWM-frequency/m-p/1416266#M47939</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have LPCXpresso OM13058 board with LPC11U68 MCU.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Board schematic: &lt;A href="https://www.nxp.com/downloads/en/schematics/LPC11U68_Xpresso_v2_Schematic_RevC_1.pdf" target="_blank"&gt;https://www.nxp.com/downloads/en/schematics/LPC11U68_Xpresso_v2_Schematic_RevC_1.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I am using this board standalone and compile my program with IAR IDE. For MCU programming I use Flash magic. I attached my project configuration files, including SystemInit.&lt;/P&gt;&lt;P&gt;My program runs at 48MHz. I am trying to generate 200kHz PWM for a GPIO pin. I init my CT32B0 timer:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= (1&amp;lt;&amp;lt;9); &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;LPC_CT32B0-&amp;gt;CTCR = 0x0;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;LPC_CT32B0-&amp;gt;PR = 48-1; //prescale, I get 1MHz&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;LPC_CT32B0-&amp;gt;TCR = 0x02;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Then I have a timer counter based delay function:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;void delay(unsigned int ms) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; LPC_CT32B0-&amp;gt;TCR = 0x02; &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; LPC_CT32B0-&amp;gt;TCR = 0x01; &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; while(LPC_CT32B0-&amp;gt;TC &amp;lt; ms);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp; LPC_CT32B0-&amp;gt;TCR = 0x00; &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Simple GPIO toggling to get 1kHz (works well, oscilloscope shows 1kHz):&lt;/P&gt;&lt;P&gt;LPC_GPIO_PORT-&amp;gt;NOT[0] |= (1&amp;lt;&amp;lt;17);&lt;BR /&gt;delay(500);&lt;/P&gt;&lt;P&gt;Then I changed a value from 500 to 50, but instead of getting 10kHz, my oscilloscope shows 9.88kHz.&lt;/P&gt;&lt;P&gt;LPC_GPIO_PORT-&amp;gt;NOT[0] |= (1&amp;lt;&amp;lt;17);&lt;BR /&gt;delay(50);&lt;/P&gt;&lt;P&gt;By changing value to 5, a result get much more inaccurate. I get 87.7kHz instead of 100kHz:&lt;/P&gt;&lt;P&gt;LPC_GPIO_PORT-&amp;gt;NOT[0] |= (1&amp;lt;&amp;lt;17);&lt;BR /&gt;delay(5);&lt;/P&gt;&lt;P&gt;As you can see, the frequency is not so high, but the error is not acceptable. I have implemented USART that is running 115200 baud rate without any issues, so I think the main clock frequency is actually running at 48MHz (SystemCoreClock also returns value 48000000).&lt;/P&gt;&lt;P&gt;I have tried different ports and pins, but result the same. Also, I have tried to run the same code on another board with 72MHz MCU LPC1343, ant GPIO switching at 200kHz was perfect and without any errors.&lt;/P&gt;&lt;P&gt;Could you please help to find out the problem. Are there any additional configuration needed or the issue is hardware?&lt;/P&gt;</description>
      <pubDate>Sat, 19 Feb 2022 09:22:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11U68-PWM-frequency/m-p/1416266#M47939</guid>
      <dc:creator>castle</dc:creator>
      <dc:date>2022-02-19T09:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: LPC11U68 PWM frequency</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11U68-PWM-frequency/m-p/1416306#M47943</link>
      <description>&lt;P&gt;Any help? &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Feb 2022 09:12:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11U68-PWM-frequency/m-p/1416306#M47943</guid>
      <dc:creator>castle</dc:creator>
      <dc:date>2022-02-20T09:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: LPC11U68 PWM frequency</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11U68-PWM-frequency/m-p/1418666#M47987</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;SPAN&gt;castle,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Generate PWM , recommend you use SCTIEMR, there is PWM application note, you can refer to:&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.nxp.com/docs/en/application-note/AN11538.zip" target="_blank"&gt;https://www.nxp.com/docs/en/application-note/AN11538.zip&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Toggle gpio by software not as accurate as hardware(SCTIEMR).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 02:00:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11U68-PWM-frequency/m-p/1418666#M47987</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2022-02-24T02:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: LPC11U68 PWM frequency</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11U68-PWM-frequency/m-p/1479068#M49300</link>
      <description>&lt;P&gt;I think the timer is counting too fast. If actually mcu clocked at 48 MHz for delay (5) only 5 us.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 11:57:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11U68-PWM-frequency/m-p/1479068#M49300</guid>
      <dc:creator>Badman</dc:creator>
      <dc:date>2022-06-23T11:57:24Z</dc:date>
    </item>
  </channel>
</rss>

