AnsweredAssumed Answered

SRAM function param crashes with pointer reference, pass by value OK

Question asked by Stuart Rubin on Nov 13, 2018
Latest reply on Nov 19, 2018 by jeremyzhou

I have a program in which most code is running from flash (XIP). I have a few functions which run directly out of RAM. These RAM functions have been located by the linker into the SRAM0 section. The rest of the RAM (stack, heap, etc.) are in SRAMX.

One of my RAM functions takes an array as in input. If I pass the array by reference (the normal C way), the function crashes. If I modify the function so the array is passed by value (i.e. on the stack) it works fine.

The calling function is in flash (0x1000 0000 region), the array data is in SRAMX (0x0000 0000 region), and the function which is called is in SRAM0 (0x2000 0000 region).

I suspect the problem has something to do with the pointers unable to address the different memory spaces, or less probably, there is an alignment issue.

Can someone suggest the root cause and a fix please?

Outcomes