Skip to content

Commit 623e3d8

Browse files
author
SimonePDA
authored
Merge pull request #359 from Artoria2e5/patch-2
Fix adoc syntax for PROGMEM
2 parents b6d8c53 + c9606c6 commit 623e3d8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Language/Variables/Utilities/PROGMEM.adoc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,30 @@ Store data in flash (program) memory instead of SRAM. There's a description of t
2121

2222
The `PROGMEM` keyword is a variable modifier, it should be used only with the datatypes defined in pgmspace.h. It tells the compiler "put this information into flash memory", instead of into SRAM, where it would normally go.
2323

24-
PROGMEM is part of the http://www.nongnu.org/avr-libc/user-manual/group\__avr__pgmspace.html[pgmspace.h] library. It is included automatically in modern versions of the IDE, however if you are using an IDE version below 1.0 (2011), you'll first need to include the library at the top your sketch, like this:
24+
PROGMEM is part of the link:http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html[pgmspace.h] library. It is included automatically in modern versions of the IDE, however if you are using an IDE version below 1.0 (2011), you'll first need to include the library at the top your sketch, like this:
2525

2626
`#include <avr/pgmspace.h>`
2727
[%hardbreaks]
2828

2929

3030
[float]
3131
=== Syntax
32+
3233
const dataType variableName[] PROGMEM = {data0, data1, data3...};
3334

34-
`dataType` - any variable type
35+
`dataType` - any variable type +
3536
`variableName` - the name for your array of data
3637

3738
Note that because PROGMEM is a variable modifier, there is no hard and fast rule about where it should go, so the Arduino compiler accepts all of the definitions below, which are also synonymous. However experiments have indicated that, in various versions of Arduino (having to do with GCC version), PROGMEM may work in one location and not in another. The "string table" example below has been tested to work with Arduino 13. Earlier versions of the IDE may work better if PROGMEM is included after the variable name.
3839

3940
`const dataType variableName[] PROGMEM = {}; // use this form` +
40-
`const PROGMEM dataType variableName[] = {}; // or this one`+
41-
`const dataType PROGMEM variableName[] = {}; // not this one
41+
`const PROGMEM dataType variableName[] = {}; // or this one` +
42+
`const dataType PROGMEM variableName[] = {}; // not this one`
4243

4344

4445
While `PROGMEM` could be used on a single variable, it is really only worth the fuss if you have a larger block of data that needs to be stored, which is usually easiest in an array, (or another C data structure beyond our present discussion).
4546

46-
Using `PROGMEM` is also a two-step procedure. After getting the data into Flash memory, it requires special methods (functions), also defined in the http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html[pgmspace.h] library, to read the data from program memory back into SRAM, so we can do something useful with it.
47+
Using `PROGMEM` is also a two-step procedure. After getting the data into Flash memory, it requires special methods (functions), also defined in the link:http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html[pgmspace.h] library, to read the data from program memory back into SRAM, so we can do something useful with it.
4748

4849

4950
--
@@ -185,6 +186,7 @@ The following code WILL work, even if locally defined within a function:
185186
const static char long_str[] PROGMEM = "Hi, I would like to tell you a bit about myself.\n"
186187
----
187188

189+
[float]
188190
=== The `F()` macro
189191

190192
When an instruction like :

0 commit comments

Comments
 (0)