dlchambers
Well-known member
The Arduino F() macro places a string literal in PROGMEM (reducing the RAM footprint)
I'm using a Teensy 3.2, and need more RAM space, so I wrapped a number of Serial.print() strings in F().
But I saw no change in the mem sizes of Flash & RAM.
So I grepped for F() and found these defs:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy\WString.h:
#define F(string_literal) ((const __FlashStringHelper *)(PSTR(string_literal)))
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\WString.h
#define F(string_literal) ((const __FlashStringHelper *)(string_literal))
which seems to explain it - the T3 macro doesn't use PSTR(), which is the thing that places it in Flash... on a T3 the F() macro has no effect.
Can anyone explain:
a) Why the teensy and teensy3 macros re different?
b) The "correct" way to make it work on a Teensy3?
Thanks,
-Dave
I'm using a Teensy 3.2, and need more RAM space, so I wrapped a number of Serial.print() strings in F().
But I saw no change in the mem sizes of Flash & RAM.
So I grepped for F() and found these defs:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy\WString.h:
#define F(string_literal) ((const __FlashStringHelper *)(PSTR(string_literal)))
C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3\WString.h
#define F(string_literal) ((const __FlashStringHelper *)(string_literal))
which seems to explain it - the T3 macro doesn't use PSTR(), which is the thing that places it in Flash... on a T3 the F() macro has no effect.
Can anyone explain:
a) Why the teensy and teensy3 macros re different?
b) The "correct" way to make it work on a Teensy3?
Thanks,
-Dave