
<font color=green>
/*************************************
| "LCDtest6.c"
| LCD command/data transmittal
| program for ATMEL (Temic)T80C51 
| microcontroller
======================================
| Tests initialization of a 2x16
| LCD 44780-based display module, 8 bit 
| dat/cont. sent, 2 control bits:
| RS = control/data = 0/1 = P3.2
| E = enable = P3.4
| R/W* = P3.3
| P1 = output
| (P3 = output)
| IE = interrupts disabled
|--------------------------------------
| 8/4/04 Marty McLeod
| IDE: Keil uVision2 Eval V7
---------------------------------------*/</font>

#include <reg5101.h>


unsigned int i;
unsigned int j;

//Function prototypes here
void DELAY(void);
void NOP(void);

//Begin main of program

void main(void)
{

	//Initialize 8051 SFRs:
	IE = 0;		//Disable interrupts
	P1 = 0x00;	//Set port 1 to OUTPUT
	P3 = 0x00;	//Set port 3, all bits, to OUTPUT
	//
	PSW = 0x00;	//Clear program status word PS

	while(1)
	{
	/********************************************/
	//Attempt to do partial initialization:
	DELAY();
	DELAY();
	
	//Command: for 8 bit, 2 lines
	P3_2 = 0;	//RS = control
	P3_4 = 1;	//E = true then post command, then wait...
	P1 = 0x38;	//8 bit, 2 lines
	DELAY();	//wait
	P3_4 = 0;	//Toggle E low
	//
	DELAY();
	DELAY();
	//Command: clear
	P3_2 = 0;	//RS = control
	P3_4 = 1;	//E = true then post command, then wait...
	P1 = 0x01;	//Display on, cursor off
	DELAY();	//wait
	P3_4 = 0;	//Toggle E low
	//	
	DELAY();
	DELAY();
	//Command: on
	P3_2 = 0;	//RS = control
	P3_4 = 1;	//E = true then post command, then wait...
	P1 = 0x0C;	//Display on, cursor off
	DELAY();	//wait
	P3_4 = 0;	//Toggle E low
		
	}//while(1) end

}//main(void)

/****************************/
/* Functions defined below */

void DELAY(void)
  {
	for(i = 0; i < 3000; ++i)
		{
			NOP();
		}
  }

void NOP(void)
	{
		j = 0;
	}
<font color=green>
/**** END OF FILE ****/</font>