Toll-Free Customer Support 24/7

8051 Development Board

/*
 * Project name:
    8051 Development Board
 * Copyright
     (c) Researchdesignlab.com
 * Description:
    
 * Test configuration:
     MCU:             AT89S52
     Dev.Board:       8051
     Oscillator:      11.0592 MHz
     Software:        Keil uVision3

*/
include<reg51.h>
#define LCD_PORT P2
sbit rs=P3^5;
sbit en=P3^7;
sbit D7=P2^7;
sbit rw=P3^6; 

void busy();
void CMD_WRT(unsigned char);
void LCD_WRT(unsigned char *);
void DATA_WRT(unsigned char);
void DELAY();
void main()
 {
unsigned char CMD[]={0x38,0x01,0x0f,0x06,0x80},TEMP1,i;
    for(i=0;i<5;i++)
   {
    TEMP1=CMD[i];
	CMD_WRT(TEMP1);
   }
        DELAY();
	 	CMD_WRT(0X01);
 	    CMD_WRT(0X80);
	    LCD_WRT("16X2 LCD DISPLAY");
	    DELAY();
		DELAY();
		while(1);

 }
      void DELAY()
      {
	  unsigned int X=6000000;
	  while(X--);
      }
      void busy()
     {
	   D7=1;
	   rs=0;
	   rw=1;
	   while(D7!=0)
	   {
		en=0;
		en=1;
	   }
     } 



	void CMD_WRT(unsigned char val)
	{
	busy();
	LCD_PORT=val;
	rs=0;
	rw=0;
	en=1;
	en=0;
	}

	void LCD_WRT(unsigned char *string)
	{
	while(*string)
	DATA_WRT(*string++);
	}
	void DATA_WRT(unsigned char ch)
	{
	busy();
	LCD_PORT = ch;
	rs=1;
	rw=0;
	en=1;
	en=0;
	}

Back to top