I have the following memory allocation:
unsigned char g1[]={
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ....0x00 ,0x00 ,0x00 ,0x00 ,0x00 };
g2[]={
0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ....0x00 ,0x00 ,0x00 ,0x00 ,0x00 };
...
unsigned char* index[10] = {g1,g2,g3,g4,g5,g6,g7,g8,g9,g0};
This is accessed in the following way:
unsigned char* getMatch(int input){
return index[input];
}
This is then futher acces using the method of
unsigned char store[1024]
unsigned char* temp = getMatch(n);
for(int i=0;i <50;i++){
store[i]=temp[i];
}
and store is then modified and send to an external device.
As my program is randomly failing I think it might be running low on SRAM and was wondering if there is any way to force this memory to be placed in flash. Anybody got an idea?
1 Answer 1
It's stored in both the FLASH and SRAM because it's initialized array. To store in FLASH only you need use PROGMEM attribute.
const unsigned PROGMEM char g1[]= ...
You cannot access directly but using memcpy_P() function.
-
How would I put this in the 2nd array after this? I get a lot of error: invalid conversion from ‘const unsigned char*’ to ‘unsigned char* errors.Thijser– Thijser2014年12月11日 13:39:05 +00:00Commented Dec 11, 2014 at 13:39
-