How to retreive & display on LCD a string stored in rom

Thread Starter

NorwegianFunk

Joined Nov 8, 2009
6
Hey guys, this is my first post to the forum, and I am also pretty new to PIC programming, and C as well.

I need to display a menu that I made using 30+ strings on an oled display (works the same as an LCD, to my knowledge), on the PIC18F46K20 starter kit.

So it worked until I ran out of RAM. Now that I learned how to store the strings in program memory (calling them const rom unsigned char string1[]), I have saved space. And I know it was saved correctly, because if I view the program memory viewer in mplab, it shows up.

My question is: how can I retreive these saved strings and display them on the OLED screen? Currently, all that I see is jumbled garbage.

Thanks!
-Funk
 

Kanutus

Joined Nov 12, 2009
1
Could it be that you only need to convert the values back to ASCII somehow? Do you notice if there is a consistency in what you get back? Say you write (and retrieve) something like "ABCDEFGHIJK ..." what does that look like when you try to display it?

Hey guys, this is my first post to the forum, and I am also pretty new to PIC programming, and C as well.

I need to display a menu that I made using 30+ strings on an oled display (works the same as an LCD, to my knowledge), on the PIC18F46K20 starter kit.

So it worked until I ran out of RAM. Now that I learned how to store the strings in program memory (calling them const rom unsigned char string1[]), I have saved space. And I know it was saved correctly, because if I view the program memory viewer in mplab, it shows up.

My question is: how can I retreive these saved strings and display them on the OLED screen? Currently, all that I see is jumbled garbage.

Thanks!
-Funk
 

maxpower097

Joined Feb 20, 2009
816
Like Kanutus said is there a rhyme or reason to the numbers? When I was working with an old PIC16 and had to do some menu work, much like yours, when the char's would display on the LCD they were all off by 30 digits. Then I learned you just had to add or subtract 30 digits, I forget, to all the chars and they all displayed correctly.
 

Thread Starter

NorwegianFunk

Joined Nov 8, 2009
6
There does not seem to be any rhyme or reason to it.

The main menu of my program is supposed to display 4 lines: a title and then 3 options. But what is displayed is literally the following:

"j
d!A@ @@X@@X@A>@<$sil" - and looks like it still continues off the screen.

If I just try to print a single string, it usually displays 2 characters: a $, and a random letter or @ symbol.
 

BMorse

Joined Sep 26, 2009
2,675
There does not seem to be any rhyme or reason to it.

The main menu of my program is supposed to display 4 lines: a title and then 3 options. But what is displayed is literally the following:

"j
d!A@ @@X@@X@A>@<$sil" - and looks like it still continues off the screen.

If I just try to print a single string, it usually displays 2 characters: a $, and a random letter or @ symbol.

Sounds like BAUD rate problems...... If you just send a Hexadecimal value, straight out the TX buffer, does it display properly?? (example: send 0X41, should display a capital "A".) if not I would say BAUD Rate.......

I ran into a similar Problem with the PIC16F887, I am using a Serial VFD (Vacuum Fluorescent Display), and I was just getting garbage on the display, then I realized I set 1 bit wrong in the SPBRG register......


My .02
 

Thread Starter

NorwegianFunk

Joined Nov 8, 2009
6
Thanks for your suggestion, I may try that next.

But since I didn't check the post until now, I figured that perhaps I am suppose to merely declare the string (which is a char []) as global. Then, in each function I can instantiate it. This way, I won't need to save them to program memory, hence being able to use it in RAM right there, calling over and over again a small number of strings.

I think I am making some progress, but right now it gives me the errors:

Error [1153] cannot assign array type objects
Error [1102] cannot assign to 'const' modified object
Error [1131] type mismatch in assignment

Perhaps I just need to understand how arrays are called better.

Here are snippets of my code:

//global
#pragma udata

unsigned char string1[];
unsigned char string2[];
unsigned char string3[];

//inside function A
string1 = "Pick a mode: \n";
string2 = "Mode A \n";
string3 = "Mode B \n";
 
Top