Unable to diplay characters on ks0108 GLCD

I have a ks0108 GLCD screen connected to an arduino uno. The example sketch from the GLCD 3 library works perfect when I compile and upload the code through the ardunio GUI. However, when I compile and upload it through eclipse, everything works fine except for characters. The bitmap, counter, and numbers still display correctly but not characters.

One or two random characters will display in the correct location but that is it. The problem seems to occur at the GLCD.Puts("string to print here"); method.

I greatly prefer using eclipse and it has worked great up until now. What would make the difference? The main code is exactly the same, as well as the hardware connections, operating system, everything.

In eclipse, I copied the GLCD 3 library into my workspace and made sure all of the header and cpp files were linked correctly. The code compiles, uploads, and runs fine except for the characters not being displayed correctly.

I'm using ubuntu 10.04 linux if that makes any difference.

I really appreciate any and all help.

Thanks, Chris

I assuming you are runnng the GLCDdemo.pde sketch?

This is very strange. Everything eventually should call the PutChar() function to do the actual character rendering.

I've not used eclipse yet so I'm not versed in how it is used to build arduino sketches. I am very familiar with Makefiles (been using them for 25+ years) and I'm curious how you are building the arduino libraries and your sketches under eclipse as there is some ugliness that is done in the IDE that I assume you are having to mimick.

What do you mean by:

I copied the GLCD 3 library into my workspace and made sure all of the header and cpp files were linked correctly.

Numbers used as function arguments (to say print()) will not be stored in the flash, they will be passed in registers, while strings will be stored in flash.

It almost sounds like the strings in flash aren't working correctly, like the startup code isn't copying them into RAM or maybe the data section was not included in the .hex file.

Maybe check the linker options or the objcopy options.

To test it you could try adding a few lines to print characters with/without using flash. If there is a string/flash issue then things like sending a single character as in

GLCD.PutChar('h');GLCD.PutChar('e');GLCD.PutChar('l');GLCD.PutChar('l');GLCD.PutChar('o');

should work,

But

GLCD.Puts("hello");

will not.

--- bill

I tried your suggestion and you were exactly right. Printing characters worked fine while strings did not.

As far as building the arduino libraries under eclipse, I followed a couple different tutorials online about building a static library and then including it in my project. I won't lie, it was a huge pain. If your interested, I can find the link and send it to you. I pretty much followed it verbatim.

You asked

What do you mean by:

I copied the GLCD 3 library into my workspace and made sure all of the header and cpp files were linked correctly.

I copied the .cpp and .h files from the library that I was to use and made sure to fix the paths of the #include s. I then included the necessary files in my program.

You mention

the startup code isn't copying them into RAM or maybe the data section was not included in the .hex file.

I am unsure what I should be looking for to check this. Could you explain a little bit more?

Thank you for helping me find where the problem is. I'll fiddle around with it and let you know if I figure anything out. If you have any more suggestions, I'd love to hear them.

Thanks, Chris

Copying to RAM: When you have initialized data such as char *s = "xxx"; or int y=42;

The value of those variables must be stored in FLASH and then initialized to the real variable which is in RAM. All these initialized variables are stored in a special section by compiler.

2 things must happen in order for them to be used properly.

1) the data section must be properly extracted from the final linked image when creating the .hex image that is to be downloaded to flash.

2) the tiny C runtime code (which is some assembler code) that runs before any C code that sets up the C environment (things like stack, int vectors, and initialized data) must run. In this case the thing it must do is copy the initialized data section from flash into RAM to properly set all the initial values of the initialized data variables. It is a small loop that simply copies the data from flash to RAM.

I'm not sure how the eclipse environment you are using builds the sketch and does the download but this sounds like a linker problem or an avr-objcopy problem.

The linker may not be being given the correct flags or linking against the correct files/libraries.

avr-objcopy determines which sections inside the linked image get moved to the .hex file.

Sometimes this kind of problem may not be seen if interrupts or initialized data are not being used.

Even if initalized data is used, it still my not show up depending how the variable is used. For example. If you have something like int y=42; or const int y = 42;

and then only use that in a single .pde file and only assign it to other variables and never modify it, the compiler will eliminate it completely as it is not really needed to be variable. The compiler will use an inline constant instead so the data section and hence flash storage is not used for that variable.

But it is definitely a problem that needs to be addressed as it will eventually show up and "break" other code as well.

My suspicion is that either the linker flags are not quite correct or the linker is not linking the correct files, or the objcopy command is not being given correct information.

--- bill