GLCD Program

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
//////////////////////////////////////////
//		Graphics LCD Program			//
//			By Austin Salgat			//
//////////////////////////////////////////

#include 
#include 



void Enable(void)	//Toggle Enable Pin
{
	PORTD = PORTD | 0x04;	//Toggle Enable Pin ON
	_delay_loop_2(1000);
	PORTD = PORTD & 0xFB;	//Toggle Enable Pin OFF
	_delay_loop_2(1000);
}


void GLCD_Init(void)
{
	DDRB = 0xFF;	//Make PortB Output
	DDRD = 0xFF;	//Make PortD Output

	PORTB = 0x3F;	//Turn on Display
	PORTD = 0x00;
	Enable();

	PORTB = 0x40;	//Set Y Address to 0
	Enable();

	PORTB = 0xB8;	//Set Page Address to 0
	Enable();
}


void GLCD_Test()
{
	PORTB = 0x55;	//Display 01010101
	PORTD = PORTD | 0x01;

	int i;
	for ( i=0; i!=62; i++ )
	{
		Enable();
	}
}


int main(void)
{
	_delay_loop_2(30000);
	GLCD_Init();
	GLCD_Test();
}

Can you double check this code please? My LCD is unfortunately doing nothing, although it does have the backlight going and has proper wiring. I ran this code through the simulator and mimic'ed the ports to http://www.geocities.com/dincera... and it seems to be working, but the actual LCD does not do anything.

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

>> Can you double check this code please?

Yup, code is there alright!

/johan

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

Toggling Enable 62 times by itself isn't going to do much of anything!!Also, the init routine looks suspect to me.

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

And maybe the AVR is continuously resetting at the end of the main function.

Programmers never die
they just GOSUB without RETURN

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

The Enable toggling is to have the 01010101 byte be entered into the display to fill the first page. Unfortunately the damn thing got really hot and is likely dead. Have to return it to Mouser and get a new one. :(