please explain the following Header file written for lcd (keil 89s510

Status
Not open for further replies.

thannara123

Advanced Member level 5
Joined
Jan 7, 2010
Messages
1,580
Helped
122
Reputation
244
Reaction score
114
Trophy points
1,353
Location
Usa
Activity points
10,382
Dear experts i have got a Lcd program but i didnt get the output in Proteus
what are the Pins for Enable ,rs .and data please help me

i am pasting the program as follows

#define LCD_en P3_1
#define LCD_rs P3_0
#define LCD_DELAY 1535 /* Delay for 1 ms */
#define LCD_clear() LCD_command(0x1) /* Clear display LCD */
#define LCD_origin() LCD_command(0x2) /* Set to origin LCD */
#define LCD_row1() LCD_command(0x80) /* Begin at Line 1 */
#define LCD_row2() LCD_command(0xC0) /* Begin at Line 2 */

/***************************************************
* Prototype(s) *
***************************************************/
void LCD_delay(unsigned char ms);
void LCD_enable();
void LCD_command(unsigned char command);
void LCD_putc(unsigned char ascii);
void LCD_puts(unsigned char *lcd_string);
void LCD_init();

/***************************************************
* Sources *
***************************************************/
void LCD_delay(unsigned char ms)
{
unsigned char n;
unsigned int i;
for (n=0; n<ms; n++)
{
for (i=0; i<LCD_DELAY; i++); /* For 1 ms */
}

}

void LCD_enable()
{
LCD_en = 0; /* Clear bit P2.4 */
LCD_delay(1);
LCD_en = 1; /* Set bit P2.4 */
}

void LCD_command(unsigned char command)
{
LCD_rs = 0; /* Clear bit P2.5 */
P2 = (P2 & 0xF0)|((command>>4) & 0x0F);
LCD_enable();
P2 = (P2 & 0xF0)|(command & 0x0F);
LCD_enable();
LCD_delay(1);
}

void LCD_putc(unsigned char ascii)
{
LCD_rs = 1; /* Set bit P2.5 */
P2 = (P2 & 0xF0)|((ascii>>4) & 0x0F);
LCD_enable();
P2 = (P2 & 0xF0)|(ascii & 0x0F);
LCD_enable();
LCD_delay(1);
}

void LCD_puts(unsigned char *lcd_string)
{
while (*lcd_string)
{
LCD_putc(*lcd_string++);
}
}

void LCD_init()
{
LCD_en = 1; /* Set bit P2.4 */
LCD_rs = 0; /* Clear bit P2.5 */
LCD_command(0x33);
LCD_command(0x32);
LCD_command(0x28);
LCD_command(0x0C);
LCD_command(0x06);
LCD_command(0x01); /* Clear */
LCD_delay(256);
}





#include <at89x52.h>
#include "lcd.h"

main( )
{
LCD_init();
LCD_row1(); LCD_puts("Hello World");
LCD_row2(); LCD_puts("Good Morning");
while (1);
}
 

i gived e- P3_1
rs- P3_0
P2 as data but not working
 

if you are using 16x2
then enable routine is wrong. it should be
en=1;
delay(1);
en=0;

LCD initialization i also wrong
it should be
LCD_Command(0x38);
LCD_Command(0x01);
LCD_Command(0x06);
LCD_Command(0x0E);

Rajbabu
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…