<?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 Re: &amp;quot;PRINTF&amp;quot; SRAM Overhead/Stack Overflow in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1267565#M60366</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;Regardless, if the problem only occurs when PRINTF is active and debug is disabled, any ideas on how to catch the event?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Make sure that the code halts at the place the overflow is detected.&lt;/P&gt;&lt;P&gt;Let the target run without debug session (I hope you can still keep the debug cable atteched. Download and let the target run, then terminate the debugger). When it stops with the overflow, connect to the 'running' target:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErichS_0-1619250407860.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/143156i3B286CFC165590E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErichS_0-1619250407860.png" alt="ErichS_0-1619250407860.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then you can pause the target and should see where it is and potentially the environment creating the issue.&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
    <pubDate>Sat, 24 Apr 2021 07:47:56 GMT</pubDate>
    <dc:creator>ErichStyger</dc:creator>
    <dc:date>2021-04-24T07:47:56Z</dc:date>
    <item>
      <title>"PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265358#M60297</link>
      <description>&lt;P&gt;I'm running my FreeRTOS (with USB CDC) development code on a FRDM-K22F and I've just started seeing something strange.&amp;nbsp; To monitor operations, I periodically "PRINTF" (using the SDK library code) to put out a message.&amp;nbsp; All works well when I run with MCUXpresso debug active.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I stop the debugger (and optionally remove the USB Cable from the debug port of the Freedom board) which allows the code in the Freedom board continues executing until it encounters a "PRINTF" statement at which point it stops and indicates a Stack Overflow issue.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "PRINTF" statements are typically only built into the code when I specify the pre-processor symbol&amp;nbsp; SDK_DEBUGCONSOLE=0 and all "PRINTF" instances are surrounded by "#if" statements like:&lt;/P&gt;&lt;PRE&gt;#if (2 != SDK_DEBUGCONSOLE)&lt;BR /&gt;  PRINTF("Done");&lt;BR /&gt;#endif&lt;/PRE&gt;&lt;P&gt;When I remove the "PRINTF" statements by setting SDK_DEBUGCONSOLE=2 the application runs fine, no stack overflows detected regardless of whether or not it is connected to the development PC and whether or not debug is active.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I believe the problem is with the PRINTF statements.&amp;nbsp; Now, I've increased the "configTOTAL_HEAP_SIZE" as well as the stack size for the first task that executes a "PRINT" statement but no joy.&amp;nbsp; 25k is the total stacks size used by all the tasks and the total system heap is 36k.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't checked running the code without MCUXpresso Debug active for a week or so, during which I've added a number of tasks and queues and a mutex along with increasing the total number of queues in FreeRTOSConfig.h.&amp;nbsp; &amp;nbsp;- but, as indicated, when MCUXpresso Debug is active, no issues or overflow detected/indicated.&amp;nbsp; Along with that no task's stack is close to it's threshold.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rather than pouding out different ideas, I'd thought I'd ask if anybody has any thoughts as to where I should look to understand this issue.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 19:43:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265358#M60297</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-20T19:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265551#M60301</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;do you print to a serial port or are you using semihosting?&lt;/P&gt;&lt;P&gt;If using semihosting, be aware that without a debugger attached it will cause a hard fault to be handled by your semihosting hard fault handler. It will add to the MSP (interrupt stack) (see &lt;A href="https://mcuoneclipse.com/2016/08/28/arm-cortex-m-interrupts-and-freertos-part-3/" target="_blank"&gt;https://mcuoneclipse.com/2016/08/28/arm-cortex-m-interrupts-and-freertos-part-3/&lt;/A&gt; if this is new to you). So I suggest to increase the interrupt stack space. In MCUXpresso you can do this in the linker settings (there is a setting for the Stack under 'managed linker script').&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 03:37:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265551#M60301</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-04-21T03:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265564#M60302</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's really helpful - I'm using semihosting and the default.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was aware of the two stack architecture in the Cortex-M but I thought that the task stack (PSP) was used during interrupts and the MSP was used within FreeRTOS to avoid adding to the process's stack data (and also simplify restoring the process's context information).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I take a look at "Properties"-&amp;gt;"C/C++ Build"-&amp;gt;"Settings"-&amp;gt;"MCU Linker"-&amp;gt;"Managed Linker Script" I see:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021.04.21 - MCUXpresso Interrupt Stack Location-Value.jpg" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142839i9A572FD30A1B3486/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021.04.21 - MCUXpresso Interrupt Stack Location-Value.jpg" alt="2021.04.21 - MCUXpresso Interrupt Stack Location-Value.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And when I roll over the "Default" for "Stack", I see:&lt;BR /&gt;"Actual size allocated: 4.0kB (0x1000)&lt;BR /&gt;Setting to any non-numeric value will result in Default"&lt;/P&gt;&lt;P&gt;Is this what you are suggesting that I change?&amp;nbsp; If so, what value should I put in here?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally, any idea why this stack would now have a problem?&amp;nbsp; Looking over the changes, I added:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ADC Interrupt Handler&lt;/LI&gt;&lt;LI&gt;2x Queues&lt;/LI&gt;&lt;LI&gt;1x Mutex&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I wouldn't think that would significantly add to the amount of memory required by the MSP.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, many thanx,&lt;/P&gt;&lt;P&gt;myke&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 04:33:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265564#M60302</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-21T04:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265601#M60303</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;The PSP and the FreeRTOS stack space is used for the task (without the interrupt stacks). The interrupts are stacked on the MSP: so all variables and and pushed registers of the interrupts will end up on the MSP stack.&lt;/P&gt;&lt;P&gt;I'm not 100% positive if this is really your issue, but as using printf with semihosting without a debugger will trigger a hard fault on top of it, so this might be the thing. Although the hardfault handler itself (if using the one from the SDK) should not use much stack.&lt;/P&gt;&lt;P&gt;I recommend you check the interrupt stack size used with the Image Info:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErichS_0-1618983703758.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142842i74955D2BEB79F7DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErichS_0-1618983703758.png" alt="ErichS_0-1618983703758.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It does not count in for the interrupt nesting (this is not something this view can account for), but if you know your interrupt priorities you should get an idea about the stack consumed.&lt;/P&gt;&lt;P&gt;And yes: that is the linker setting you showed responsible for the MSP stack size. 4k should be plenty, but who knows what your interrupts are doing?&lt;/P&gt;&lt;P&gt;The other thought I have: do you reset the MSP stack at scheduler start? The NXP SDK standard examples are doing this, and if you have some data present on the MSP stack this will be not good.&lt;/P&gt;&lt;P&gt;See &lt;A href="https://mcuoneclipse.com/2019/01/20/freertos-how-to-end-and-restart-the-scheduler/" target="_blank"&gt;https://mcuoneclipse.com/2019/01/20/freertos-how-to-end-and-restart-the-scheduler/&lt;/A&gt; on that topic.&lt;/P&gt;&lt;P&gt;That's why I have added&lt;/P&gt;&lt;P&gt;configRESET_MSP&lt;/P&gt;&lt;P&gt;to FreeRTOS to configure this. So check if you reset it,e.g.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErichS_1-1618984288397.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142843i43D3D2D3A28BA997/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErichS_1-1618984288397.png" alt="ErichS_1-1618984288397.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So depending on this you have more (or less) usage of the MSP.&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 05:52:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265601#M60303</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-04-21T05:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265833#M60306</link>
      <description>&lt;P&gt;There is a really obscure bug in printf that requires the stack to be aligned on 64 bit boundaries (8 bytes).&lt;BR /&gt;The bug usually shows itself when trying to print 64-bit numbers.&lt;BR /&gt;&lt;BR /&gt;In most non-RTOS systems the stack is placed at the end of memory which would be on a 64 bit boundary, so the bug goes unnoticed.&lt;BR /&gt;&lt;BR /&gt;Are all of the RTOS stacks on a 64 bit boundary?&lt;BR /&gt;&lt;BR /&gt;[I edited this to correctly say 64-bit, not byte as when I initially posted.]&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 17:30:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1265833#M60306</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2021-04-21T17:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266009#M60311</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/38376"&gt;@bobpaddock&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just looked at the .map file for the current as well as past versions of code.&amp;nbsp; The end of memory generally looks like below, noting that the it is aligned on a four byte (32 bit) boundary.&amp;nbsp; I don't print (or even use) any 64 bit numbers.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;.heap 0x0000000020006388 0x1000&lt;BR /&gt;0x0000000020006388 _pvHeapStart = .&lt;BR /&gt;0x0000000020007388 . = (. + _HeapSize)&lt;BR /&gt;*fill* 0x0000000020006388 0x1000 &lt;BR /&gt;0x0000000020007388 . = ALIGN (0x4)&lt;BR /&gt;0x0000000020007388 _pvHeapLimit = .&lt;BR /&gt;0x0000000000001000 _StackSize = 0x1000&lt;BR /&gt;&lt;BR /&gt;.heap2stackfill&lt;BR /&gt;0x0000000020007388 0x1000&lt;BR /&gt;0x0000000020008388 . = (. + _StackSize)&lt;BR /&gt;*fill* 0x0000000020007388 0x1000&lt;BR /&gt;&lt;BR /&gt;.stack 0x000000002000f000 0x0&lt;BR /&gt;0x000000002000f000 _vStackBase = .&lt;BR /&gt;0x000000002000f000 . = ALIGN (0x4)&lt;BR /&gt;0x0000000020010000 _vStackTop = (. + _StackSize)&lt;BR /&gt;0x0000000000000000 _image_start = LOADADDR (.text)&lt;BR /&gt;0x0000000000027120 _image_end = (LOADADDR (.data) + SIZEOF (.data))&lt;BR /&gt;0x0000000000027120 _image_size = (_image_end - _image_start)&lt;/PRE&gt;&lt;P&gt;Thank you for the comment.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 17:11:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266009#M60311</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-21T17:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266079#M60312</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm going to answer your post in two parts.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first is on the MSP reset.&amp;nbsp; In your screenshots, it looks like the first MSP set up is done in "prvPortStartFirstTask" which is called by the "xPortStartScheduler" method which was called by "vTaskStartScheduler".&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking through the project source, other than the setup in "prvPortStartFirstTask", MSP isn't accessed except in the CMSIS library code.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made the change to the code that you recommended in your reply:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021.04.21 - Erich's Remove MSP Reset - 2.jpg" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142899iBB9064175704134A/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021.04.21 - Erich's Remove MSP Reset - 2.jpg" alt="2021.04.21 - Erich's Remove MSP Reset - 2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;With no change in the operating behaviour.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, I tried taking out the MSP reset in "prvPortStartFirstTask" all together (as discssed in your article):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021.04.21 - Erich's Remove MSP Reset - 3.jpg" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142900iAAB5308310D85214/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021.04.21 - Erich's Remove MSP Reset - 3.jpg" alt="2021.04.21 - Erich's Remove MSP Reset - 3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;With again no change in behaviour.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I'm restoring port.c (where "prvPortStartFirstTask" and the MSP setup/reset occurs) on the assumption that this isn't the issue.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 18:30:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266079#M60312</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-21T18:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266099#M60314</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well no luck with changing the stack value - I doubled the "Default" value to 0x2000 (4k) and I get the same behaviour.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked at the Call Graph for a previous build (which works without any issues) and the only difference I can see is the "ADC_IRQHandler" which is in the new project and not in the old as you can see here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021.04.21 - Erich's Call Graph Review - 3.jpg" style="width: 859px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142901iC96E71C837C4D2BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021.04.21 - Erich's Call Graph Review - 3.jpg" alt="2021.04.21 - Erich's Call Graph Review - 3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm a bit surprised the ADC Handler has a call depth of 8 levels - I'm using the SDK code which appears to be fairly inefficient - right&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/1431"&gt;@mjbcswitzerland&lt;/a&gt;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;So, any suggestions on what to look at next?&amp;nbsp; Maybe I'm not changing the right Property?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 19:36:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266099#M60314</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-21T19:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266298#M60321</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;can you share a picture of that ADC0 interrupt handler in the image info unfolded to see all the dependencies?&lt;/P&gt;&lt;P&gt;I'm wondering why it is not able to show the stack used unless it is implemented in assembly?&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 04:29:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266298#M60321</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-04-22T04:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266302#M60322</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;ok, I think it it was at least worth trying.&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 04:46:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266302#M60322</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-04-22T04:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266306#M60324</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No worries.&amp;nbsp; I'm always game to learn sometthing new as well as try different things.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;myke&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 04:51:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266306#M60324</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-22T04:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266312#M60325</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;ok, just checked an example on my side (FRDM-K22F adc16 interrupt example from the SDK):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErichS_3-1619067286077.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142942i5B0C1DCE111D5A3A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErichS_3-1619067286077.png" alt="ErichS_3-1619067286077.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErichS_2-1619067275702.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142941i28F8D72C17F4E8BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErichS_2-1619067275702.png" alt="ErichS_2-1619067275702.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErichS_0-1619067070198.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142937i4ECA8C1261354A3F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErichS_0-1619067070198.png" alt="ErichS_0-1619067070198.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I get that huge call stack because of the assert and the associated printf().&lt;/P&gt;&lt;P&gt;Could it be that in your case the assert gets triggered? but only in the case it triggers the printf() would be executed. I would disable that assert to give it a try. Or replace it with a check turning on a LED if it fails,then you know if it is really that assert.&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 04:54:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266312#M60325</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-04-22T04:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266317#M60326</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the interrupt handler:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021.04.21 - ADC0 Interrupt Handler.jpg" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142938iE7DF92A1CB353389/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021.04.21 - ADC0 Interrupt Handler.jpg" alt="2021.04.21 - ADC0 Interrupt Handler.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and here's the sensor value variable declare:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021.04.21 - ADC0 Interrupt Handler Declares.jpg" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142939i38121354D3399BE4/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021.04.21 - ADC0 Interrupt Handler Declares.jpg" alt="2021.04.21 - ADC0 Interrupt Handler Declares.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, as coded, up to eight interrupt sources can be used and stored in an array.&amp;nbsp; I just looked at the assembly code (below) and I don't see anything that I would be extreme.&amp;nbsp; I also followed the code through "ADC16_GetChannelConversionValue" and there is only one subroutine call in the method which means that the depth of this interrupt service routine should be "3" and not the "8" produced by the Call Graph (I guess I don't understand how it works).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ADC0_IRQHandler:&lt;BR /&gt;0000205c: push {r3, r4, r7, lr}&lt;BR /&gt;0000205e: add r7, sp, #0&lt;BR /&gt;62 adcpollConversionDoneFlag = TRUE;&lt;BR /&gt;00002060: ldr r3, [pc, #32] ; (0x2084 &amp;lt;ADC0_IRQHandler+40&amp;gt;)&lt;BR /&gt;00002062: movs r2, #1&lt;BR /&gt;00002064: str r2, [r3, #0]&lt;BR /&gt;64 adcpollSensorValue[adcpollActive] = ADC16_GetChannelConversionValue(ADC0_ADC16_BASE&lt;BR /&gt;00002066: ldr r3, [pc, #32] ; (0x2088 &amp;lt;ADC0_IRQHandler+44&amp;gt;)&lt;BR /&gt;00002068: ldr r4, [r3, #0]&lt;BR /&gt;0000206a: movs r1, #0&lt;BR /&gt;0000206c: ldr r0, [pc, #28] ; (0x208c &amp;lt;ADC0_IRQHandler+48&amp;gt;)&lt;BR /&gt;0000206e: bl 0x2030 &amp;lt;ADC16_GetChannelConversionValue&amp;gt;&lt;BR /&gt;00002072: mov r3, r0&lt;BR /&gt;00002074: ldr r2, [pc, #24] ; (0x2090 &amp;lt;ADC0_IRQHandler+52&amp;gt;)&lt;BR /&gt;00002076: str.w r3, [r2, r4, lsl #2]&lt;BR /&gt;879 __ASM volatile ("dsb 0xF":::"memory");&lt;BR /&gt;0000207a: dsb sy&lt;BR /&gt;880 }&lt;BR /&gt;0000207e: nop &lt;BR /&gt;71 }&lt;BR /&gt;00002080: nop &lt;BR /&gt;00002082: pop {r3, r4, r7, pc}&lt;BR /&gt;00002084: mvns r4, r4&lt;BR /&gt;00002086: subs r7, r7, #7&lt;BR /&gt;00002088: mvns r0, r5&lt;BR /&gt;0000208a: subs r7, r7, #7&lt;BR /&gt;0000208c: add sp, #0&lt;BR /&gt;0000208e: ands r3, r0&lt;BR /&gt;00002090: mvns r4, r0&lt;BR /&gt;00002092: subs r7, r7, #7&lt;/PRE&gt;&lt;P&gt;Thoughts or places where you see issues?&lt;/P&gt;&lt;P&gt;myke&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 05:01:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266317#M60326</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-22T05:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266319#M60327</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt; ,&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;the depth of this interrupt service routine should be "3" and not the "8" produced by the Call Graph (I guess I don't understand how it works).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It counts how many functions are called to the max and stacked up. Could you share the image as I did for that depth unfolded? Are there any printf() in it?&lt;/P&gt;&lt;P&gt;If it is as on my SDK example, the ADC16_GetChannelConversionValue adds up to the number of calls because of that assert in it.&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 05:08:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266319#M60327</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-04-22T05:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266321#M60328</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, other than the ADC value being stored in an array, our code is basically identical&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I expanded the Call Graph and have the same results as you do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I check the assert, ChannelGroup is zero (ADC0) and&amp;nbsp;FSL_FEATURE_ADC16_CONVERSION_CONTROL_COUNT is 2, so no issues with assert not being true.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;myke&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 05:07:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266321#M60328</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-22T05:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266325#M60329</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;I would comment out that assert and give it a try if it makes a difference.&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 05:11:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266325#M60329</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-04-22T05:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266327#M60330</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the Call Graph Fully Expanded.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021.04.21 - Erich's Call Graph Review - 4.jpg" style="width: 950px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/142943i62090951844382A8/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021.04.21 - Erich's Call Graph Review - 4.jpg" alt="2021.04.21 - Erich's Call Graph Review - 4.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;No PRINTFs in it.&lt;/P&gt;&lt;P&gt;myke&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 05:13:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266327#M60330</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-22T05:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266329#M60331</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I commented out the assert and tried it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No differences in operation.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 05:17:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266329#M60331</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-04-22T05:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266331#M60332</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;No PRINTFs in it.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Outsch! Even worse, you have file I/O in it (writing to a file) :-(.&lt;/P&gt;&lt;P&gt;Your assert must be pretty fancy &lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 05:18:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266331#M60332</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-04-22T05:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: "PRINTF" SRAM Overhead/Stack Overflow</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266337#M60333</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;I would set the NDEBUG define in the project settings to disable all these asserts to see if it makes any difference. Your assert is very concerning to me: in case of a triggering it it most likely will immediately overflow any stack unless you have many KBytes available for it: doing File I/O is huge (both from stack usage and code size).&lt;/P&gt;&lt;P&gt;Just to be sure: you are running the 'debug' and not the 'release' version on the target, right?&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 05:23:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-PRINTF-quot-SRAM-Overhead-Stack-Overflow/m-p/1266337#M60333</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-04-22T05:23:05Z</dc:date>
    </item>
  </channel>
</rss>

