<?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>topic Re: Generating a 5MHz clock signal using LPC1768 in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698776#M53701</link>
    <description>&lt;P&gt;Woohoo! I think I got Match working:&lt;/P&gt;&lt;P&gt;I user Timer0 and MR1, setting up as follows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;LPC_PINCON-&amp;gt;PINSEL7 = (2&amp;lt;&amp;lt;20); // P3.26 becomes MAT0.1
LPC_PINCON-&amp;gt;PINMODE7 |= (2 &amp;lt;&amp;lt; 20); // Pin 3.26 == MAT0.1 no pull or pull down
LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 1;      // Power up Timer 1
LPC_SC-&amp;gt;PCLKSEL0 |= 1 &amp;lt;&amp;lt; 2;   // Clock for Timer 0 = CCLK

LPC_TIM0-&amp;gt;MR1 = 9;     // Approx 100ns
LPC_TIM0-&amp;gt;MCR = (1 &amp;lt;&amp;lt; 4);			// Reset on MR1 (no interrupt)
LPC_TIM0-&amp;gt;EMR = (1 &amp;lt;&amp;lt; 1) | (3&amp;lt;&amp;lt;6);	// Drive MAT0.1
	
// Reset Timer 1
LPC_TIM0-&amp;gt;TCR = 0x02; 
LPC_TIM0-&amp;gt;TCR = 0x00;
LPC_TIM0-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 0;      // Start timer 1&lt;/LI-CODE&gt;&lt;P&gt;The only odd things are:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I needed to set MR1 to 9 for an interval or 100ns when I expected to have to use 10.&lt;/LI&gt;&lt;LI&gt;The amplitude of the signal on that output pin was 0.4Vp-p when I expected 3.3V.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Can you clarify those issues for me please?&lt;/P&gt;&lt;P&gt;Thanks, David&lt;/P&gt;</description>
    <pubDate>Thu, 03 Aug 2023 15:53:13 GMT</pubDate>
    <dc:creator>perdrix</dc:creator>
    <dc:date>2023-08-03T15:53:13Z</dc:date>
    <item>
      <title>Generating a 5MHz clock signal using LPC1768</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1697634#M53687</link>
      <description>&lt;P&gt;The processor is running with a processor clock of 100MHz.&lt;/P&gt;&lt;P&gt;I only have the following GPIO pins available for use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;P0.2, P0.3, P0.23, P0.24, P0.25 and P0.26&lt;BR /&gt;&lt;BR /&gt;I tried to use a timer interrupt to generate a 5MHz clock signal, but AFAICT there just aren't enough processor cycles available to handle a timer interrupt every 10 clocks (which makes sense) and I only achieved a 1MHz signal out and there were probably not many processor cycles available to do any other work!&lt;BR /&gt;&lt;BR /&gt;Is there a neat way to get a 5MHz clock out those pins using hardware to toggle it (perhaps using one of the peripherals)?&amp;nbsp; Ideally I'd like to use P0.23 and P0.26 for the clock signal (but not both at the same time).&lt;/P&gt;&lt;P&gt;Thanks, David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 12:42:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1697634#M53687</guid>
      <dc:creator>perdrix</dc:creator>
      <dc:date>2023-08-02T12:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a 5MHz clock signal using LPC1768</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698466#M53695</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/185858"&gt;@perdrix&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you just want to toggle GPIO? How about use match function of timer?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alice_Yang_0-1691052888415.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/234932i2215CDAA4EF67883/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Alice_Yang_0-1691052888415.png" alt="Alice_Yang_0-1691052888415.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;Alice&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 08:55:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698466#M53695</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2023-08-03T08:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a 5MHz clock signal using LPC1768</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698529#M53696</link>
      <description>&lt;P&gt;Maybe because I didn't quite understand how that works!&lt;/P&gt;&lt;P&gt;Remember that for a 5MHz clock on a GPIO port that needs to be toggled every 100ns or every ten processor cycles.&amp;nbsp;&amp;nbsp;&amp;nbsp; If by using the match registers I can do that w/o consuming processor cycles, I am all ears!!!&lt;BR /&gt;&lt;BR /&gt;Please could you help me with some example code.&lt;BR /&gt;&lt;BR /&gt;The code I used looked like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void TIMER1_IRQHandler (void)
{
  if((LPC_TIM1-&amp;gt;IR &amp;amp; 0x01) == 0x01) // if MR0 interrupt
  {
        LPC_TIM1-&amp;gt;IR |= (1 &amp;lt;&amp;lt; 0); // Clear MR1 interrupt flag
	if (enablePGC)
	{
	  LPC_GPIO0-&amp;gt;FIOPIN ^= PGC; // Toggle PGC (programming clock)
	}
	else LPC_GPIO0-&amp;gt;FIOPIN &amp;amp;= ~(PGC);// Force PGC low		
  }
}

LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 1;      // Power up Timer 1
LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 22;     // Power up Timer 2
LPC_SC-&amp;gt;PCLKSEL0 |= 1 &amp;lt;&amp;lt; 4;   // Clock for Timer 1 = CCLK
LPC_SC-&amp;gt;PCLKSEL1 |= 1 &amp;lt;&amp;lt; 12;  // Clock for Timer 2 = CCLK

