Reputation: 11
I have an API to read data:
ROM_READ_PAGE(BLOCK_NO, PAGE_NO, *READ_BUFFER);
The Page size is 2048 and you can ONLY read WHOLE page at a time.
I know it is just about using C, but my system doesn't run using either of the methods I tried.
For example:
char *readPtr;
char readBuff[128]; //(Can not use 2048 due to stack overflow)
readPtr = readBuff;
ROM_READ_PAGE(BLOCK_NO, PAGE_NO, readPtr); // SMX doesn't like this and shows some exception
Any other idea or if I am missing something important.
Upvotes: 1
Views: 359
Reputation: 89192
If your stack can't be 2048, that doesn't mean that you are excused from providing a 2048 byte block
char *readPtr = malloc(2048);
ROM_READ_PAGE(BLOCK_NO, PAGE_NO, readPtr);
// do whatever you need
free(readPtr);
Upvotes: 3
Reputation: 108938
Don't use the stack. If you compiler uses the stack for auto variables, you can either change the way your compiler deals with auto variables (unlikely) or use some other kind of variable.
Usually, compilers put static storage variables in a different area than auto variables. You may want to try that.
Or, try dynamic memory allocation.
Upvotes: 0
Reputation: 25505
You can dynamically allocate the buffer and avoid the stack overflow. you will also need to free the buffer
char *readBuff;
readBuff = (char *) malloc(2048);
free(readBuff);
Upvotes: 2