<?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 GPT microseconds counter 3x in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/GPT-microseconds-counter-3x/m-p/1366611#M182616</link>
    <description>&lt;P&gt;Dear NXP,&lt;/P&gt;&lt;P&gt;I have found to get the right microseconds (us) then I need to multiply by 3 the return of GPT_GetCurrentTimerCount()&lt;/P&gt;&lt;P&gt;Is this expected?&lt;/P&gt;&lt;P&gt;Example: evkmimxtrt1160_gpt_timer_cm7&lt;/P&gt;&lt;P&gt;Creates a 1 second interrupt&lt;/P&gt;&lt;P&gt;If I measure the difference between each interrupt&lt;/P&gt;&lt;P&gt;uint32_t us_count1(void)&lt;BR /&gt;{&lt;BR /&gt;return GPT_GetCurrentTimerCount(GPT1);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;gpt1_previous = gpt1_current;&lt;BR /&gt;gpt1_current = 3 * us_count1(); // &amp;lt;---- HERE multiply by 3&lt;BR /&gt;gpt1_difference = gpt1_current - gpt1_previous;&lt;/P&gt;&lt;P&gt;PRINTF("GPT1 %d\n\r",gpt1_difference);&lt;/P&gt;&lt;P&gt;Then I get&lt;BR /&gt;GPT1 981396&amp;nbsp;&lt;/P&gt;&lt;P&gt;981396us =(approx) 0.98 seconds&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just wanted to know if this is documented somewhere?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 10:11:25 GMT</pubDate>
    <dc:creator>neo2</dc:creator>
    <dc:date>2021-11-04T10:11:25Z</dc:date>
    <item>
      <title>GPT microseconds counter 3x</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/GPT-microseconds-counter-3x/m-p/1366611#M182616</link>
      <description>&lt;P&gt;Dear NXP,&lt;/P&gt;&lt;P&gt;I have found to get the right microseconds (us) then I need to multiply by 3 the return of GPT_GetCurrentTimerCount()&lt;/P&gt;&lt;P&gt;Is this expected?&lt;/P&gt;&lt;P&gt;Example: evkmimxtrt1160_gpt_timer_cm7&lt;/P&gt;&lt;P&gt;Creates a 1 second interrupt&lt;/P&gt;&lt;P&gt;If I measure the difference between each interrupt&lt;/P&gt;&lt;P&gt;uint32_t us_count1(void)&lt;BR /&gt;{&lt;BR /&gt;return GPT_GetCurrentTimerCount(GPT1);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;gpt1_previous = gpt1_current;&lt;BR /&gt;gpt1_current = 3 * us_count1(); // &amp;lt;---- HERE multiply by 3&lt;BR /&gt;gpt1_difference = gpt1_current - gpt1_previous;&lt;/P&gt;&lt;P&gt;PRINTF("GPT1 %d\n\r",gpt1_difference);&lt;/P&gt;&lt;P&gt;Then I get&lt;BR /&gt;GPT1 981396&amp;nbsp;&lt;/P&gt;&lt;P&gt;981396us =(approx) 0.98 seconds&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just wanted to know if this is documented somewhere?&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 10:11:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/GPT-microseconds-counter-3x/m-p/1366611#M182616</guid>
      <dc:creator>neo2</dc:creator>
      <dc:date>2021-11-04T10:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: GPT microseconds counter 3x</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/GPT-microseconds-counter-3x/m-p/1367816#M182747</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/191554"&gt;@neo2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;3X is not the fixed one, it is determined by your clock divider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Let me know, why you need to divide 3, please check the code:&lt;/P&gt;
&lt;P&gt;/* Divide GPT clock source frequency by 3 inside GPT module */&lt;BR /&gt;GPT_SetClockDivider(EXAMPLE_GPT, 3);&lt;/P&gt;
&lt;P&gt;/* Get GPT clock frequency */&lt;BR /&gt;gptFreq = EXAMPLE_GPT_CLK_FREQ;&lt;/P&gt;
&lt;P&gt;/* GPT frequency is divided by 3 inside module */&lt;BR /&gt;gptFreq /= 3;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kerryzhou_0-1636362864034.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/161497i9DC776BF617A300F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kerryzhou_0-1636362864034.png" alt="kerryzhou_0-1636362864034.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, your register divide 3, then your clock need to divide 3.&lt;/P&gt;
&lt;P&gt;Wish it helps you!&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Kerry&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 09:38:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/GPT-microseconds-counter-3x/m-p/1367816#M182747</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2021-11-08T09:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: GPT microseconds counter 3x</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/GPT-microseconds-counter-3x/m-p/1383954#M184177</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/60336"&gt;@kerryzhou&lt;/a&gt;&amp;nbsp;I solved this issue, I want to share what I found.&lt;/P&gt;&lt;P&gt;Original code :&amp;nbsp; GPT_SetClockSource(GPT1, kGPT_ClockSource_Osc);&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It was not obvious about what speed the OSC clock was running. Which is why it confused me why 3x - it seems this was a "red herring" or I made the wrong assumption about what frequency the OSC clock was running.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here a more robust solution:&lt;/P&gt;&lt;P&gt;Then I changed this to&amp;nbsp; GPT_SetClockSource(GPT1, kGPT_ClockSource_Periph);&amp;nbsp;&lt;BR /&gt;Seems like some documents say this is 150MHz but actually I found something different.&lt;/P&gt;&lt;P&gt;At least on the RT1160 board I have it seems this clock source is actually 24MHz&lt;/P&gt;&lt;P&gt;Since then I divided by 24&lt;BR /&gt;GPT_SetClockDivider(GPT1, 24);&lt;BR /&gt;Which gives 1MHz or 1us&lt;BR /&gt;&lt;BR /&gt;I was able to confirm this because I setup GPT2 to generate an interrupt at 1 second intervals.&lt;BR /&gt;I could see the log output on the terminal correlated to 1 second.&lt;/P&gt;&lt;P&gt;Then I used the GPT1 counter to confirm e.g. GPT_GetCurrentTimerCount(GPT1)&amp;nbsp;&lt;/P&gt;&lt;P&gt;The elapsed time between the previous interrupt and the current interrupt.&lt;/P&gt;&lt;P&gt;So the number of ticks of my GPT1 @1us was of course approximately 1,000,000 = 1,000,000us = 1 second&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 09:48:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/GPT-microseconds-counter-3x/m-p/1383954#M184177</guid>
      <dc:creator>neo2</dc:creator>
      <dc:date>2021-12-09T09:48:26Z</dc:date>
    </item>
  </channel>
</rss>