LPC_TIM1-&amp;gt;MR0 = 10;           // 5MHz
LPC_TIM1-&amp;gt;MCR |= (1 &amp;lt;&amp;lt; 0) | (1 &amp;lt;&amp;lt; 1); // Interrupt and Reset on MR0

// Reset Timers 1 and 2
LPC_TIM1-&amp;gt;TCR = 0x02; 
LPC_TIM1-&amp;gt;TCR = 0x00;
LPC_TIM2-&amp;gt;TCR = 0x02; 
LPC_TIM2-&amp;gt;TCR = 0x00;

// Clear pending interrupts for Timer 1 and enable timer interrupts
NVIC_ClearPendingIRQ(TIMER1_IRQn);
NVIC_EnableIRQ(TIMER1_IRQn);  // Enable timer interrupt
LPC_TIM1-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 0;      // Start timer 1&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;If you could show me how to do that using the match stuff I'd be most grateful - I got quite confused reading about EMR and MAT0.n registers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 10:22:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698529#M53696</guid>
      <dc:creator>perdrix</dc:creator>
      <dc:date>2023-08-03T10:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a 5MHz clock signal using LPC1768</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698559#M53697</link>
      <description>&lt;P&gt;Please remember&lt;/P&gt;&lt;P&gt;I only have the following GPIO pins available for use:&lt;/P&gt;&lt;P&gt;P0.2, P0.3, P0.23, P0.24, P0.25 and P0.26&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 10:56:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698559#M53697</guid>
      <dc:creator>perdrix</dc:creator>
      <dc:date>2023-08-03T10:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a 5MHz clock signal using LPC1768</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698776#M53701</link>
      <description>&lt;P&gt;Woohoo! I think I got Match working:&lt;/P&gt;&lt;P&gt;I user Timer0 and MR1, setting up as follows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;LPC_PINCON-&amp;gt;PINSEL7 = (2&amp;lt;&amp;lt;20); // P3.26 becomes MAT0.1
LPC_PINCON-&amp;gt;PINMODE7 |= (2 &amp;lt;&amp;lt; 20); // Pin 3.26 == MAT0.1 no pull or pull down
LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 1;      // Power up Timer 1
LPC_SC-&amp;gt;PCLKSEL0 |= 1 &amp;lt;&amp;lt; 2;   // Clock for Timer 0 = CCLK

LPC_TIM0-&amp;gt;MR1 = 9;     // Approx 100ns
LPC_TIM0-&amp;gt;MCR = (1 &amp;lt;&amp;lt; 4);			// Reset on MR1 (no interrupt)
LPC_TIM0-&amp;gt;EMR = (1 &amp;lt;&amp;lt; 1) | (3&amp;lt;&amp;lt;6);	// Drive MAT0.1
	
// Reset Timer 1
LPC_TIM0-&amp;gt;TCR = 0x02; 
LPC_TIM0-&amp;gt;TCR = 0x00;
LPC_TIM0-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 0;      // Start timer 1&lt;/LI-CODE&gt;&lt;P&gt;The only odd things are:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I needed to set MR1 to 9 for an interval or 100ns when I expected to have to use 10.&lt;/LI&gt;&lt;LI&gt;The amplitude of the signal on that output pin was 0.4Vp-p when I expected 3.3V.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Can you clarify those issues for me please?&lt;/P&gt;&lt;P&gt;Thanks, David&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 15:53:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698776#M53701</guid>
      <dc:creator>perdrix</dc:creator>
      <dc:date>2023-08-03T15:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a 5MHz clock signal using LPC1768</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698828#M53704</link>
      <description>&lt;P&gt;Hmmm I generate the clock signal, but how do I clock data out using that clock? Maybe I need to rethink to use one of the peripherals &lt;LI-EMOJI id="lia_disappointed-face" title=":disappointed_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 18:01:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1698828#M53704</guid>
      <dc:creator>perdrix</dc:creator>
      <dc:date>2023-08-03T18:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a 5MHz clock signal using LPC1768</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1700963#M53779</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/185858"&gt;@perdrix&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For match function, there is External Match Output pins, while not for those pins(&lt;SPAN&gt;P0.2, P0.3, P0.23, P0.24, P0.25 and P0.26&lt;/SPAN&gt;).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alice_Yang_0-1691485170144.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/235523iC7B91466C91B4E7D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Alice_Yang_0-1691485170144.png" alt="Alice_Yang_0-1691485170144.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For you those pins, I think only can use timer interrupt to control GPIO.&amp;nbsp;&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;</description>
      <pubDate>Tue, 08 Aug 2023 09:00:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1700963#M53779</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2023-08-08T09:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a 5MHz clock signal using LPC1768</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1701055#M53781</link>
      <description>&lt;P&gt;I've done this the old fashioned way by bit-banging the clock and data at a lower rate (1MHz) which the receiving device can handle and I can generate.&amp;nbsp; Thanks,David&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 11:08:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Generating-a-5MHz-clock-signal-using-LPC1768/m-p/1701055#M53781</guid>
      <dc:creator>perdrix</dc:creator>
      <dc:date>2023-08-08T11:08:56Z</dc:date>
    </item>
  </channel>
</rss>

