<?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: KS20 core lockup reset exiting stop mode</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KS20-core-lockup-reset-exiting-stop-mode/m-p/1846289#M66286</link>
    <description>&lt;P&gt;Ok, this is getting stranger by the hour.&amp;nbsp; As shown above, I have 3 routines.&amp;nbsp; What really happens is in the main() routine, it calls a single function called applicationStart().&amp;nbsp; ApplicationStart() contains all the setup code and a while(1) loop with the program function calls.&amp;nbsp; The last call in the list is checkForSleep() and if that detects the correct conditions, it calls the 3 sleep routines (prepare, sleep, and wake).&amp;nbsp; What appears to be happening is the board does indeed sleep and does actually wake and execute.&amp;nbsp; It resumes from wake and returns to checkForSleep, which then calls wake.&amp;nbsp; Wake executes and returns. But, when the system tries to return from checkForSleep to the ApplicationStart() routine, I get a reset.&amp;nbsp; That tells me that the stack is messed up and the LR gets corrupted.&amp;nbsp; I moved all the code to inside the while(1) loop in ApplicationStart and a similar thing happens that upon wake, I can execute any code that I want, but when it finally hits the end of the while(1) loop, it never returns to the top of the loop.&amp;nbsp; The reset is gone, but I have no idea where the program is at.&lt;BR /&gt;Of course, this would be way easier if you could run the debugger through low power modes like you can with an ST part.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;More to come&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Apr 2024 18:08:10 GMT</pubDate>
    <dc:creator>jbjoe301</dc:creator>
    <dc:date>2024-04-12T18:08:10Z</dc:date>
    <item>
      <title>KS20 core lockup reset exiting stop mode</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KS20-core-lockup-reset-exiting-stop-mode/m-p/1846121#M66284</link>
      <description>&lt;P&gt;I'm using KS22 and trying to get LLS2 to function.&amp;nbsp; I've tried using the fsl_smc.c routines and I've tried writing my own.&amp;nbsp; I have all clock monitors disabled, and low voltage dropout disabled.&amp;nbsp; I've then disabled sysTick (shouldn't matter), global interrupts, and flash prefetch.&amp;nbsp; I've also ensured that any pending interrupt is serviced and no other interrupts are pending. I can get the board to enter low power mode via WFI instruction, however, as soon as I activate one of the LLWU pins, I get a system reset.&amp;nbsp; Looking at the reset source, it is a core lockup reset.&amp;nbsp; There is little to no documentation on the NXP side, and looking at the Arm site, there isn't much there either.&amp;nbsp; I've submitted a help ticket but it has gone unanswered so hoping the community can lend some advice.&amp;nbsp; Once the software determines it's time to sleep, these routines are called:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;prepareForSleep&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;void&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;disableSystemTickTimer(); &lt;/SPAN&gt;&lt;SPAN&gt;// Disable system tick to allow sleep/stop modes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SCB-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;SCR&lt;/SPAN&gt;&lt;SPAN&gt; = 0x00000004; &lt;/SPAN&gt;&lt;SPAN&gt;// Enable Deep sleep mode&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;clearWakeSource(); &lt;/SPAN&gt;&lt;SPAN&gt;// Clear the wake source before we go to sleep&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NVIC_EnableIRQ(LLWU_IRQ); &lt;/SPAN&gt;&lt;SPAN&gt;// Enable global interrupt for LLWU&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;g_savedPrimask = DisableGlobalIRQ();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// __disable_irq(); // Disable Global interrupts to avoid entering flash vector table&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;__ISB(); &lt;/SPAN&gt;&lt;SPAN&gt;// Synchronize any pre-fetched instructions&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;configureFlashPreFetch(false); &lt;/SPAN&gt;&lt;SPAN&gt;// Disable instruction &amp;amp; data pre-fetch&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;goToSleep&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;void&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;__DSB(); &lt;/SPAN&gt;&lt;SPAN&gt;// Clear the pipeline instructions&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;__WFI(); &lt;/SPAN&gt;&lt;SPAN&gt;// Go to sleep and wait for Event&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;__ISB(); &lt;/SPAN&gt;&lt;SPAN&gt;// Synchronize fetched instructions&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;wakeFromSleep&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;void&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;configureFlashPreFetch(true); &lt;/SPAN&gt;&lt;SPAN&gt;// Enable instruction &amp;amp; data pre-fetch&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;EnableGlobalIRQ(g_savedPrimask);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// __enable_irq(); // Enable Global interrupts&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;__ISB(); &lt;/SPAN&gt;&lt;SPAN&gt;// Synchronize any pre-fetched instructions&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;clearWakeSource(); &lt;/SPAN&gt;&lt;SPAN&gt;// Clear the wake source once we are awake&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SCB-&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;SCR&lt;/SPAN&gt;&lt;SPAN&gt; = 0x00000000; &lt;/SPAN&gt;&lt;SPAN&gt;// Disable Deep sleep mode&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NVIC_DisableIRQ(LLWU_IRQ); &lt;/SPAN&gt;&lt;SPAN&gt;// Enable global interrupt for LLWU&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;initializeSystemTickTimer(); &lt;/SPAN&gt;&lt;SPAN&gt;// Re enable system tick timer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 12 Apr 2024 13:22:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KS20-core-lockup-reset-exiting-stop-mode/m-p/1846121#M66284</guid>
      <dc:creator>jbjoe301</dc:creator>
      <dc:date>2024-04-12T13:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: KS20 core lockup reset exiting stop mode</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KS20-core-lockup-reset-exiting-stop-mode/m-p/1846289#M66286</link>
      <description>&lt;P&gt;Ok, this is getting stranger by the hour.&amp;nbsp; As shown above, I have 3 routines.&amp;nbsp; What really happens is in the main() routine, it calls a single function called applicationStart().&amp;nbsp; ApplicationStart() contains all the setup code and a while(1) loop with the program function calls.&amp;nbsp; The last call in the list is checkForSleep() and if that detects the correct conditions, it calls the 3 sleep routines (prepare, sleep, and wake).&amp;nbsp; What appears to be happening is the board does indeed sleep and does actually wake and execute.&amp;nbsp; It resumes from wake and returns to checkForSleep, which then calls wake.&amp;nbsp; Wake executes and returns. But, when the system tries to return from checkForSleep to the ApplicationStart() routine, I get a reset.&amp;nbsp; That tells me that the stack is messed up and the LR gets corrupted.&amp;nbsp; I moved all the code to inside the while(1) loop in ApplicationStart and a similar thing happens that upon wake, I can execute any code that I want, but when it finally hits the end of the while(1) loop, it never returns to the top of the loop.&amp;nbsp; The reset is gone, but I have no idea where the program is at.&lt;BR /&gt;Of course, this would be way easier if you could run the debugger through low power modes like you can with an ST part.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;More to come&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 18:08:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KS20-core-lockup-reset-exiting-stop-mode/m-p/1846289#M66286</guid>
      <dc:creator>jbjoe301</dc:creator>
      <dc:date>2024-04-12T18:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: KS20 core lockup reset exiting stop mode</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KS20-core-lockup-reset-exiting-stop-mode/m-p/1846294#M66287</link>
      <description>&lt;P&gt;Ok, that was actually the solution!&amp;nbsp; The program does return from the bottom of the while loop, I had disabled an output led which led to that confusion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the end, here is what I learned.&amp;nbsp; If you want to use low power mode, you have to call the sleep function from highest execution loop and not from within 1 or 2 layers.&amp;nbsp; Very strange and nowhere is this documented.&amp;nbsp; Clearly, either the registers or part of the stack is corrupt or overwritten.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 18:20:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KS20-core-lockup-reset-exiting-stop-mode/m-p/1846294#M66287</guid>
      <dc:creator>jbjoe301</dc:creator>
      <dc:date>2024-04-12T18:20:54Z</dc:date>
    </item>
  </channel>
</rss>

