Guest
#1485759
Hello Community! I would like to create a self-defined structure for a configuration (for Timers, UARTs, etc.) and store different configurations in an array. The described concept works great when everything is stored in SRAM. But as these differente configurations would be constant, and only be read at run-time, I would like store them in Flash-memory and not waste SRAM. However, when i try to define them as Flash-memory using the PROGMEM attribute, I get the following error-message in avr-gcc: "main.c 47 warning: initialization discards qualifiers from pointer target type main.c 49 warning: initialization discards qualifiers from pointer target type" Here is a minimal example code that procudes these errors. The code defines a structure and thenn tries to declare a an array of this structe once in SRAM (this works) and once in Flarh (doesn't work). Everything that should be in Flash has a _P appended. An appended _h means "handler". The defines for ConfigLine_tP and ConfigLine_hP are because of a warning with the corresponding typedefs, but I will see about this on later. First I would like to be able to compile the file.
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
I would be glad if anyone could explain me what happens here/why it doesn't work or point me to a Flash/PROGMEM-Tutorial that covers more details than "Storing constant strings" in Flash. best regards, Wolfgang