Having such a hard time with PROGMEM.......resets ESP....
Posted: Mon Oct 26, 2015 9:02 pm
Hi,
I am having such a hard time reading from PROGMEM. Below is a sample program that I though would work, but it causes the ESP to reboot/reset. Any ideas what I am doing wrong here. FYI this is being compiled and uploaded in the Arduino IDE.
Appreciated
Mark.
I am having such a hard time reading from PROGMEM. Below is a sample program that I though would work, but it causes the ESP to reboot/reset. Any ideas what I am doing wrong here. FYI this is being compiled and uploaded in the Arduino IDE.
Appreciated
Mark.
Code: Select all
#include <pgmspace.h>
static const char PROGMEM Line1[] = {"String 1"};
static const char PROGMEM Line2[] = {"String 2"};
static const char PROGMEM Line3[] = {"String 3"};
const char * const Lines [] PROGMEM = { Line1, Line2, Line3 };
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
delay(5000);
char buffer[20] = {0};
strcpy_P(buffer, (char*) pgm_read_word( &(Lines[0]) ) );
Serial.print("buffer=");
Serial.println(buffer);
}
void loop() {
// put your main code here, to run repeatedly:
}