[TUT] [C] GCC and the PROGMEM Attribute

Go To Last Post
204 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I made this table illustrating the complexity and lack of "one-to-one" mapping between PC and AVR memory types. I'm sure it does not cover everything, and might be wrong in details. See it as an illustration rather than an absolute truth..

 

 

Memory type       Volatile  Speed[1] PC                                     AVR
                            R   W
---------------------------------------------------------------------------------------------------------------------
RAM               Yes       F   F    * Program code when executing
                                     * Data for programs while running      * Data for programs while running

Hard disk         No        S   S    * Permanent program code storage       * n/a [2]
                                       (must be loaded into RAM to be 
                                        executed)
                                     * Permanent data storage
                                       (e.g. store data between executions
                                       i.e. when program is not running)

Flash             No        F   S    * n/a [4]                             * Program code permanent storage, and
                                                                             is executed from here

EEPROM            No        F   S    * n/a [5]                              * Low volume read and write data
                                                                              (e.g. store data between executions
                                                                              i.e. when AVR is not powered)

External          No        S   S    * As hard disk above                   * High(er) volume read and write data
Non-volatile                                                                  (e.g. store data between executions
Memory [3]                 			                              i.e. when AVR is not powered)
                                                                              Possibly for needing moveable/detachable
                                                                              memory, or just for high volumes

----------------------------------------------------------------------------------------------------------------------
[1] R - Read, W - Write, F - Fast, S - Slow
[2] While technically possible attaching a "classical" hard disk (SATA/ESATA)
    to an AVR is complex and in most all cases a memory card is more fitting
    and definitively easier to do
[3] Memory cards, USB sticks/drives
[4] I'm avoiding a somewhat complex discussion on PC BIOS storage by simply ignoring it and
    saying n/a while it might not be true :-)
[5] It's possible (or even likely?) that BIOS Setup data is stored in EEPROM on a PC

 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Fri. May 5, 2017 - 06:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I managed to solve my problem gracefuly!:_

 

const char PROGMEM ErrorArray1[] = "testa";
const char PROGMEM ErrorArray2[] = "testaaa";
const char PROGMEM ErrorArray3[] = "test";
const char PROGMEM ErrorArray4[] = "test";
const char PROGMEM ErrorArray5[] = "testdddddd";
const char PROGMEM ErrorArray6[] = "test";
const char PROGMEM ErrorArray7[] = "test";
PGM_P const ErrorArray8[][3] PROGMEM = {{ErrorArray1,ErrorArray2},{ErrorArray3,ErrorArray4},{ErrorArray5,ErrorArray6,ErrorArray7}};

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AND a 3 multi array of pointers and the 4th array being char array

    const char PROGMEM ErrorArray1[] = "testa";
    const char PROGMEM ErrorArray2[] = "testaaa";
    const char PROGMEM ErrorArray3[] = "test";
    const char PROGMEM ErrorArray4[] = "test";
    const char PROGMEM ErrorArray5[] = "testdddddd";
    const char PROGMEM ErrorArray6[] = "test";
    const char PROGMEM ErrorArray7[] = "test";
    PGM_P const ErrorArray8[][2][3] PROGMEM = {{{ErrorArray1,ErrorArray2},{ErrorArray3,ErrorArray4}},{{ErrorArray5,ErrorArray6,ErrorArray7}}};

Last Edited: Sat. May 6, 2017 - 03:40 AM

Pages