I would like to store the menu title in FLASH memory and the print over serial and over the oled display.
In the menu struct I want to store the pointer to title, but when I try to read the FLASH memory with the code below I can't get any string, actually my arduino uno reboot continuously. I think that I try to read a NULL address value.
Your menu structures are not in FLASH so no need to read the pointer from FLASH. Just fetch the pointer and pass it to the function that knows it points to FLASH:
I would like to store the menu title in FLASH memory and the print over serial and over the oled display.
In the menu struct I want to store the pointer to title, but when I try to read the FLASH memory with the code below I can't get any string, actually my arduino uno reboot continuously. I think that I try to read a NULL address value.
pgm_read_word() returns a word (16bit value from program Memory, The AVR CPU's are Harvard architecture, The program memory is totally separate from the data memory.
you have to copy each byte or word from Program Memoryto a DATA
Your code was reading the first two characters (word) from PROGMEM then treating this Word value as a pointer into DataRam, and moving a random number of bytes into your 30 byte buffer, strcpy_p() assumes null terminated Strings. If the two character "pointer" resulted in an address outside of physical RAM (0x0000 .. 0x08FF for UNO, 0x0000 .. 0x021FF for MEGA2560) the value read would be 0xFF. NEVER ZERO.
So all of the time a pointer made from two displayable characters pointed outside of 'real' RAM, so effectively every time this code executed you filled from buffer[0] to buffer[0xFFFF] with 0xff. Totally destroying all variables, All of the Stack.