2020-12-13 05:29 AM
Hi,
In my program (running on STM32F446RE, with 512 KB flash and 128 KB SRAM) I defined two big arrays:
int main(void)
{
/* USER CODE BEGIN 1 */
int16_t data_in[64000];
int16_t audio_buffer[16000];
The code can run normally when the data_in array is not there. However, when the variable data_in is defined, the program will just encounter hard fault and exit abnormally.
Since these variables will be changed throughout the program I can't define them as constants. May I ask what should I do in order to fix this problem?
Thank you.
Solved! Go to Solution.
2020-12-13 07:01 AM
The linker should catch this, check the linker script describes the amount of RAM correctly.
You need to use less memory for the buffers or pick a larger part with more RAM.
Your description doesn't suggest internal Flash is usable for transient data.
2020-12-13 06:36 AM
You are overflowing your ram. int16_t data_in[64000]; alone neede 128 kB, and than the other 32 kB variable and stack and local storage...
2020-12-13 06:48 AM
does that mean I should put the array in flash instead? or is there other solution?
2020-12-13 07:01 AM
The linker should catch this, check the linker script describes the amount of RAM correctly.
You need to use less memory for the buffers or pick a larger part with more RAM.
Your description doesn't suggest internal Flash is usable for transient data.
2020-12-14 05:45 AM
I reduced the size of the buffer and the issue was solved. Thank you!