<?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: Time difference LPIT channels immediately after enabling</title>
    <link>https://community.nxp.com/t5/S32K/Time-difference-LPIT-channels-immediately-after-enabling/m-p/1179822#M8724</link>
    <description>&lt;P&gt;Hi&amp;nbsp;jh2,&lt;/P&gt;
&lt;P&gt;Have you tried the suggestions in &lt;A id="relatedDocsClick_1" href="https://www.nxp.com/webapp/Download?colCode=S32K1XXRM" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;S32K1xx MCU Family - Reference Manual&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;SUP&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SUP&gt;&lt;I class="icon-lock4"&gt;&lt;/I&gt;?&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;While the timer is running, CVALn register reads may not return the real value. If the timer value needs to be read, read it during an LPIT interrupt service routine.&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="48.1.5 Current timer value.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/129394i2ADFD647BA590C34/image-size/large?v=v2&amp;amp;px=999" role="button" title="48.1.5 Current timer value.png" alt="48.1.5 Current timer value.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Robin&lt;BR /&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&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;</description>
    <pubDate>Mon, 09 Nov 2020 03:41:00 GMT</pubDate>
    <dc:creator>Robin_Shen</dc:creator>
    <dc:date>2020-11-09T03:41:00Z</dc:date>
    <item>
      <title>Time difference LPIT channels immediately after enabling</title>
      <link>https://community.nxp.com/t5/S32K/Time-difference-LPIT-channels-immediately-after-enabling/m-p/1179478#M8711</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was hoping someone could shed some light on some odd behaviour.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void LpTimerInit(void)
{
  /*
    DBG_EN = 1
    DOZE_EN = 1
    SW_RST = 1
    M_CEN = 1
  */
  LPIT0-&amp;gt;MCR = 0x0000000F;

  /*
    "Before clearing the Software Reset bit, software must wait for 4
     peripheral clocks (for clock synchronization and reset propagation)."

    CPU clock is 80 MHz. SOSCDIV2_CLK is 1 MHz.
      80 MHz / 1 MHz = 80 per clock tick. 80 * 4 clock ticks = 320.
  */
  for (uint32_t i = 0; i &amp;lt; 320; i++)
  {
    /*
      Intentionally empty.

      Yes, this is more than 320 instructions, but this is a lazy/easy way to wait for long enough.

      Make sure code is not optimized away.
    */
  }

  /*
    SW_RST = 0: abort reset.
  */
  LPIT0-&amp;gt;MCR &amp;amp;= ~0x00000002;

  /*
    Not sure if we need to wait *after* clearing reset, but if there is
    a propagation delay for making reset high, then there might be one for
    making reset low as well.
  */
  for (uint32_t i = 0; i &amp;lt; 320; i++)
  {
    /* Intentionally empty. */
  }

  /*
    TRG_SEL = 0
    TRG_src=0
    TROT = 0
    TSOI = 0
    TSOT = 0
    Mode = 00
    CHAIN = 0
    T_EN = 0
  */
  LPIT0-&amp;gt;TMR[0].TCTRL = 0x00000000;
  LPIT0-&amp;gt;TMR[1].TCTRL = 0x00000000;

  LPIT0-&amp;gt;TMR[0].TVAL = 1000000;

  /* Just for testing. Will, of course, get a different value. */
  LPIT0-&amp;gt;TMR[1].TVAL = 1000000; 

  /*
    TIE0 = 1: Interrupt request on channel 0
  */
  LPIT0-&amp;gt;MIER = 0x00000001;

  /*
    Interrupt LPIT Ch0 enabled in NVIC.
  */
  enableInterrupt(LPIT0_Ch0_IRQn);

  /*
    Start channels 0 and 1 simultaneously.
  */
  LPIT0-&amp;gt;SETTEN = 0x00000003;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Other details about the setup:&lt;/STRONG&gt;&lt;BR /&gt;I'm using an 8 MHz crystal on SOSC. I'm feeding SOSC into the SPLL to generate a 160 MHz SPLL_CLK, which is divided down to an 80 MHz CORE_CLK. I divide SOSC down to a 1 MHz SOSCDIV2_CLK, which feeds the functional clock of the LPIT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Everything works as expected. I can generate the 1s interrupt through ch0. However, immediately after executing the last line in the code, there is already a time difference between Ch0 and Ch1. See the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="jh2_0-1604674024801.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/129325i0EEBBFFFB86CF479/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jh2_0-1604674024801.png" alt="jh2_0-1604674024801.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have verified that before executing the statement, CVAL0 and CVAL1 are both still 0xFFFFFFFF. TVAL0 and TVAL1 are loaded correctly.&lt;/P&gt;&lt;P&gt;The time difference always comes down to 829 microseconds, and stays constant after this initial offset. This is almost a whole millisecond. I thought that setting the timers with SETTEN would cause them to start simultaneously. What could cause this behaviour I'm seeing?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 15:01:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Time-difference-LPIT-channels-immediately-after-enabling/m-p/1179478#M8711</guid>
      <dc:creator>Joey_van_Hummel</dc:creator>
      <dc:date>2020-11-06T15:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference LPIT channels immediately after enabling</title>
      <link>https://community.nxp.com/t5/S32K/Time-difference-LPIT-channels-immediately-after-enabling/m-p/1179822#M8724</link>
      <description>&lt;P&gt;Hi&amp;nbsp;jh2,&lt;/P&gt;
&lt;P&gt;Have you tried the suggestions in &lt;A id="relatedDocsClick_1" href="https://www.nxp.com/webapp/Download?colCode=S32K1XXRM" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;S32K1xx MCU Family - Reference Manual&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/A&gt;&lt;SUP&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SUP&gt;&lt;I class="icon-lock4"&gt;&lt;/I&gt;?&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;While the timer is running, CVALn register reads may not return the real value. If the timer value needs to be read, read it during an LPIT interrupt service routine.&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="48.1.5 Current timer value.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/129394i2ADFD647BA590C34/image-size/large?v=v2&amp;amp;px=999" role="button" title="48.1.5 Current timer value.png" alt="48.1.5 Current timer value.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Robin&lt;BR /&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&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;</description>
      <pubDate>Mon, 09 Nov 2020 03:41:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Time-difference-LPIT-channels-immediately-after-enabling/m-p/1179822#M8724</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2020-11-09T03:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference LPIT channels immediately after enabling</title>
      <link>https://community.nxp.com/t5/S32K/Time-difference-LPIT-channels-immediately-after-enabling/m-p/1180081#M8732</link>
      <description>&lt;P&gt;Thank you. We use the S32K146. I missed the W suffix, and thought I was in the clear.&lt;/P&gt;&lt;P&gt;Since we need to poll the timer for exact microseconds, I'd rather not use an interrupt. I think we'll have to use the FTM for that.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 11:39:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Time-difference-LPIT-channels-immediately-after-enabling/m-p/1180081#M8732</guid>
      <dc:creator>Joey_van_Hummel</dc:creator>
      <dc:date>2020-11-09T11:39:03Z</dc:date>
    </item>
  </channel>
</rss>

