• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18F4550 XLCD putsXLCD vs putrxXLCD

Not open for further replies.


New Member
So I'm trying to get my little LCD up and running on my PIC18F4550. I got putcXLCD to work just fine and I think my microchip is communicating fine. I can get putrsXLCD to work however trying to use putsXLCD in any form just causes garbage on the screen.

Here's what my main function looks like:

void main(void)
	const char* message = "Test Message";

	while(1) {}
I'm having trouble wrapping my head around why putsXLCD would get garbage for string data. Is it because it's declared as a local variable? If I change the storage qualifier to rom and use putrsXLCD everything works fine.


Well-Known Member
Most Helpful Member
It is due to the different types of pointers available on a Pic. The various subroutines can take ROM or RAM pointers. If a ROM pointer is used then the code uses the Table read commands to access the data, if RAM then the FSR register is used. If you pass a RAM pointer to a function that expects a ROM pointer then it reads garbage from the ROM area instead of the data from the RAM area. Likewise if you pass a ROM pointer to a function expecting a RAM pointer. Unfortunately Microchip didn't implement a function to distinguish between the two pointer types and so invariably two functions have to be written. For completeness I should mention that there are actually 4 pointer types as there are also near and far pointers.

I hope that makes sense.



New Member
I understand that for the most part, I'm just trying to figure out why ROM puts works fine but normal RAM doesn't. Luckily printf rerouted through putcXLCD works flawlessly so I'll just stick with that for now.
Not open for further replies.

EE World Online Articles