<?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 LLWU using LPTMR0 on K22F not waking in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/LLWU-using-LPTMR0-on-K22F-not-waking/m-p/680929#M41930</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to use the LLWU triggered by LPTMR0 on a K22F to wake from sleep. I've based my code so far on this guide:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://mcuoneclipse.com/2014/03/16/starting-point-for-kinetis-low-power-lls-mode/" title="https://mcuoneclipse.com/2014/03/16/starting-point-for-kinetis-low-power-lls-mode/"&gt;Starting Point for Kinetis Low Power LLS Mode | MCU on Eclipse&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My goal is to put the system into low-power mode, then periodically wake using a low-power timer *without* resetting system state. So, I don't want to re-enter at main; I just want the MCU to pause while it's sleeping until the timer goes off.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;timer interrupt is being triggered but&amp;nbsp;&lt;STRONG&gt;Cpu_OnLLSWakeUpINT is never executed &lt;/STRONG&gt;after the processor goes back to sleep. Here's some background on my configuration:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-LPTMR0 configured to use LPO_1kHzSrc&lt;/P&gt;&lt;P&gt;-Very low power mode, Low leakage stop mode, Very low leakage stop mode all enabled under Cpu component&lt;/P&gt;&lt;P&gt;-LPTMR0 checked under "LLWU Settings" under Cpu component&lt;/P&gt;&lt;P&gt;-interrupt request enabled under LLWU Settings, Interrupts&lt;/P&gt;&lt;P&gt;-interrupt priority set to Highest&lt;/P&gt;&lt;P&gt;-Return to wait after ISR is disabled for both WAIT and SLEEP&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My best guess is that this is happening because the TimerUnit_LDD interrupt handler is clearing the LPTMR0 before&amp;nbsp;Cpu_OnLLSWakeUpINT gets executed. In fact, I can see this line in the PE-generated code for the timer unit:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PE_ISR(WakeupTimer_Interrupt)&lt;BR /&gt;{&lt;BR /&gt; /* {Default RTOS Adapter} ISR parameter is passed through the global variable */&lt;BR /&gt; WakeupTimer_TDeviceDataPtr DeviceDataPrv = INT_LPTMR0__DEFAULT_RTOS_ISRPARAM;&lt;/P&gt;&lt;P&gt;LPTMR_PDD_ClearInterruptFlag(LPTMR0_BASE_PTR); /* Clear interrupt flag */&lt;BR /&gt; WakeupTimer_OnCounterRestart(DeviceDataPrv-&amp;gt;UserDataPtr); /* Invoke OnCounterRestart event */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I don't understand: in the blog post above, the PE-generated code seems to be working fine according to the author.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something I don't quite understand: what's the distinction between the TimerInterrupt event vs. the&amp;nbsp;&lt;SPAN&gt;Cpu_OnLLSWakeUpINT event? If I have configured LPTMR0 as a LLWU source, I would expect that both the TimerInterrupt event and the LLSWakeUp event to occur.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Updates:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1) Could this be caused by the fact that LPTMR is enabled as an LLWU source but LPTMR_CMR is not?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2) Somehow, *other* interrupts (not the LPTMR) are able to wake the processor and start it running again. I've set a breakpoint in&amp;nbsp;Cpu_OnLLSWakeUpINT&amp;nbsp;and it doesn't appear to be executed, so I'm not sure how or if the processor is waking. For example, I can transmit a UART character into my MCU (which triggers a different interrupt) and then everything starts running again. These other interrupts are not LLWU sources.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Jul 2017 23:51:07 GMT</pubDate>
    <dc:creator>asfarley</dc:creator>
    <dc:date>2017-07-24T23:51:07Z</dc:date>
    <item>
      <title>LLWU using LPTMR0 on K22F not waking</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/LLWU-using-LPTMR0-on-K22F-not-waking/m-p/680929#M41930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to use the LLWU triggered by LPTMR0 on a K22F to wake from sleep. I've based my code so far on this guide:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://mcuoneclipse.com/2014/03/16/starting-point-for-kinetis-low-power-lls-mode/" title="https://mcuoneclipse.com/2014/03/16/starting-point-for-kinetis-low-power-lls-mode/"&gt;Starting Point for Kinetis Low Power LLS Mode | MCU on Eclipse&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My goal is to put the system into low-power mode, then periodically wake using a low-power timer *without* resetting system state. So, I don't want to re-enter at main; I just want the MCU to pause while it's sleeping until the timer goes off.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;timer interrupt is being triggered but&amp;nbsp;&lt;STRONG&gt;Cpu_OnLLSWakeUpINT is never executed &lt;/STRONG&gt;after the processor goes back to sleep. Here's some background on my configuration:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-LPTMR0 configured to use LPO_1kHzSrc&lt;/P&gt;&lt;P&gt;-Very low power mode, Low leakage stop mode, Very low leakage stop mode all enabled under Cpu component&lt;/P&gt;&lt;P&gt;-LPTMR0 checked under "LLWU Settings" under Cpu component&lt;/P&gt;&lt;P&gt;-interrupt request enabled under LLWU Settings, Interrupts&lt;/P&gt;&lt;P&gt;-interrupt priority set to Highest&lt;/P&gt;&lt;P&gt;-Return to wait after ISR is disabled for both WAIT and SLEEP&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My best guess is that this is happening because the TimerUnit_LDD interrupt handler is clearing the LPTMR0 before&amp;nbsp;Cpu_OnLLSWakeUpINT gets executed. In fact, I can see this line in the PE-generated code for the timer unit:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PE_ISR(WakeupTimer_Interrupt)&lt;BR /&gt;{&lt;BR /&gt; /* {Default RTOS Adapter} ISR parameter is passed through the global variable */&lt;BR /&gt; WakeupTimer_TDeviceDataPtr DeviceDataPrv = INT_LPTMR0__DEFAULT_RTOS_ISRPARAM;&lt;/P&gt;&lt;P&gt;LPTMR_PDD_ClearInterruptFlag(LPTMR0_BASE_PTR); /* Clear interrupt flag */&lt;BR /&gt; WakeupTimer_OnCounterRestart(DeviceDataPrv-&amp;gt;UserDataPtr); /* Invoke OnCounterRestart event */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I don't understand: in the blog post above, the PE-generated code seems to be working fine according to the author.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something I don't quite understand: what's the distinction between the TimerInterrupt event vs. the&amp;nbsp;&lt;SPAN&gt;Cpu_OnLLSWakeUpINT event? If I have configured LPTMR0 as a LLWU source, I would expect that both the TimerInterrupt event and the LLSWakeUp event to occur.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Updates:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1) Could this be caused by the fact that LPTMR is enabled as an LLWU source but LPTMR_CMR is not?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2) Somehow, *other* interrupts (not the LPTMR) are able to wake the processor and start it running again. I've set a breakpoint in&amp;nbsp;Cpu_OnLLSWakeUpINT&amp;nbsp;and it doesn't appear to be executed, so I'm not sure how or if the processor is waking. For example, I can transmit a UART character into my MCU (which triggers a different interrupt) and then everything starts running again. These other interrupts are not LLWU sources.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jul 2017 23:51:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/LLWU-using-LPTMR0-on-K22F-not-waking/m-p/680929#M41930</guid>
      <dc:creator>asfarley</dc:creator>
      <dc:date>2017-07-24T23:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: LLWU using LPTMR0 on K22F not waking</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/LLWU-using-LPTMR0-on-K22F-not-waking/m-p/680930#M41931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I've got this partially solved: Cpu_OnLLSWakeUpINT is now being executed as intended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the big change was using the mode DOM_STOP instead of DOM_WAIT. I &lt;STRONG&gt;never&lt;/STRONG&gt;&amp;nbsp;saw&amp;nbsp;&lt;SPAN&gt;Cpu_OnLLSWakeUpINT&amp;nbsp;execute after transitioning to DOM_WAIT.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Under the Cpu component settings for PE, I noticed that the configuration under Low Power Mode Settings -&amp;gt; Operation Mode Settings -&amp;gt; WAIT does not have any drop-down box for selecting the equivalent ARM Cortex mode. This made me suspect that I was entering some unknown state using the function Cpu_SetOperationMode(DOM_WAIT, NULL, NULL). &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To answer some of my other questions in case someone else is reading:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-I didn't have to modify any PE-generated code to get this working&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;-both&amp;nbsp;Cpu_OnLLSWakeUpINT and the timer interrupt are being executed on wake despite the fact that both interrupts perform the following flag-clearing (this is the desired behavior from my perspective):&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LPTMR_PDD_ClearInterruptFlag(LPTMR0_BASE_PTR); /* Clear interrupt flag */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The flag-clearing may be redundant and there may be other factors here, but at least future readers can confirm that waking from LLWU using LPTMR along with a TimerInt is possible (without reseting MCU either).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jul 2017 18:16:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/LLWU-using-LPTMR0-on-K22F-not-waking/m-p/680930#M41931</guid>
      <dc:creator>asfarley</dc:creator>
      <dc:date>2017-07-25T18:16:49Z</dc:date>
    </item>
  </channel>
</rss>

