<?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 MKL28 input to TPM pulse counter example or application note in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949517#M54683</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to setup &amp;amp; use the Timer Pulse Module (TPM) of the MKL28 as a Pulse Counter to count input square waveform from a flow meter.&lt;/P&gt;&lt;P&gt;The SDK example do not exactly do this configuration, except some dual or single edge detection / capture that does not trigger the TPM internal pulse counting to log pulse counts.&lt;/P&gt;&lt;P&gt;I have read the Reference Manual regarding the matter but it would be nice to see an example that shows the steps in configuring the module as such.&lt;/P&gt;&lt;P&gt;Has anybody tried to configure the MKL28's TPM&amp;nbsp; in Pulse Counter mode?&lt;/P&gt;&lt;P&gt;And/or does anyone seen any mkl28/kinetis/TPM application note document on this?&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P&gt;MI&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 21 Jul 2019 05:53:16 GMT</pubDate>
    <dc:creator>mci</dc:creator>
    <dc:date>2019-07-21T05:53:16Z</dc:date>
    <item>
      <title>MKL28 input to TPM pulse counter example or application note</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949517#M54683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to setup &amp;amp; use the Timer Pulse Module (TPM) of the MKL28 as a Pulse Counter to count input square waveform from a flow meter.&lt;/P&gt;&lt;P&gt;The SDK example do not exactly do this configuration, except some dual or single edge detection / capture that does not trigger the TPM internal pulse counting to log pulse counts.&lt;/P&gt;&lt;P&gt;I have read the Reference Manual regarding the matter but it would be nice to see an example that shows the steps in configuring the module as such.&lt;/P&gt;&lt;P&gt;Has anybody tried to configure the MKL28's TPM&amp;nbsp; in Pulse Counter mode?&lt;/P&gt;&lt;P&gt;And/or does anyone seen any mkl28/kinetis/TPM application note document on this?&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P&gt;MI&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Jul 2019 05:53:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949517#M54683</guid>
      <dc:creator>mci</dc:creator>
      <dc:date>2019-07-21T05:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: MKL28 input to TPM pulse counter example or application note</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949518#M54684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi MI,&lt;/P&gt;&lt;P&gt;I am not sure if you can accept the use of the LPTMR module as a pulse counter.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="LPTMR pulse counter.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/82523iC41922650EE222AE/image-size/large?v=v2&amp;amp;px=999" role="button" title="LPTMR pulse counter.png" alt="LPTMR pulse counter.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If TPM module is must, then select External Clock as TPM clock source.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="TPM_EXTCLK.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/82574iD7D4A36B6A483F47/image-size/large?v=v2&amp;amp;px=999" role="button" title="TPM_EXTCLK.png" alt="TPM_EXTCLK.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;P style="min- padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2019 01:52:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949518#M54684</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2019-07-22T01:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: MKL28 input to TPM pulse counter example or application note</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949519#M54685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are right that I should go back to my original plan - use design plan, PTC5 (LPTMR0_ALT2) to connect flow meter input.&lt;/P&gt;&lt;P&gt;I thought I could use TPM to manually code from scratch something that will simulate a pulse counter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That problem which confused me late Friday while researching further &amp;amp; looking at SDK examples, there is NO PULSE COUNTER example using LPTMR module.&amp;nbsp;&amp;nbsp; There's only TPM&amp;nbsp;pulse edge detection examples so I thought to ask about that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the one example lptmr on SDK has setup PTE29 as ALT0 "CMP0_IN5" is assigned as output toggle,&amp;nbsp;&amp;nbsp;connected to RED RGB LED on FRDM-KL28Z schematic diagram.&amp;nbsp;&amp;nbsp; So this is output mode.&amp;nbsp;&amp;nbsp; I need example of square wave (flow meter) input pulses mode for LPTMR to detect the pulses &amp;amp;&amp;nbsp;save in its counter so I can check the counter say every minute, to measure how much water has flowed etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know any example configuration of PTC5 or I'll just dive in &amp;amp; figure that out myself based on what I think I understand from the KL28Z reference manual?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MI&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2019 15:34:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949519#M54685</guid>
      <dc:creator>mci</dc:creator>
      <dc:date>2019-07-22T15:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: MKL28 input to TPM pulse counter example or application note</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949520#M54686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I dove in &amp;amp; tried to adapt KL28Z SDK lptmr project &amp;amp; changed it from being LPTMR timer counter mode to be in pulse counter mode taking input pulses from PTC5 setup as LPTMR0_ALT2 input function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran this modified code but the CNR register count is always 0 even when I turn on the flowmeter simulator gadget that is attached to PTC5 which is generating square wave pulses in different duty cycles which should trigger pulse counts.&lt;/P&gt;&lt;P&gt;Original code sets up an lptmr timer to trigger interrupt every second &amp;amp; display a declared timer variable;&amp;nbsp; NOT from lptmr CNR counter register.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you have a chance, kindly review this code snippets &amp;amp; see what I'm missing or where I am wrong.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE:&amp;nbsp; I am using my custom prototype board with the KL28Z as its MCU.&lt;/P&gt;&lt;P&gt;I setup a millisecond TPM timer such that&amp;nbsp;every 30 seconds (half a minute), the system will dump a string on debug console&amp;nbsp;that displays what is read from the CNR (lptmr count register), using function call:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fsl_lptmr.c/LPTMR_GetCurrentTimerCount(LPTMR0);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // correctly writes 0 to CNR first before reading...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OUTPUT:&amp;nbsp;&amp;nbsp; (even after I turn on the flowmeter pulse generator, counter remains zero.)&lt;/P&gt;&lt;P&gt;Low Power Timer Pulse Counter 7/22/19&lt;BR /&gt;Pulse Count after half a minute = 0&lt;BR /&gt;Pulse Count after half a minute = 0&lt;BR /&gt;Pulse Count after half a minute = 0&lt;BR /&gt;Pulse Count after half a minute = 0&lt;BR /&gt;Pulse Count after half a minute = 0&lt;BR /&gt;Pulse Count after half a minute = 0&lt;BR /&gt;Pulse Count after half a minute = 0&lt;BR /&gt;Pulse Count after half a minute = 0&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;*************************************************&lt;/P&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;P&gt;*****pinmux.c/BOARD_InitPins();&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #7f0055; font-size: small; "&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;BOARD_InitPins&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small; "&gt;void&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Clock Gate Control: 0x01u */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; CLOCK_EnableClock(&lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kCLOCK_PortA&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Clock Gate Control: 0x01u */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; CLOCK_EnableClock(&lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kCLOCK_PortC&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Clock Gate Control: 0x01u */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; CLOCK_EnableClock(&lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kCLOCK_PortE&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// v3 5/30/19 &lt;SPAN style="text-decoration: underline;"&gt;mi&lt;/SPAN&gt; ELMNT debug console&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// PORTA1 (pin 35) is configured as LPUART0_RX&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; PORT_SetPinMux(PORTA, 1U, &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kPORT_MuxAlt2&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// PORTA2 (pin 36) is configured as LPUART0_TX&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; PORT_SetPinMux(PORTA, 2U, &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kPORT_MuxAlt2&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// PORTC5 (pin 77) is configured as PTC5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; PORT_SetPinMux(PORTC, 5U, &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kPORT_MuxAlt3&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// v1 7/22/19 &lt;SPAN style="text-decoration: underline;"&gt;mi&lt;/SPAN&gt; LPTMR_ALT2 pulse counter input&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// PORTE26 (pin 33) is configured as PTE26&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; PORT_SetPinMux(PORTE, 26U, &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kPORT_MuxAsGpio&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;); &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// v1 7/22/19 &lt;SPAN style="text-decoration: underline;"&gt;mi&lt;/SPAN&gt; Filter RGB Green to blink off/on&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****** lptmr.c&amp;nbsp; -&amp;nbsp;&amp;nbsp; NOTE:&amp;nbsp; I COMMENTED OUT SetTimer...() because the pulse counter flowmeter external input should be triggering timer count in this code modification.&amp;nbsp;&amp;nbsp;&amp;nbsp; Am I right to comment out those lines?&lt;/P&gt;&lt;P&gt;main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;. . .&lt;/P&gt;&lt;P&gt;LPTMR_GetDefaultConfig(&amp;amp;lptmrConfig);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Initialize the LPTMR */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;LPTMR_Init(DEMO_LPTMR_BASE, &amp;amp;lptmrConfig);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;* Set timer period.&lt;/P&gt;&lt;P&gt;* Note : the parameter "ticks" of LPTMR_SetTimerPeriod should be equal or greater than 1.&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;// LPTMR_SetTimerPeriod(DEMO_LPTMR_BASE, USEC_TO_COUNT(LPTMR_USEC_COUNT, LPTMR_SOURCE_CLOCK));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Enable timer interrupt */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;// LPTMR_EnableInterrupts(DEMO_LPTMR_BASE, kLPTMR_TimerInterruptEnable);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Enable at the NVIC */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;EnableIRQ(DEMO_LPTMR_IRQn);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// should I enable this code to execute? or comment it out too?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; PRINTF(&lt;/SPAN&gt;&lt;SPAN style="color: #2a00ff; font-size: small; "&gt;"Low Power Timer Pulse Counter 7/22/19\r\n"&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt;. . .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt;The 3rd code snippet at the end is the lptmr initialization configuration.&amp;nbsp;&amp;nbsp;&amp;nbsp; Did I do it right?&amp;nbsp;&amp;nbsp;&amp;nbsp; And note:&amp;nbsp;&amp;nbsp; I'm bypassing both prescaler &amp;amp; also glitch filter in this pulse counter mode.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt;***** fsl_lptmr.c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IS SETUP HERE CORRECT ???&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #7f0055; font-size: small; "&gt;&lt;STRONG&gt;void&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;LPTMR_GetDefaultConfig&lt;/STRONG&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #005032; font-size: small; "&gt;lptmr_config_t&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; *config)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;assert(config);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Initializes the configure structure to zero. */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #642880; font-size: small; "&gt;memset&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;(config, 0, &lt;/SPAN&gt;&lt;STRONG style=": ; color: #7f0055; font-size: small; "&gt;sizeof&lt;/STRONG&gt;&lt;SPAN style="font-size: small;"&gt;(*config));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// v1 7/22/19 &lt;SPAN style="text-decoration: underline;"&gt;mi&lt;/SPAN&gt; modified to behave in pulse counter mode&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Use time counter mode */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; config-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small; "&gt;timerMode&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; = &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kLPTMR_TimerModePulseCounter&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// set as pulse counter&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Use input 0 as source in pulse counter mode */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; config-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small; "&gt;pinSelect&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; = &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kLPTMR_PinSelectInput_2&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// input 2, LPTMR0_ALT2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Pulse input pin polarity is active-high */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; config-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small; "&gt;pinPolarity&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; = &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kLPTMR_PinPolarityActiveHigh&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Counter CNR resets on overflow */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; config-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small; "&gt;enableFreeRunning&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; = true; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// reset on CNR overflow?&amp;nbsp;&amp;nbsp; instead of when CNR = CMR&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Bypass the &lt;SPAN style="text-decoration: underline;"&gt;prescaler&lt;/SPAN&gt; */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; config-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small; "&gt;bypassPrescaler&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; = true;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// yes, bypass &lt;SPAN style="text-decoration: underline;"&gt;prescaler&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* LPTMR clock source */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; config-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small; "&gt;prescalerClockSource&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; = &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kLPTMR_PrescalerClock_2&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// LPTMR0_ALT2?&amp;nbsp; or don't care&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;/* Divide the &lt;SPAN style="text-decoration: underline;"&gt;prescaler&lt;/SPAN&gt; clock by 2 */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; config-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000c0; font-size: small; "&gt;value&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; = &lt;/SPAN&gt;&lt;EM style=": ; color: #0000c0; font-size: small; "&gt;kLPTMR_Prescale_Glitch_0&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small; "&gt;// don't care?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any questions or what other code you want me to post here for clarity?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2019 00:07:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949520#M54686</guid>
      <dc:creator>mci</dc:creator>
      <dc:date>2019-07-23T00:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: MKL28 input to TPM pulse counter example or application note</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949521#M54687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just letting you guys know that I was able to make it work today.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly, to confirm if the input flow meter is generating pulses, I programmed PTC5 port pin as regular GPIO with interrupt trigger on falling edge, so the code is simply incrementing the counter everytime falling edge is detected.&amp;nbsp; I accumulated edge count &amp;amp; displayed amount every minute.&amp;nbsp; That works nice &amp;amp; simple but I can't settle with that because this product needs to do many other operations (including the touch button sensing) etc.&amp;nbsp;&amp;nbsp; I need a module that will do this exactly as its job in INTERNAL REGISTER (not external variable).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After proving the flowmeter works, I went back to LPTMR in pulse counter mode.&amp;nbsp;&amp;nbsp; I&amp;nbsp;disabled even more of the above quoted code in main()&amp;nbsp;by commenting out everything that pertains to "timer counter" mode as opposed to "pulse counter" mode.&amp;nbsp;&amp;nbsp; The deal that made LPTMR module finally started counting was simply TO ENABLE it.&amp;nbsp;&amp;nbsp;&amp;nbsp; There was no function call to enable it so I had to create one which I called after the LPTMR configuration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I figured these from re-reading the reference manual again &amp;amp; some general LPTMR presentation document I found from NXP/Freescale.&amp;nbsp;&amp;nbsp; None of these stated a pulse counter mode example.&amp;nbsp;&amp;nbsp; Put what struck me was the statement, "enable LPTMR as the last step".&amp;nbsp;&amp;nbsp; So I figured out how to enable it &amp;amp; created a function call &amp;amp; called it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So finally pulse count was no longer 0.&amp;nbsp;&amp;nbsp; It started counting whenever the flowmeter simulator is on. At the minimum, it pulses 365 every minute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for those who tried to help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if anyone has any comments or questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MI&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2019 22:44:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949521#M54687</guid>
      <dc:creator>mci</dc:creator>
      <dc:date>2019-07-23T22:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: MKL28 input to TPM pulse counter example or application note</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949522#M54688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It sounds as though the reference is using the CMP as LPTMR counter trigger. This is because the ALT0 input function is connected internally to the CMP_OUT. For this to work (which allows adjustable voltage thresholds to be set) the CMP input was used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To connect to PTC5 the only change is to select ALT2 instead of ALT0 in the LPTMR configuration and to configure PTC5 as its LPTMR_ALT2 function (which can be shared between LPTMR0 and LPTMR1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Complete Kinetis solutions for professional needs, training and support: &lt;A href="http://www.utasker.com/kinetis.html" target="test_blank"&gt;http://www.utasker.com/kinetis.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Kinetis KL28:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL28Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL28Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;SPAN style="color: #000080;"&gt;&lt;EM&gt;uTasker: supporting &amp;gt;1'000 registered Kinetis users get products faster and cheaper to market&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;EM&gt;Request Free emergency remote desk-top consulting at &lt;A href="http://www.utasker.com/services.html" target="test_blank"&gt;http://www.utasker.com/services.html&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Open Source version at &lt;A href="https://github.com/uTasker/uTasker-Kinetis" target="test_blank"&gt;https://github.com/uTasker/uTasker-Kinetis&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2019 22:32:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL28-input-to-TPM-pulse-counter-example-or-application-note/m-p/949522#M54688</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-07-29T22:32:42Z</dc:date>
    </item>
  </channel>
</rss>

