2

For an ethernet project I do, I need to store the Ethernet Shield's MAC address. I store it like that:

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0xE1, 0x85 };

That works OK, but in my project I need all the SRAM available, so every byte of memory is important. I've used the F() macro and PROGMEM everywhere, but I couldn't manage to store the MAC byte array in the PROGMEM.

How can I store it in PROGMEM? Is it even possible?

Ido Daniel
  • 68
  • 2
  • 5

1 Answers1

2

See Putting constant data into program memory (PROGMEM) for tips about putting stuff into PROGMEM. However personally I wouldn't get too excited about saving 6 bytes.


Example code:

Declare data globally:

const byte mac [6] PROGMEM = { 0x90, 0xA2, 0xDA, 0x0F, 0xE1, 0x85 };

Get a copy for use into a temporary variable:

  char foo [6];
  memcpy_P (foo, mac, sizeof foo);
Nick Gammon
  • 38,901
  • 13
  • 69
  • 125