<?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中的主题 s32k144 LPIT timer period problem</title>
    <link>https://community.nxp.com/t5/S32K/s32k144-LPIT-timer-period-problem/m-p/2083311#M47924</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;My goal is to generate a waveform with LPIT of S32K144, the LPIT initial and interrupt handler as below:&lt;/P&gt;&lt;P&gt;//-------------------------------------------------------------&lt;/P&gt;&lt;P&gt;LPIT_DRV_Init(INST_LPIT1, &amp;amp;lpit1_InitConfig);&lt;BR /&gt;LPIT_DRV_InitChannel(INST_LPIT1, LPIT_CHANNEL, &amp;amp;lpit1_ChnConfig0);&lt;BR /&gt;INT_SYS_InstallHandler(LPIT0_Ch0_IRQn, &amp;amp;&lt;STRONG&gt;lpit_level_ctl&lt;/STRONG&gt;, (isr_t *) 0);&lt;BR /&gt;INT_SYS_SetPriority(LPIT0_Ch0_IRQn, 3U);&lt;BR /&gt;INT_SYS_EnableIRQ(LPIT0_Ch0_IRQn);&lt;/P&gt;&lt;P&gt;//-------------------------------------------------------------&lt;/P&gt;&lt;DIV&gt;static void &lt;STRONG&gt;lpit_level_ctl&lt;/STRONG&gt;(void)&amp;nbsp; //timer period is 2us&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; PINS_DRV_WritePin(PTA,0,levelA[counter]);&amp;nbsp; //levelA is waveform data array&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; counter++;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; if(counter == &lt;STRONG&gt;data_len&lt;/STRONG&gt;)&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;{&amp;nbsp; //the data_len is a global varible&amp;nbsp; , and data_len is equal to 100&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; counter = 0;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LPIT_DRV_StopTimerChannels(INST_LPIT1, 1U &amp;lt;&amp;lt; LPIT_CHANNEL);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPIT_DRV_ClearInterruptFlagTimerChannels(INST_LPIT1, 1 &amp;lt;&amp;lt; LPIT_CHANNEL);&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;//-------------------------------------------------------------&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;And PE LPIT configuration : Timer period is 2us (need 500k frequency）&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fedora_0-1744977860790.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/333917i8A0C714C0083F054/image-size/medium?v=v2&amp;amp;px=400" role="button" title="fedora_0-1744977860790.png" alt="fedora_0-1744977860790.png" /&gt;&lt;/span&gt;&lt;P&gt;Clock configuration: Core clock is 48MHz&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fedora_1-1744978083421.png" style="width: 656px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/333918i81F265198899AA37/image-dimensions/656x105?v=v2" width="656" height="105" role="button" title="fedora_1-1744978083421.png" alt="fedora_1-1744978083421.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this, I have encountered a problem,&amp;nbsp; in&amp;nbsp;&lt;STRONG&gt;lpit_level_ctl() &lt;/STRONG&gt;function, if the &lt;STRONG&gt;data_len&lt;/STRONG&gt; variable is used, then waveform timing generated will be incorrect; But I used a constant (such as 100)&amp;nbsp; instead of the &lt;STRONG&gt;data_len&lt;/STRONG&gt;, and waveform is good.&lt;/P&gt;&lt;P&gt;I would like to know the reason for this issue?&amp;nbsp; How to solve it that ensure a frequency of 500k?&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;fedora&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 18 Apr 2025 12:32:48 GMT</pubDate>
    <dc:creator>fedora</dc:creator>
    <dc:date>2025-04-18T12:32:48Z</dc:date>
    <item>
      <title>s32k144 LPIT timer period problem</title>
      <link>https://community.nxp.com/t5/S32K/s32k144-LPIT-timer-period-problem/m-p/2083311#M47924</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;My goal is to generate a waveform with LPIT of S32K144, the LPIT initial and interrupt handler as below:&lt;/P&gt;&lt;P&gt;//-------------------------------------------------------------&lt;/P&gt;&lt;P&gt;LPIT_DRV_Init(INST_LPIT1, &amp;amp;lpit1_InitConfig);&lt;BR /&gt;LPIT_DRV_InitChannel(INST_LPIT1, LPIT_CHANNEL, &amp;amp;lpit1_ChnConfig0);&lt;BR /&gt;INT_SYS_InstallHandler(LPIT0_Ch0_IRQn, &amp;amp;&lt;STRONG&gt;lpit_level_ctl&lt;/STRONG&gt;, (isr_t *) 0);&lt;BR /&gt;INT_SYS_SetPriority(LPIT0_Ch0_IRQn, 3U);&lt;BR /&gt;INT_SYS_EnableIRQ(LPIT0_Ch0_IRQn);&lt;/P&gt;&lt;P&gt;//-------------------------------------------------------------&lt;/P&gt;&lt;DIV&gt;static void &lt;STRONG&gt;lpit_level_ctl&lt;/STRONG&gt;(void)&amp;nbsp; //timer period is 2us&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; PINS_DRV_WritePin(PTA,0,levelA[counter]);&amp;nbsp; //levelA is waveform data array&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; counter++;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; if(counter == &lt;STRONG&gt;data_len&lt;/STRONG&gt;)&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;{&amp;nbsp; //the data_len is a global varible&amp;nbsp; , and data_len is equal to 100&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; counter = 0;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LPIT_DRV_StopTimerChannels(INST_LPIT1, 1U &amp;lt;&amp;lt; LPIT_CHANNEL);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; LPIT_DRV_ClearInterruptFlagTimerChannels(INST_LPIT1, 1 &amp;lt;&amp;lt; LPIT_CHANNEL);&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;//-------------------------------------------------------------&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;And PE LPIT configuration : Timer period is 2us (need 500k frequency）&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fedora_0-1744977860790.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/333917i8A0C714C0083F054/image-size/medium?v=v2&amp;amp;px=400" role="button" title="fedora_0-1744977860790.png" alt="fedora_0-1744977860790.png" /&gt;&lt;/span&gt;&lt;P&gt;Clock configuration: Core clock is 48MHz&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fedora_1-1744978083421.png" style="width: 656px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/333918i81F265198899AA37/image-dimensions/656x105?v=v2" width="656" height="105" role="button" title="fedora_1-1744978083421.png" alt="fedora_1-1744978083421.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this, I have encountered a problem,&amp;nbsp; in&amp;nbsp;&lt;STRONG&gt;lpit_level_ctl() &lt;/STRONG&gt;function, if the &lt;STRONG&gt;data_len&lt;/STRONG&gt; variable is used, then waveform timing generated will be incorrect; But I used a constant (such as 100)&amp;nbsp; instead of the &lt;STRONG&gt;data_len&lt;/STRONG&gt;, and waveform is good.&lt;/P&gt;&lt;P&gt;I would like to know the reason for this issue?&amp;nbsp; How to solve it that ensure a frequency of 500k?&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;fedora&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 18 Apr 2025 12:32:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/s32k144-LPIT-timer-period-problem/m-p/2083311#M47924</guid>
      <dc:creator>fedora</dc:creator>
      <dc:date>2025-04-18T12:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: s32k144 LPIT timer period problem</title>
      <link>https://community.nxp.com/t5/S32K/s32k144-LPIT-timer-period-problem/m-p/2084072#M47961</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/224465"&gt;@fedora&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I imagine this is because of the interrupt routine. It is good practice to a&lt;SPAN&gt;void complex operations in the ISR.&amp;nbsp;You should instead use flags and process everything else in the main code. For example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;static void lpit_level_ctl(void)  //timer period is 2us
{
    bFlag = 1;
    LPIT_DRV_ClearInterruptFlagTimerChannels(INST_LPIT1, 1 &amp;lt;&amp;lt; LPIT_CHANNEL);
}

