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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

533 Views
stuartrubin
Contributor III

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?

Labels (1)
Tags (2)
0 Kudos
2 Replies

426 Views
converse
Senior Contributor V

Can you show the code that is causing the problem? 

0 Kudos

426 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Stuart Rubin,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
I was wondering if you can share the code which can replicate the phenomenon.
Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos