The ü expedient

Hi all! I’ve a really strange error with my Arduino. I’m developing an application wich includes a LCD menu to configure settings of the system.
I register the position of the menu where I’m and call a function passing the position to retrieve the text to show. The function is this:

char* Line1(int _PosMenu){
    case 0: return "";
    case 1: return "My Text1";
    case 2: return "My Text2";
    case 3: return "My Text3";
    case 4: return "My Text4";
    case 5: return "My Text5";
    case 6: return "My Text6";
    case 7: return "";
    case 8: return "";
    case 9: return "";
    case 10: return "My Text10";
    case 17: return "My Text17"; 
    case 39: return "My Text39";
    case 40: return "My Text40";

Look that in some cases (0,7,8,9) it returns nothing because the option menu needs no text.

THE problem: When I call Line1(17) I get “My Teüt17” instead of “My Text17” :o
The rest of the texts arre returned correctly just this one is “out of law”.

I’ve tried this change in the code:

case 17: return "My Te";

But in this case what I get when call Line1(17) is “My Te’My Text20”. It looks like if the returned text has no line feed and it gets some garbage text from around.

My (strange) hypothesis is this: code is stored in the flash and for some reason the position of the memory where ‘x’ of line 17 is stored is overwrited with some character anywhere in the code. :-/

Anyone can give some light to solve “the ü expedient”


You have a lot of strings in just that function. I’d suspect that you are running out of memory, and stepping on code somewhere else in the application. Look at the ASCII table to see what value the ü represents.

Thanks Paul for your answer! When you say run out of memory, do you mean RAM memory? I used to store the strings in variables but yes, I ran out of RAM memory. So I decided to change and hardcode the strings in a function guessing that this text would be placed in Flash instead of RAM. It worked memory problems went by!

The application is 13kB (max is 30kB) so I guess I'm not out of memory. Also, if it was a running out memory problem, why the next lines (18 to 40) returns text OK?

So strange!

Happy reading :)

Happy reading

Especially that part about different types of memory.

Hi guys! Yeah, I read quite a lot about PROGMEM and also about another library for write in FLASH (I don't remember the name). But I decided not to use because it didn't gave me some flexibility I wanted, moreover it should be the same don't u think? I mean, PROGMEM is used to store read only data in FLASH, but all the code of the program should also be stored in FLASH so... why it doesn't return the text only of the line 17?

Here is where your RAM goes:

in this is the way to avoid it

(it's progmem you need in the end ... ) Eberhard

:o so the strings are stored finally in RAM even if they are hardcoded!

Used PROGMEM and ü disapeared.

Thank you all folks! wayoda thanks for the links ;)