I have the following memory allocation:

unsigned char g1[]={
  0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ....0x00 ,0x00 ,0x00 ,0x00 ,0x00 }; 
  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++){

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?


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
    Dec 11 '14 at 13:39
  • Never mind got it.
    – Thijser
    Dec 11 '14 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.