100% found this document useful (1 vote)
81 views

LCD Display

This document contains code for an LCD demo using an Nvis 5001A microcontroller. It includes initialization code and functions to write strings and characters to the LCD. The main function initializes the LCD, clears the display, displays a company name, and then continuously clears and redisplays an LCD demo message while in an infinite loop.

Uploaded by

NARENDRA SENCHA
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
81 views

LCD Display

This document contains code for an LCD demo using an Nvis 5001A microcontroller. It includes initialization code and functions to write strings and characters to the LCD. The main function initializes the LCD, clears the display, displays a company name, and then continuously clears and redisplays an LCD demo message while in an infinite loop.

Uploaded by

NARENDRA SENCHA
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

/******************************************************************************

* FileName: Main.c
* Processor: AT89C52
* Complier: Keil
* Keil IDE
* Company: Nvis Technologies Pvt. Ltd.
*
***********************************************************************************
***********
*File - LCD_Demo code with Nvis 5001A
* Step of operation:
* 1.Select PC mode and put toggle switch in PC mode of Nvis 5001A
* 1.Burn LCD Display.hex file generated in keil with Nvis 5001A programmer
setup
* 2.After Burn file finished put toggle switch into Run mode and Press Run
button in software
*
* Output: Fisrt "Nvis Technologies" display in few second and after "Nvis 5001A""
LCD Demo code"
* display continue.
***********************************************************************************
************
* Change History:
* Name Date Changes
* RajKumar 08/05/13 Initial Version
***********************************************************************************
**********/
#include <REGX52.H>

#define LCDPORT P0

#define RS P0_2
#define E P0_3

/****************************Delay
routine****************************************************/
void delay(unsigned int rTime) //Function to provide time delay.
{
unsigned int i,j;

for(i=0;i<rTime;i++)
for(j=0;j<775;j++);
}
/********** Initialize LCD Routine *****************/
bit status=0;

void lcd_init_write(unsigned char a)


{
delay(1);
RS=0;
LCDPORT=a;
E=1;
delay(15);
E=0;
}
void LCD_Cmd(unsigned char a)
{
unsigned char temp;
if(status)
{
status=0;
goto a;
}
RS=0;
a:
temp=a;
temp&=0xF0;
LCDPORT&=0x0F;
LCDPORT|=temp;
E=1;
delay(5);
E=0;
temp=a<<4;
temp&=0xF0;
LCDPORT&=0x0F;
LCDPORT|=temp;
E=1;
delay(5);
E=0;
}
void LCD_Data(unsigned char a)
{
status = 1;
RS = 1;
delay(2);
LCD_Cmd(a);
}
void LCD_Init(void)
{
status = 0;
delay(3);
lcd_init_write(0x30);
delay(3);
lcd_init_write(0x30);
delay(3);
lcd_init_write(0x30);
delay(3);
lcd_init_write(0x20);
delay(3);
LCD_Cmd(0x28);
delay(3);
LCD_Cmd(0x04);
delay(3);
LCD_Cmd(0x85);
delay(3);
LCD_Cmd(0x06);
delay(3);
LCD_Cmd(0x0C);
delay(3);
LCD_Cmd(1);
delay(3);
}
/*************** Write Srting to LCD ***************/
void LCD_Disp(unsigned char Loc,unsigned char *String)
{
LCD_Cmd(Loc);
delay(5);
while(*String)
{
LCD_Data(*String++); /* write data to LCD */
// delay(1);
}
}
/*************** Write Charactor to LCD ***************/

void Display_CompanyName()
{
LCD_Disp(0x80," C.I.D.I. ");
LCD_Disp(0xC0," S.G.S.I.T.S. ");
}

/******************************************************************************/
/* main function
******************************************************************************/
void main (void)
{
P0 = 0x00;
delay(5);
LCD_Init(); /* Initialize LCD
*/
delay(50);
LCD_Cmd(0x01); /* Clear Display
*/
delay(20);
Display_CompanyName(); /* Display Company Name */
delay(400);
while(1)
{
LCD_Cmd(0x01);
delay(50);
LCD_Disp(0x80," Nvis 5001A ");
LCD_Disp(0xC0," LCD Demo code ");
delay(800);
}
}

You might also like