<?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: LPC1768: How to Read Tach signal for DC fan in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953084#M37843</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check the following examples and tutorial. Let me know if this helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.ocfreaks.com/lpc1768-timer-input-capture-frequency-counter-tutorial/"&gt;http://www.ocfreaks.com/lpc1768-timer-input-capture-frequency-counter-tutorial/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Have a nice day!&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sol&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Aug 2019 16:22:16 GMT</pubDate>
    <dc:creator>soledad</dc:creator>
    <dc:date>2019-08-01T16:22:16Z</dc:date>
    <item>
      <title>LPC1768: How to Read Tach signal for DC fan</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953080#M37839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can anybody help me out on reading a Tach signal from DC fan and controlling an LED on/off.&lt;/P&gt;&lt;P&gt;iam a nee bee to this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2019 18:56:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953080#M37839</guid>
      <dc:creator>rsapple_007</dc:creator>
      <dc:date>2019-07-22T18:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768: How to Read Tach signal for DC fan</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953081#M37840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the one of the LPC1768 Timers as a frequency counter. The idea is to count the number of cycles of the input in one second. You need one counter that keeps counting the rising/falling edges of the input signal then read the value of this counter once in a second and then clear it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below you can find pseudocode:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Initialization of the counter&lt;BR /&gt;&lt;BR /&gt;LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 2; //Power up TimerCounter1&lt;BR /&gt;&lt;BR /&gt;LPC_TIM1-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 0; // Counter mode&lt;BR /&gt;LPC_TIM1-&amp;gt;CTCR |= 2; // Count on falling edges&lt;BR /&gt;LPC_TIM1-&amp;gt;CTCR |= 1 &amp;lt;&amp;lt; 2; // CAP1.1 is the input pin for which the input signal needs to be connected.&lt;BR /&gt;&lt;BR /&gt;LPC_PINCON-&amp;gt;PINSEL3 |= 3 &amp;lt;&amp;lt; 6; // Make P1.19 as CAP1.1&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;LPC_TIM1-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 1; // Reset the counter&lt;BR /&gt;LPC_TIM1-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 0; // Start counter&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2. Initialization of the timer which generates interrupt once in a second&lt;BR /&gt;LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 1; //Power up Timer0&lt;BR /&gt;LPC_SC-&amp;gt;PCLKSEL0 |= 3 &amp;lt;&amp;lt; 2; // Clock for timer = CCLK/8&lt;BR /&gt;&lt;BR /&gt;LPC_TIM0-&amp;gt;MR0 = 12499999; // Assuming that clk freq = 100 MHz, this value is calculated to generate an interrupt once in a second.&lt;BR /&gt;&lt;BR /&gt;LPC_TIM0-&amp;gt;MCR |= 1 &amp;lt;&amp;lt; 0; // Interrupt on Match0 compare&lt;BR /&gt;LPC_TIM0-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 1; // Reset Timer0&lt;BR /&gt;&lt;BR /&gt;NVIC_EnableIRQ(TIMER0_IRQn); // Enable timer interrupt&lt;BR /&gt;&lt;BR /&gt;LPC_TIM0-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 0; // Start timer&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;3. Timer interrupt routine&lt;BR /&gt;&lt;BR /&gt;In this routine we need to read the value of the counter if the interrupt was generated by MR0 and then we need to clear the counter.&lt;BR /&gt;&lt;BR /&gt;inputFreq = LPC_TIM1-&amp;gt;TC; // Read the counter value&lt;BR /&gt;LPC_TIM1-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 1; // Reset the counter&lt;BR /&gt;&lt;BR style="color: #cccccc; background-color: #1c1c1c; font-size: 14.85px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;Soledad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2019 17:31:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953081#M37840</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2019-07-23T17:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768: How to Read Tach signal for DC fan</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953082#M37841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your help,&lt;/P&gt;&lt;P&gt;i will try your advice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2019 18:56:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953082#M37841</guid>
      <dc:creator>rsapple_007</dc:creator>
      <dc:date>2019-07-23T18:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768: How to Read Tach signal for DC fan</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953083#M37842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please see my code i have formed with your suggestion, but i unable to read external pulse (connected a TACH output fan), only internal timer value is able to read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help to resolve the issue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include &amp;lt;lpc17xx.h&amp;gt;&lt;BR /&gt;#include "uart.h"&lt;BR /&gt;#include "delay.h"&lt;/P&gt;&lt;P&gt;#define LED 0&lt;/P&gt;&lt;P&gt;volatile uint32_t Freq, Freq2;&lt;/P&gt;&lt;P&gt;int main (void) &lt;BR /&gt;{&lt;BR /&gt; UART0_Init(9600);&lt;BR /&gt; LPC_SC-&amp;gt;PCONP |= ( 1 &amp;lt;&amp;lt; 15 ); // power up GPIO&lt;BR /&gt; LPC_GPIO0-&amp;gt;FIODIR |= 1 &amp;lt;&amp;lt; LED; // puts P0.0 into output mode.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; //Initialization of the counter on P1.19 as CAP1.1&lt;BR /&gt; LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 2; //Power up TimerCounter1&lt;BR /&gt; LPC_TIM1-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 0; // Counter mode&lt;BR /&gt; LPC_TIM1-&amp;gt;CTCR |= 3; // Count on falling edges&lt;BR /&gt; LPC_TIM1-&amp;gt;CTCR |= 1 &amp;lt;&amp;lt; 2; // CAP1.1 is the input pin for which the input signal needs to be connected.&lt;BR /&gt; LPC_PINCON-&amp;gt;PINSEL3 |= ((1 &amp;lt;&amp;lt; 7) | (1 &amp;lt;&amp;lt; 6));; // Make P1.19 as CAP1.1&lt;BR /&gt; &lt;BR /&gt; LPC_TIM1-&amp;gt;TCR = 0x1; // Enable counter&lt;BR /&gt; &lt;BR /&gt; //Initialization of the timer which generates interrupt once in a second&lt;BR /&gt; LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 1; //Power up Timer0&lt;/P&gt;&lt;P&gt;LPC_TIM0-&amp;gt;MR0 = 12499999; // Assuming that clk freq = 100 MHz, this value is calculated to generate an interrupt once in a second.&lt;BR /&gt; LPC_TIM0-&amp;gt;MCR = 3; //interrupt and reset control&lt;BR /&gt; &lt;BR /&gt; NVIC_EnableIRQ(TIMER0_IRQn); //enable timer0 interrupt&lt;/P&gt;&lt;P&gt;LPC_TIM0-&amp;gt;TCR = 1; //enable Timer0&lt;BR /&gt; &lt;BR /&gt; while(1)&lt;BR /&gt; {&lt;BR /&gt; UART0_TxFloatNumber(Freq);&lt;BR /&gt; UART0_Printf("\n"); &lt;BR /&gt; DELAY_ms(500);&lt;BR /&gt; UART0_TxFloatNumber(Freq2);&lt;BR /&gt; UART0_Printf("\n"); &lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void TIMER0_IRQHandler (void)&lt;BR /&gt;{&lt;BR /&gt; LPC_TIM1-&amp;gt;TCR = 1;&lt;/P&gt;&lt;P&gt;if((LPC_TIM0-&amp;gt;IR &amp;amp; 0x01) == 0x01) // if MR0 interrupt&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;LPC_TIM0-&amp;gt;IR |= 1 &amp;lt;&amp;lt; 0; // Clear MR0 interrupt flag&lt;/P&gt;&lt;P&gt;Freq = LPC_TIM1-&amp;gt;TC; // Read the counter value&lt;BR /&gt;Freq2 = LPC_TIM0-&amp;gt;TC;&lt;/P&gt;&lt;P&gt;LPC_TIM1-&amp;gt;TCR |= 1 &amp;lt;&amp;lt; 1 ; // Reset the counter&lt;BR /&gt;LPC_GPIO0-&amp;gt;FIOPIN ^= (1&amp;lt;&amp;lt;LED); /* Toggle the LED (P0_0) */&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2019 09:04:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953083#M37842</guid>
      <dc:creator>rsapple_007</dc:creator>
      <dc:date>2019-08-01T09:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768: How to Read Tach signal for DC fan</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953084#M37843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check the following examples and tutorial. Let me know if this helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.ocfreaks.com/lpc1768-timer-input-capture-frequency-counter-tutorial/"&gt;http://www.ocfreaks.com/lpc1768-timer-input-capture-frequency-counter-tutorial/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Have a nice day!&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sol&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2019 16:22:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1768-How-to-Read-Tach-signal-for-DC-fan/m-p/953084#M37843</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2019-08-01T16:22:16Z</dc:date>
    </item>
  </channel>
</rss>