main()
{
    if(1 == bFlag)
    {
        bFlag = 0;
        PINS_DRV_WritePin(PTA,0,levelA[counter]);  //levelA is waveform data array
        counter++;
        if(counter == data_len) {  //the data_len is a global varible  , and data_len is equal to 100
            counter = 0;
            LPIT_DRV_StopTimerChannels(INST_LPIT1, 1U &amp;lt;&amp;lt; LPIT_CHANNEL);
        }
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't see exactly how you are declaring data_len, but make sure it is a global variable, and that the counter is declared as volatile to avoid optimization.&lt;/P&gt;
&lt;P&gt;With all that said, you could also use the &lt;STRONG&gt;oc_pal_s32k144&lt;/STRONG&gt; example which uses the output compare to control an output instead.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Julián&lt;/P&gt;</description>
      <pubDate>Mon, 21 Apr 2025 22:06:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/s32k144-LPIT-timer-period-problem/m-p/2084072#M47961</guid>
      <dc:creator>Julián_AragónM</dc:creator>
      <dc:date>2025-04-21T22:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: s32k144 LPIT timer period problem</title>
      <link>https://community.nxp.com/t5/S32K/s32k144-LPIT-timer-period-problem/m-p/2084165#M47968</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp; Julián&amp;nbsp; !&lt;/P&gt;&lt;P&gt;I understand now and I will continue to research it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;fedora&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Apr 2025 02:41:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/s32k144-LPIT-timer-period-problem/m-p/2084165#M47968</guid>
      <dc:creator>fedora</dc:creator>
      <dc:date>2025-04-22T02:41:36Z</dc:date>
    </item>
  </channel>
</rss>

