<?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>Kinetis MicrocontrollersのトピックRe: K66 ADC sampling / TPM firing at wrong times</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1338192#M61458</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/186731"&gt;@EdwinHz&lt;/a&gt;!&lt;BR /&gt;Thanks for your answer!&lt;/P&gt;&lt;P&gt;I'm afraid I cannot share the complete code.&lt;BR /&gt;Do you have any suggestions on how do debug this? Where to look?&lt;/P&gt;&lt;P&gt;I first suspected, that what I see is a product of delayed ISR execution (due to priorities or similar).&lt;BR /&gt;However, I am quite sure, that the conversion actually happens at those delayed times, as I inserted a test ramp and the converted values correspond to the times I meausred on the oscilloscope&lt;/P&gt;&lt;P&gt;Is there a more immediate option to stop a timer?&lt;BR /&gt;Is it somehow possible to "chain" timers/counters to start/stop a timer in hardware?&lt;/P&gt;&lt;P&gt;Can you think of any reason a timer would produce a trigger or an ADC would convert after the triggering timer has been stopped?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 10 Sep 2021 07:37:45 GMT</pubDate>
    <dc:creator>RadaD</dc:creator>
    <dc:date>2021-09-10T07:37:45Z</dc:date>
    <item>
      <title>K66 ADC sampling / TPM firing at wrong times</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1336149#M61433</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I am trying to sample two channels with ADC0 on Kinetis K66 (MK66FN2).&lt;/P&gt;&lt;P&gt;I have configure the ADC to be triggered by TPM1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;tmp32 = SIM-&amp;gt;SOPT7 &amp;amp; ~(SIM_SOPT7_ADC0TRGSEL_MASK | SIM_SOPT7_ADC1TRGSEL_MASK);
tmp32 |= SIM_SOPT7_ADC1ALTTRGEN_MASK | SIM_SOPT7_ADC1TRGSEL(15U) | SIM_SOPT7_ADC0ALTTRGEN_MASK | SIM_SOPT7_ADC0TRGSEL(15U);
SIM-&amp;gt;SOPT7 = tmp32;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TPM1 is configured with a period of 8us, triggering the two ADC channels in alternating fashion:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;tpm_config_t tpmConfig;

CLOCK_SetTpmClock(1U);
CLOCK_SetPllFllSelClock(1,0,0);

TPM_GetDefaultConfig(&amp;amp;tpmConfig);

TPM_Init(TPM1, &amp;amp;tpmConfig);

TPM_SetTimerPeriod(TPM1, 960); // equals 8us at 120 MHz

TPM_SetupOutputCompare(TPM1, kTPM_Chnl_0, kTPM_HighPulseOutput, 0);
TPM_SetupOutputCompare(TPM1, kTPM_Chnl_1, kTPM_HighPulseOutput, 480);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ADC results are transfered using DMA. DMA is also triggered by TPM1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TPM1-&amp;gt;CONTROLS[kTPM_Chnl_0].CnSC |= TPM_CnSC_DMA_MASK;
TPM1-&amp;gt;CONTROLS[kTPM_Chnl_1].CnSC |= TPM_CnSC_DMA_MASK;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now the problem is, that the ADC samples after I turn off TPM1 via&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;TPM_StopTimer(TPM1);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I observed this by turning a GPIO pin on and off in the conversion complete ISR of the ADC. Additionally I also turn a pin on and off in the overflow ISR of TPM1 and I am able to observe the pulses using an oscilloscope.&lt;/P&gt;&lt;P&gt;Does anyone have an idea why the timer runs and fires after I stop it?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 13:13:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1336149#M61433</guid>
      <dc:creator>RadaD</dc:creator>
      <dc:date>2021-09-07T13:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: K66 ADC sampling / TPM firing at wrong times</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1337868#M61454</link>
      <description>&lt;P&gt;I tried to make a quick test based on the SDK to see if there was a more “immediate” thing that was being overlooked, but I wasn’t able to reproduce your situation. If you are willing to share your project, perhaps I could get a better insight of the problem. You can also submit a support ticket from our support webpage to send us the code directly, instead of publishing it the public community.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 17:42:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1337868#M61454</guid>
      <dc:creator>EdwinHz</dc:creator>
      <dc:date>2021-09-09T17:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: K66 ADC sampling / TPM firing at wrong times</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1338192#M61458</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/186731"&gt;@EdwinHz&lt;/a&gt;!&lt;BR /&gt;Thanks for your answer!&lt;/P&gt;&lt;P&gt;I'm afraid I cannot share the complete code.&lt;BR /&gt;Do you have any suggestions on how do debug this? Where to look?&lt;/P&gt;&lt;P&gt;I first suspected, that what I see is a product of delayed ISR execution (due to priorities or similar).&lt;BR /&gt;However, I am quite sure, that the conversion actually happens at those delayed times, as I inserted a test ramp and the converted values correspond to the times I meausred on the oscilloscope&lt;/P&gt;&lt;P&gt;Is there a more immediate option to stop a timer?&lt;BR /&gt;Is it somehow possible to "chain" timers/counters to start/stop a timer in hardware?&lt;/P&gt;&lt;P&gt;Can you think of any reason a timer would produce a trigger or an ADC would convert after the triggering timer has been stopped?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Sep 2021 07:37:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1338192#M61458</guid>
      <dc:creator>RadaD</dc:creator>
      <dc:date>2021-09-10T07:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: K66 ADC sampling / TPM firing at wrong times</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1340758#M61486</link>
      <description>&lt;P&gt;My guess would be that, for some reason, the CMOD register is not being written correctly by the TPM_StopTimer function. If CMOD was able to change to 00, the TPM would have no clock source to count and wouldn’t keep triggering the ADC. Why this could be the case is beyond me, but I would look into this possibility before anything else.&lt;/P&gt;
&lt;P&gt;You could always force stop the timer with TPM_Deinit, although this is obviously NOT recommended as an alternative to stop the TMP clock.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if you find something about this.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 16:34:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1340758#M61486</guid>
      <dc:creator>EdwinHz</dc:creator>
      <dc:date>2021-09-15T16:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: K66 ADC sampling / TPM firing at wrong times</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1341525#M61499</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/186731"&gt;@EdwinHz&lt;/a&gt; for your suggestion!&lt;/P&gt;&lt;P&gt;I'm still looking for the cause of this.&lt;BR /&gt;I'll come back and report if I find something or give up.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 10:55:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K66-ADC-sampling-TPM-firing-at-wrong-times/m-p/1341525#M61499</guid>
      <dc:creator>RadaD</dc:creator>
      <dc:date>2021-09-16T10:55:32Z</dc:date>
    </item>
  </channel>
</rss>

