HD44780 Read DDRAM

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys, I have a function for reading the DDRAM contents of the HD44780 LC Display.  Have a look below:

char get_character(int x, int y){

	// set DDRAM address
	system_set_cursor(x, y);

	pio_set(&ReadWrite_Pin);
	pio_set(&RegisterSelect_Pin);


	pio_configure(&D4_PinRead, 1);
	pio_configure(&D5_PinRead, 1);
	pio_configure(&D6_PinRead, 1);
	pio_configure(&D7_PinRead, 1);



	char character = 0;


	pio_clear(&Enable_Pin); msleep(1); pio_set(&Enable_Pin); msleep(1);


	character  = (0x01 & pio_get(&D7_PinRead)); character = character << 1;
	character |= (0x01 & pio_get(&D6_PinRead)); character = character << 1;
	character |= (0x01 & pio_get(&D5_PinRead)); character = character << 1;
	character |= (0x01 & pio_get(&D4_PinRead)); character = character << 1;

	pio_clear(&Enable_Pin); msleep(1); pio_set(&Enable_Pin); msleep(1);

	character |= (0x01 & pio_get(&D7_PinRead)); character = character << 1;
	character |= (0x01 & pio_get(&D6_PinRead)); character = character << 1;
	character |= (0x01 & pio_get(&D5_PinRead)); character = character << 1;
	character |= (0x01 & pio_get(&D4_PinRead));

	pio_clear(&Enable_Pin);

	// Configure Hardware Port
	pio_configure(&D4_Pin, 1);
	pio_configure(&D5_Pin, 1);
	pio_configure(&D6_Pin, 1);
	pio_configure(&D7_Pin, 1);

	return character;
}

As you can see its interfaced with 4-Bit mode.

But it keeps returning a 'SPACE'.

 

Anyone see whats wrong. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why reinvent the wheel? This has been done a 1000 times before? If you want to see how to do it start with Fleury

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Had a look at Fleury, to verbose.

Much prefer my own library clawson.

 

PS: not much difference in approach either!

Last Edited: Tue. Mar 17, 2020 - 09:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But certainly the Fleury library can help show the way.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At first glance, I would guess that you are using the '&' symbol where you should be using the '*' symbol.  So you are getting the address of the control pin instead of the current value of the control pin.

 

You are the first person that I've seen actually -read- the HD44780.  Usually people just write to the unit and view the LCD display of the characters.  The text that is written is stored and edited in an AVR SRAM buffer before it is written to the LCD display.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:

At first glance, I would guess that you are using the '&' symbol where you should be using the '*' symbol.  So you are getting the address of the control pin instead of the current value of the control pin.

 

You are the first person that I've seen actually -read- the HD44780.  Usually people just write to the unit and view the LCD display of the characters.  The text that is written is stored and edited in an AVR SRAM buffer before it is written to the LCD display.

 

Very, very true Simonetta!

I was thinking that yesterday but it would have been nice to use the DDRAM as storage and not do it on the MPU as the code would be simpler.

 

PS: its for a simple consel on a 40*4 LCD.  where the text scrolls in the up direction.

So DDRAM Line 0 becomes DDRAM link 1

DDRAM Line 1 becomes DDRAM line 2

And so on.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fianawarrior wrote:

I was thinking that yesterday but it would have been nice to use the DDRAM as storage and not do it on the MPU as the code would be simpler.

 

 

But the access to the lcd is dog slow! I usually just rewrite the lcd - or if I've got ram to spare, only update the changed bytes.