Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: can't assign String array to PROGMEM?

  1. #1
    Senior Member
    Join Date
    Apr 2020
    Location
    Tucson
    Posts
    135

    can't assign String array to PROGMEM?

    When I try to build this it works fine as is, however if I try to make either of the String tables file miditables.h to PROGMEM I get a compiler error on the next set

    In file included from /tmp/arduino_build_451560/sketch/messages.h:1:0,
    from /home/brad/Arduino/knobby/knobby.ino:53:
    display.h: In function 'void sendmessage(String, float)':
    display.h:2: error: chargen causes a section type conflict with mixmsgs
    PROGMEM const unsigned char chargen[][12] = {
    ^
    In file included from /home/brad/Arduino/knobby/knobby.ino:13:0:
    /tmp/arduino_build_451560/sketch/miditables.h:133:22: note: 'mixmsgs' was declared here
    PROGMEM const String mixmsgs[96] = {"Ext In:",

    Can someone explain this error to me? I don't understand why it compiles just fine if it's not PROGMEM, but crashes otherwise. An since it's a const, isn't it just in program memory anyway?

    Thanks
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,476
    See this thread, especially Paul's answer in message 9.

    Pete

  3. #3
    Senior Member
    Join Date
    Apr 2020
    Location
    Tucson
    Posts
    135
    Thanks heaps. It's a clue, but using it as below also did not work:

    const String midiprompts[64] PROGMEM = {"Main Mix A",

    After commenting out the character generator table I tried again and this time the compile ends with

    noteFreqs causes a section type conflict with midiprompts

    noteFreqs is a table of floats, and midiprompts is the table of strings. It seems like trying to put Strings in the PROGMEM crashes it no matter how I try. Edit: OK I think I get it. Not worth it

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,985
    You can put a char array into flash, but not String because String is a C++ object.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •