Hello,
My KE02 is unpredictably reseting and I suspect that this is probably due to RAM overflow.
Is there a C command or register of the MCU that would tell me the remaining (or used) RAM memory? With that, I could track better with what operation could be related this memory leak.
If there is not such thing, what would you recommend to identify this problem?
Thanks
Juan
I hope you are doing well, I am sorry for the late response.
There are several ways in that the MCU goes into reset state as mentioned in the section 6.2 Reset of the KE02 Sub-Family reference manual. Specifically you could try to track the actual source of reset from the SIM_SRSID register, just after the reset event just happened.
Following your idea, Indeed the KE02 comes with very few SRAM ( 4 KB for some parts), so a stack overflow seems very likely to happen if there is bad handling from the SW or demanding functions like semihost' printf .
To monitor stack usage during run time:
As mentioned in this post , there is a suggestion to read the internal stack point register of the processor Monitoring Stack Size - NXP Community
Other thing, it would be to set a data watchpoint of to the SRAM region that corresponds to the limit of the stack. How to use Watchpoints - NXP Community This applies also for MCUXpresso IDE (if you are using it.)
I think that this post from Erich Styger's is useful discussing this topic (he also mentions static stack analysis) Stack Canaries with GCC: Checking for Stack Overflow at Runtime | MCU on Eclipse
If you are not able to catch the problem , I would also recommend you to check for any hardware/electrical issue , in the case you have a custom board.
I hope, this could help you, many thanks for your patience.
Diego