Skip to content

Commit 40fab3d

Browse files
committed
Minor Content Update: Based on Comments
1 parent c2a7bb3 commit 40fab3d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

content/learn/03.programming/06.memory-guide/memory-guide.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ Not only Strings occupy SRAM space, but **global variables** also take up quite
317317

318318
`PROGMEM`, which stands for **Program Memory**, can be used to store variable data into Flash memory space, just as the `F()` wrapper described before, but the use of `PROGMEM` presents one disadvantage: data read speed. Using RAM will provide a much faster data read speed, but `PROGMEM`, as it uses Flash memory, will be slower than RAM, given the same data size. Thus, it is essential to design code knowing which variables are crucial and which do not or have a lower priority.
319319

320-
The use of `PROGMEM` in an AVR-based Arduino board is shown in the example code below:
320+
The use of `PROGMEM` in an **AVR-based Arduino® board** is shown in the example code below:
321321

322322
```arduino
323323
#include <avr/pgmspace.h>
@@ -332,6 +332,22 @@ const PROGMEM uint16_t NumSet[] = {0, 1, 1, 2, 3, 5, 8 ...};
332332
const char greetMessage[] PROGMEM = {"Something"};
333333
```
334334

335+
For **ARM-based Arduino® board**, to implement similar solution, we will need to use `static const` over the variables.
336+
337+
```arduino
338+
static const int Variable = Data;
339+
```
340+
341+
The usage differs in different levels summarized as following:
342+
- *Namespace Level*
343+
- At Namespace level, we are pointing at the variables and it is differed whether `static` is declared or not. If declared, it infers that the variable is explicit static; on the other hand, it is implicit static declaration.
344+
345+
- *Function Level*
346+
- If it is declared within `static`, any type of applicable data that is to be managed will be between function calls.
347+
348+
- *Class Level*
349+
- On a Class level, `static` declaration will mean any type of applicable data that is handled will be shared in between the instances.
350+
335351
***You can read more about PROGMEM in the [Arduino Language Reference](https://www.arduino.cc/reference/en/language/variables/utilities/progmem/).***
336352

337353
#### Non-Dynamic Memory Allocation

0 commit comments

Comments
 (0)