<?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: LPC54005 CTIMER0 PIO1_1 as counter in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/1575811#M51143</link>
    <description>hi jeremyzhou&lt;BR /&gt;seem like you didn't answer this question.&lt;BR /&gt;eg, LPC55S69 P1_9, in BOARD_InitPins(), I configure as 'IOCON_PIO_FUNC3', the CTIMER CAP function still can not work.&lt;BR /&gt;could you show this question a demo?&lt;BR /&gt;thanks.</description>
    <pubDate>Fri, 30 Dec 2022 09:40:48 GMT</pubDate>
    <dc:creator>qingyunliu</dc:creator>
    <dc:date>2022-12-30T09:40:48Z</dc:date>
    <item>
      <title>LPC54005 CTIMER0 PIO1_1 as counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/951750#M37817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On my custom LPC54005 board, I am trying to use CTimer0 as a counter with PIO1_1 as the clock input.&lt;/P&gt;&lt;P&gt;(CT0_CAP3 — Capture 3 input to Timer 0). I have a 1Hz square wave connected to the pin. This signal is clean and recognized by the MCU. When using the interrupt as we do for counting slow signals, I see an exact count so I think the hardware is OK. When I try using the hardware CTIMER0 as a counter for higher frequency signals, retrieving the TC every minute and then immediately clearing the count, I get extremely large TC values ~ TC:10269 that are also not stable. I also tried reading the TC and using the difference from the last reading with same problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;It looks like the timer is not routing PIO1_1 as its clock. I just want to use CTIMER0 as a hardware counter.&lt;/P&gt;&lt;P&gt;I added the FSL_FEATURE_CTIMER_HAS_CCR_CAP3=1 in my Symbols.&lt;/P&gt;&lt;P&gt;In the debugger using MCUXpresso I can not read the TC value but other registers are available:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/82199i8906BA60257424DC/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/82270i688DAF3B1EDE1937/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also attached my code snippets that initialize CTIMER0 and read it periodically.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2019 09:12:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/951750#M37817</guid>
      <dc:creator>kiryat8</dc:creator>
      <dc:date>2019-07-22T09:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54005 CTIMER0 PIO1_1 as counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/951751#M37818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" data-content-finding="Community" data-userid="290018" data-username="kiryat8" href="https://community.nxp.com/people/kiryat8"&gt;David Kaplan&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Thank you for your interest in NXP Semiconductor products and &lt;BR /&gt;for the opportunity to serve you.&lt;BR /&gt;I'd like to suggest you implement a match feature of the Ctimer to toggle CTIMERn_MAT pin after the external clock has already driven the Ctimer module. It's able to be used to validate whether the Ctimer counter runs well.&lt;BR /&gt;In further, there's a simple_match demo in the SDK library for you to refer to.&lt;BR /&gt;So please give a try.&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2019 03:03:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/951751#M37818</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2019-07-23T03:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54005 CTIMER0 PIO1_1 as counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/951752#M37819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I do not understand how the 4 SDK examples can help me. I looked at all four and the CTimer is setup as a timer and not a counter. I need a 32 bit hardware counter from an external pin. Maybe this cannot be done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the four programs, GetDefaultConfig is called to set the defaults before changing anything.&lt;/P&gt;&lt;P&gt;In all of the programs the config.mode is not changed to one of the edge modes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*! @brief List of Timer modes */&lt;BR /&gt;typedef enum _ctimer_timer_mode&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; kCTIMER_TimerMode = 0U,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* TC is incremented every rising APB bus clock edge */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; kCTIMER_IncreaseOnRiseEdge, /* TC is incremented on rising edge of input signal */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; kCTIMER_IncreaseOnFallEdge, /* TC is incremented on falling edge of input signal */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; kCTIMER_IncreaseOnBothEdge&amp;nbsp; /* TC is incremented on both edges of input signal */&lt;BR /&gt;} ctimer_timer_mode_t;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void CTIMER_GetDefaultConfig(ctimer_config_t *config)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert(config);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initializes the configure structure to zero. */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; memset(config, 0, sizeof(*config));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Run as a timer */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; config-&amp;gt;mode = kCTIMER_TimerMode;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This field is ignored when mode is timer */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; config-&amp;gt;input = kCTIMER_Capture_0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Timer counter is incremented on every APB bus clock */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; config-&amp;gt;prescale = 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;simple_match.c&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CTIMER_GetDefaultConfig(&amp;amp;config);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CTIMER_Init(CTIMER, &amp;amp;config);&lt;BR /&gt;simple_match_interrupt.c&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CTIMER_GetDefaultConfig(&amp;amp;config);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CTIMER_Init(CTIMER, &amp;amp;config);&lt;BR /&gt;simple_pwm.c&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CTIMER_GetDefaultConfig(&amp;amp;config);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; timerClock = srcClock_Hz / (config.prescale + 1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CTIMER_Init(CTIMER, &amp;amp;config);&lt;BR /&gt;simple_pwm_interrupt.c&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CTIMER_GetDefaultConfig(&amp;amp;config);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; timerClock = srcClock_Hz / (config.prescale + 1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CTIMER_Init(CTIMER, &amp;amp;config);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jul 2019 12:31:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/951752#M37819</guid>
      <dc:creator>kiryat8</dc:creator>
      <dc:date>2019-07-24T12:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54005 CTIMER0 PIO1_1 as counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/951753#M37820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" data-containerid="-1" data-containertype="-1" data-content-finding="Community" data-objectid="290018" data-objecttype="3" href="https://community.nxp.com/people/kiryat8" rel="nofollow noopener noreferrer" target="_blank"&gt;David Kaplan&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;BR /&gt;Please modify CTIMER_GetDefaultConfig to enable the Ctimer to be clocked by the CAP input, just like the below shows.&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;CTIMER_GetDefaultConfig&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ctimer_config_t &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;config&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;assert&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;config&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

    &lt;SPAN class="comment token"&gt;/* Initializes the configure structure to zero. */&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;memset&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;config&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;sizeof&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;config&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

    &lt;SPAN class="comment token"&gt;/* Run as a timer */&lt;/SPAN&gt;
    config&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;mode &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;  kCTIMER_IncreaseOnRiseEdge&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;/* This field is ignored when mode is timer */&lt;/SPAN&gt;
    config&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;input &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; kCTIMER_Capture_3&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;/* Timer counter is incremented on every APB bus clock */&lt;/SPAN&gt;
    config&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;prescale &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note that, you also need to configure the CAP input pin the BOARD_InitPins() function.&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jul 2019 05:00:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/951753#M37820</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2019-07-25T05:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54005 CTIMER0 PIO1_1 as counter</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/1575811#M51143</link>
      <description>hi jeremyzhou&lt;BR /&gt;seem like you didn't answer this question.&lt;BR /&gt;eg, LPC55S69 P1_9, in BOARD_InitPins(), I configure as 'IOCON_PIO_FUNC3', the CTIMER CAP function still can not work.&lt;BR /&gt;could you show this question a demo?&lt;BR /&gt;thanks.</description>
      <pubDate>Fri, 30 Dec 2022 09:40:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54005-CTIMER0-PIO1-1-as-counter/m-p/1575811#M51143</guid>
      <dc:creator>qingyunliu</dc:creator>
      <dc:date>2022-12-30T09:40:48Z</dc:date>
    </item>
  </channel>
</rss>

