<?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のトピックLPC11C24 external clock counter mode</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11C24-external-clock-counter-mode/m-p/594965#M22731</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lerlacher on Sat May 24 10:30:20 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to capture an encoder signal (a light barrier) using the timer module in counting mode with external clock on the capture pin.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Here is my code (formatted version: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fpastie.org%2Fprivate%2Fkdic1jfdhge0pnwfv6ola%29%3A" rel="nofollow" target="_blank"&gt;http://pastie.org/private/kdic1jfdhge0pnwfv6ola):&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void eli_light_init() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//configure capture input&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_IOCON-&amp;gt;R_PIO1_0 &amp;amp;= ~0x1F;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_IOCON-&amp;gt;R_PIO1_0 |= (0x2 &amp;lt;&amp;lt; 3) | 0x3;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//enable clock&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= (0x1 &amp;lt;&amp;lt; 10);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//configure timer block&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;PR = 0x0;&amp;nbsp; // disable Prescaler&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;MCR&amp;amp;= ~(0xFFF);// disable matching&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;EMR&amp;amp;= ~(0xFFF);// disable match outputs&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;CCR&amp;amp;= ~(0x3);// disable capture copy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;CTCR&amp;amp;= ~(0xF);// clear count control&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;CTCR|=&amp;nbsp; (0x1);// set count control to capture rising edge&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//reset value of counter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;TC = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//reset and enable timer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;TCR |= 0x3;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;TCR &amp;amp;= ~(0x2);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;uint32_t eli_light_read(uint8_t reset) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;uint32_t value = LPC_TMR32B1-&amp;gt;TC;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// reset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (reset) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;TC = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;return value;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am testing this by just poking the PIO1_0 pin with a multimeter tip that is connected to VDD and a breakpoint with the condition "value &amp;gt; 0" in the read function. I have verified that the init function is called and that the read function is regularly called as well. The breakpoint never fires.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Am I setting up the control registers correctly? Is it kosher to enable the pulldown (is the pulldown even connected when the capture function is configured?) on the capture pin? Anything else?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is muchly appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 19:23:13 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T19:23:13Z</dc:date>
    <item>
      <title>LPC11C24 external clock counter mode</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11C24-external-clock-counter-mode/m-p/594965#M22731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lerlacher on Sat May 24 10:30:20 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to capture an encoder signal (a light barrier) using the timer module in counting mode with external clock on the capture pin.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;Here is my code (formatted version: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fpastie.org%2Fprivate%2Fkdic1jfdhge0pnwfv6ola%29%3A" rel="nofollow" target="_blank"&gt;http://pastie.org/private/kdic1jfdhge0pnwfv6ola):&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void eli_light_init() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//configure capture input&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_IOCON-&amp;gt;R_PIO1_0 &amp;amp;= ~0x1F;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_IOCON-&amp;gt;R_PIO1_0 |= (0x2 &amp;lt;&amp;lt; 3) | 0x3;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//enable clock&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= (0x1 &amp;lt;&amp;lt; 10);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//configure timer block&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;PR = 0x0;&amp;nbsp; // disable Prescaler&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;MCR&amp;amp;= ~(0xFFF);// disable matching&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;EMR&amp;amp;= ~(0xFFF);// disable match outputs&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;CCR&amp;amp;= ~(0x3);// disable capture copy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;CTCR&amp;amp;= ~(0xF);// clear count control&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;CTCR|=&amp;nbsp; (0x1);// set count control to capture rising edge&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//reset value of counter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;TC = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//reset and enable timer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;TCR |= 0x3;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;TCR &amp;amp;= ~(0x2);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;uint32_t eli_light_read(uint8_t reset) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;uint32_t value = LPC_TMR32B1-&amp;gt;TC;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// reset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (reset) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_TMR32B1-&amp;gt;TC = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;return value;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am testing this by just poking the PIO1_0 pin with a multimeter tip that is connected to VDD and a breakpoint with the condition "value &amp;gt; 0" in the read function. I have verified that the init function is called and that the read function is regularly called as well. The breakpoint never fires.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Am I setting up the control registers correctly? Is it kosher to enable the pulldown (is the pulldown even connected when the capture function is configured?) on the capture pin? Anything else?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is muchly appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:23:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11C24-external-clock-counter-mode/m-p/594965#M22731</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: LPC11C24 external clock counter mode</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11C24-external-clock-counter-mode/m-p/594966#M22732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lerlacher on Sat May 24 12:03:38 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course right after posting I found the problem, my code enables the pullup resistor and not the pulldown. It has to be like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_IOCON-&amp;gt;R_PIO1_0 &amp;amp;= ~0x1F;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_IOCON-&amp;gt;R_PIO1_0 |= (0x1 &amp;lt;&amp;lt; 3) | 0x3;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:23:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC11C24-external-clock-counter-mode/m-p/594966#M22732</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:23:14Z</dc:date>
    </item>
  </channel>
</rss>

