AnsweredAssumed Answered

Vybrid Strange Memory Overwrite

Question asked by Johannes Traxler on Aug 14, 2014
Latest reply on Aug 20, 2014 by Johannes Traxler

We have a strange problem on Vybrid M4 using MQX.

 

Platform: PCM052

MQX-Version: 4.0.1 with PCM052- and ADC-Patch applied

DS-5 V5.17

Code Region: OnChip SysRAM0 0x3f00 0000-0x3f03 fff0

Data Region: GfxRAM0 0x3f40 0000-0x3f47 ffff

Shared Data (MCC): OnChip SysRAM1 0x3f04 0000-0x3f04 fff0

Stack starts at TCML_END: 0x1f80 7ff0

Librarys: PSP, BSP, MCC, RTCS (UDP only)

Tasks: MQX Idle, User Main-Task (1500Bytes Stacksize), User Task2 (1000Bytes Stacksize)

 

We have a periodic function, which is calculating some values. From time to time it happens, that values are corrupted (random numbers without meaning in this context), i.e. we do not see the expected values in the debugger. With ULinkPro Trace we found out, that this error occurs in combination with an interrupt (GPIO and also ADC0/1). Further analysis show that the StackPointer is rather high with ~28kByte. In the TCML-Memory there are just 32kBytes available, so we assume that in corner cases the stack pointer overflows and overwrite the CPU registers with wrong values, which are then written into our value buffers.

 

Is a stack pointer size of 28kByte in MQX normal or is this a exception here?

Are there any techniques to keep the stack pointer lower?

Is there a possibility in DS-5 to monitor the stack pointer and break in case of overflow?

 

Thanks in advance,

Johannes

Outcomes