mspgcc group:

I am trying to allocate memory in the flash area to use as permanent storage.  I
would like to align it on a 512-byte boundary, but msp430-gcc does not let me.
Why?

I can define the global variable in the memory, but if I try to align it I run
into problems.  If I align on a 2-byte boundary it works.  Anything beyond that,
msp430-gcc warns and uses a 2-byte boundary.

For example, using 4-byte boundary will not work:

const char __attribute__ ((section(".text"), aligned(4))) storage[100] = {[0 
... 99] = 0xFF};

Warning: alignment of 'storage' is greater than maximum object file alignment. 
Using 2.

Am I missing something?  Or is this the wrong method? 


-Paul

==================================================
Here is simple code setup (no clock setup):

#include <io.h>
// Want to align to on 512 - but will not work
const char __attribute__ ((section(".text"), aligned(2))) storage[100] = {[0 
... 99] = 0xFF};

// Copied from TI example 
void write_to_flash_int16(int *location, int value) {
  FCTL3 = 0x0A500;
  FCTL1 = 0x0A540;
  *location = value;
  FCTL1 = 0x0A500;
  FCTL3 = 0x0A510;
}

int main() {
  int *f = (int *) storage;
  write_to_flash_int16 (f, 0xcafe);
  write_to_flash_int16 (f+1, 0xbabe);
}


Reply via email to