<?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>S32K中的主题 Re: S32k342 Using Pit Ip to track milliseconds.</title>
    <link>https://community.nxp.com/t5/S32K/S32k342-Using-Pit-Ip-to-track-milliseconds/m-p/2034798#M45475</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/230291"&gt;@pb632146&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;To assist you more effectively, could you please clarify&amp;nbsp;the specific functionality you need to accomplish?&amp;nbsp;Are you looking for a delay function using the PIT, or are you trying to measure execution time?&lt;/P&gt;
&lt;P&gt;If you need to implement a blocking delay with the PIT, I suggest to follow the structure shown in the image below. It was tested for a 1 second delay and it works as expected:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RomanVR_0-1738014764334.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/321574i38FBFD6B4A2159C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RomanVR_0-1738014764334.png" alt="RomanVR_0-1738014764334.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;RomanVR_0-1738014764334.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The PIT is configured to interrupt every millisecond which updates the&amp;nbsp;"counter" variable.&amp;nbsp;The PitDelay function starts the timer and&amp;nbsp;continuously checks for the "counter" to reach the delay value.&amp;nbsp;Once&amp;nbsp;it does, the variable restarts, and the PIT is stopped.&lt;/P&gt;
&lt;P&gt;If you need to measure execution time, you can update a counter variable each time the PIT gets into the interruption. This will provide an accurate estimation of the running time of your program.&lt;/P&gt;
&lt;P&gt;Please let me know if this helps.&lt;/P&gt;
&lt;P&gt;- RomanVR.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jan 2025 21:54:24 GMT</pubDate>
    <dc:creator>RomanVR</dc:creator>
    <dc:date>2025-01-27T21:54:24Z</dc:date>
    <item>
      <title>S32k342 Using Pit Ip to track milliseconds.</title>
      <link>https://community.nxp.com/t5/S32K/S32k342-Using-Pit-Ip-to-track-milliseconds/m-p/2033589#M45416</link>
      <description>&lt;P&gt;This is a little bit more of a C question, but I am trying to emulate the functionality of the arduino millis() command which returns how long the program has been on in milliseconds. I figure to do that I would want to use the PIT_IP to increment a global variable every millisecond, but I am having the issue that for a simple delay function where I call a function to return the value to set the starting point like I would with OsIf_GetCounter, the value will update when the timer does, rather than holding the current value of the timer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a result the delay function I want to make does not work as well as other functions I have that want to use the current value as a timestamp in a similar function OsIf_GetCounter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pb632146_0-1737692102722.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/321166iDF5B9025C7DE8D6A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pb632146_0-1737692102722.png" alt="pb632146_0-1737692102722.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;pb632146_0-1737692102722.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The interrupt works, I just do not know how to disconnect the variable's value from directly referencing the global.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pb632146_1-1737692160853.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/321167i2D6DE174A7970782/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pb632146_1-1737692160853.png" alt="pb632146_1-1737692160853.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;pb632146_1-1737692160853.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pb632146_2-1737692167414.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/321168iDF85D9D39BA685CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pb632146_2-1737692167414.png" alt="pb632146_2-1737692167414.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;pb632146_2-1737692167414.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Are there alternatives to this? I want to avoid OsIf_GetCounter as it only uses 32 bits at the real clock speed which would overflow too often for my needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 04:18:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32k342-Using-Pit-Ip-to-track-milliseconds/m-p/2033589#M45416</guid>
      <dc:creator>pb632146</dc:creator>
      <dc:date>2025-01-24T04:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: S32k342 Using Pit Ip to track milliseconds.</title>
      <link>https://community.nxp.com/t5/S32K/S32k342-Using-Pit-Ip-to-track-milliseconds/m-p/2034798#M45475</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/230291"&gt;@pb632146&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;To assist you more effectively, could you please clarify&amp;nbsp;the specific functionality you need to accomplish?&amp;nbsp;Are you looking for a delay function using the PIT, or are you trying to measure execution time?&lt;/P&gt;
&lt;P&gt;If you need to implement a blocking delay with the PIT, I suggest to follow the structure shown in the image below. It was tested for a 1 second delay and it works as expected:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RomanVR_0-1738014764334.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/321574i38FBFD6B4A2159C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RomanVR_0-1738014764334.png" alt="RomanVR_0-1738014764334.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;RomanVR_0-1738014764334.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The PIT is configured to interrupt every millisecond which updates the&amp;nbsp;"counter" variable.&amp;nbsp;The PitDelay function starts the timer and&amp;nbsp;continuously checks for the "counter" to reach the delay value.&amp;nbsp;Once&amp;nbsp;it does, the variable restarts, and the PIT is stopped.&lt;/P&gt;
&lt;P&gt;If you need to measure execution time, you can update a counter variable each time the PIT gets into the interruption. This will provide an accurate estimation of the running time of your program.&lt;/P&gt;
&lt;P&gt;Please let me know if this helps.&lt;/P&gt;
&lt;P&gt;- RomanVR.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 21:54:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32k342-Using-Pit-Ip-to-track-milliseconds/m-p/2034798#M45475</guid>
      <dc:creator>RomanVR</dc:creator>
      <dc:date>2025-01-27T21:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: S32k342 Using Pit Ip to track milliseconds.</title>
      <link>https://community.nxp.com/t5/S32K/S32k342-Using-Pit-Ip-to-track-milliseconds/m-p/2034867#M45477</link>
      <description>Turning the PIT timer off and on as a delay function is interesting, I will keep it in my mind for the future.&lt;BR /&gt;&lt;BR /&gt;Strangely the issues seemed to be as a result of the debugger/compiler optimizations, as the issue would change from updating the startTime variable when the global was updated to not updating the global at all with the interrupt presumably not triggering.&lt;BR /&gt;&lt;BR /&gt;But the end goal was for using the counter for timestamping to keep track of on/off times rather than delaying and it seems to work correctly in that situation.</description>
      <pubDate>Tue, 28 Jan 2025 03:44:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32k342-Using-Pit-Ip-to-track-milliseconds/m-p/2034867#M45477</guid>
      <dc:creator>pb632146</dc:creator>
      <dc:date>2025-01-28T03:44:02Z</dc:date>
    </item>
  </channel>
</rss>

