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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

543 次查看
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?

标签 (1)
标记 (2)
0 项奖励
2 回复数

436 次查看
converse
Senior Contributor V

Can you show the code that is causing the problem? 

0 项奖励

436 次查看
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 项奖励