error: 'PSTR' was not declared in this scope
example:
Serial.print(F("FAIL")); //print the word 'FAIL' from flash memory, not RAM
vs.
Serial.print("FAIL"); //print the word 'FAIL' from RAM, but this uses RAM very fast
Why am I getting this compile error in Aruino 1.52? Do I need to add another library to be able to simply print from flash on the serial ports or using the LCD library?
http://arduino.cc/forum/index.php/topic,153761.0.html
I can't tell, but is the above thread a solution, or work in progress?
copying this into my header fixed it for me for now.
#if defined(__SAM3X8E__)
#define PROGMEM
#define pgm_read_byte(x) (*((char *)x))
// #define pgm_read_word(x) (*((short *)(x & 0xfffffffe)))
#define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))
#define pgm_read_byte_near(x) (*((char *)x))
#define pgm_read_byte_far(x) (*((char *)x))
// #define pgm_read_word_near(x) (*((short *)(x & 0xfffffffe))
// #define pgm_read_word_far(x) (*((short *)(x & 0xfffffffe)))
#define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))
#define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))))
#define PSTR(x) x
#if defined F
#undef F
#endif
#define F(X) (X)
#endif
cmaglie has done this already:
see Add compatibility layer for avr/progmem on Arduino Due · Issue #1317 · arduino/Arduino · GitHub
If you manage to run the version from github it should work,
IF you manage...
(as I still don't)
OutOfLine:
cmaglie has done this already:
see Add compatibility layer for avr/progmem on Arduino Due · Issue #1317 · arduino/Arduino · GitHub
If you manage to run the version from github it should work,
IF you manage...
(as I still don't)
A howto to build an IDE from the git files is there
http://code.google.com/p/arduino/wiki/BuildingArduino
Are you sure
Serial.print("FAIL");
Uses RAM on the Due. I would have thought on the ARM architecture constants are kept in flash anyway and the P macro is redundant.
Rob
Graynomad:
Are you sure
Serial.print("FAIL");
Uses RAM on the Due. I would have thought on the ARM architecture constants are kept in flash anyway and the P macro is redundant.
Rob
I'm pretty sure, unless they changed it in the last few versions. My game has a lot of text and the RAM function I run will show FREE RAM go up alot when converting to flash memory storage.
int freeRam(void)
{
extern int __bss_end;
extern int *__brkval;
int free_memory;
if((int)__brkval == 0) {
free_memory = ((int)&free_memory) - ((int)&__bss_end);
}
else {
free_memory = ((int)&free_memory) - ((int)__brkval);
}
return free_memory;
}
/////called in the upgrade code/regen function like this
void RAM()
{
clearLCD();
mySerial.print(F("Free RAM: ")); //debug code
mySerial.print(freeRam()); //debug code
}
zachtos:
... and the RAM function I run will show FREE RAM go up alot when converting to flash memory storage.
int freeRam(void)
{
extern int __bss_end;
extern int *__brkval;
int free_memory;
if((int)__brkval == 0) {
free_memory = ((int)&free_memory) - ((int)&__bss_end);
}
else {
free_memory = ((int)&free_memory) - ((int)__brkval);
}
return free_memory;
}
}
Had tried that a while ago. I could not figure out how to get __bss_end and __brkval defined...
I just used the RAM(); function in my main loop to print the FREE ram to screen, I did not change anything else, copy paste was it. I think that came from the WaveHC library files.
Well I guess one way of testing it is to try printing a string over 96K long...
void setup() {
Serial.begin(1200);
}
void loop() {
Serial.print(
"\n"
"ACT I\n"
"SCENE I. A desert place.\n"
"\n"
" Thunder and lightning. Enter three Witches \n"
"\n"
"First Witch\n"
"\n"
" When shall we three meet again\n"
" In thunder, lightning, or in rain?\n"
"\n"
"Second Witch\n"
"\n"
" When the hurlyburly's done,\n"
" When the battle's lost and won.\n"
"\n"
"Third Witch\n"
"\n"
" That will be ere the set of sun.\n"
"\n"
... over 100K later....
"MALCOLM\n"
"\n"
" We shall not spend a large expense of time\n"
" Before we reckon with your several loves,\n"
" And make us even with you. My thanes and kinsmen,\n"
" Henceforth be earls, the first that ever Scotland\n"
" In such an honour named. What's more to do,\n"
" Which would be planted newly with the time,\n"
" As calling home our exiled friends abroad\n"
" That fled the snares of watchful tyranny;\n"
" Producing forth the cruel ministers\n"
" Of this dead butcher and his fiend-like queen,\n"
" Who, as 'tis thought, by self and violent hands\n"
" Took off her life; this, and what needful else\n"
" That calls upon us, by the grace of Grace,\n"
" We will perform in measure, time and place:\n"
" So, thanks to all at once and to each one,\n"
" Whom we invite to see us crown'd at Scone.\n"
"\n"
" Flourish. Exeunt\n"
);
}
Believe it or not, it works
macbeth.ino (128 KB)