The Philippine Electronics and Technology Forum
February 10, 2012, 02:41:28 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  

Pages: [1]   Go Down
  Print  
Author Topic: LCD FOR 8051 written in C (keil)  (Read 1916 times)
glenndr_15
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 39



« on: June 13, 2009, 10:25:00 PM »

Hello po! need ko po ng LCD program in C ng keil sino po pwede mag share dyan?
thanks

best regards,
glenndr_15
Logged
The Philippine Electronics and Technology Forum
« on: June 13, 2009, 10:25:00 PM »

 Logged
toasted siopao
She loves me, she loves me not, she loves me...
Global Moderator
Diesel Generator
*****

Pogi/Ganda Points: 80
Offline Offline

Gender: Female
Posts: 1710



« Reply #1 on: June 13, 2009, 10:38:34 PM »

Search google for an LCD library for Keil C.
Logged

Enjoying the Australian outback.
ajak
Lead Acid Battery
*******

Pogi/Ganda Points: 50
Offline Offline

Gender: Male
Posts: 719



« Reply #2 on: June 14, 2009, 11:48:03 PM »

glenndr_15

me sumagot na sa thread mo sa sonsivri..
Logged
leoren_tm
Size AAA Battery
***

Pogi/Ganda Points: 2
Offline Offline

Posts: 87


« Reply #3 on: June 15, 2009, 04:06:58 PM »

if 2x16 lang nman ok to...http://8052.com/tutlcd
if gust mo nang ready made http://8052.com/codelib


peru mas ok kung gumawa ka from datasheet.
Logged
glenndr_15
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 39



« Reply #4 on: November 29, 2009, 02:19:06 PM »

glenndr_15

me sumagot na sa thread mo sa sonsivri..

may access ka din po ba  sa sonsivri?
Logged
glenndr_15
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 39



« Reply #5 on: January 03, 2010, 11:04:12 PM »

glenndr_15

me sumagot na sa thread mo sa sonsivri..

nakita na kita sa sonsivri pati yung thread mo hehe
Logged
engineer7@home
CR2032 Battery
**

Pogi/Ganda Points: 12
Offline Offline

Gender: Male
Posts: 42


Google Search--> Noel Rios Circuit Cellar


« Reply #6 on: March 30, 2010, 06:35:28 AM »

Here is an old set of routines used for a HD44780 based 2X16 LCD Module.  This is a quick test and I used a software delay instead of a timer based delay.

If you are a beginner, you can just ground pin 5 R/W pin of the LCD and use a software delay.  After some practice, you can read or poll the Busy Flag to see if the LCD Module has finished it's task.
Your microcontroller and LCD Module can be damaged because of bus contention due to error in the handshaking of the LCD and the Microcontroller.  By Grounding pin no.5 of the LCD, you just write to the LCD and the databus of the LCD is in Input mode,so nothing happens even if you make a mistake.
Please take note of the control pins and databus used.  Change according to your connection.

Code:

/* DEMO LCD ROUTINES USING 8 bit interface */
/*Author Noel A. Rios */
//Microcontroller: 89C52

#include <stdlib.h>
#include <reg52.h>


sbit LCDFLAG= P1^7;
sbit Enable = P0^2;
sbit RS = P0^0;
sbit RW = P0^1;

unsigned char CGRam;  /* 0-64 */
unsigned char DDRam;
unsigned char character;
int i;
unsigned char j;
code char message[]={"Noel A. Rios    "};
unsigned char pointer;



void Clear_Display(void);
void Cursor_Home(void);
void LCD_Config(void);
void Display_Control(void);
void Cursor_Control(void);
void Entry_Mode(Void);
void CGRam_Address(void);
void DDRam_Address(void);
void Read_Busy_Flag(void);
void Write_Data(void);
void delay(void);
void delay2(void);
void Write_String(void);


void Clear_Display(void)
{
character=1;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}


void Cursor_Home(void)
{
character=0x02;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void Entry_Mode(void)
{
character=0x06;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void Display_Control(void)
{
character=0x0C;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void Cursor_Control(void)
{
character=0x14;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void LCD_Config(void)
{
character=0x38;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
delay();
Read_Busy_Flag();
}

void CGRam_Address(void)
{
character=0x40|CGRam;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void DDRam_Address(void)
{
character=0x80|DDRam;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void Read_Busy_Flag(void)
{
P1=0xFF;
RS=0;
RW=1;
do{
Enable=0;
Enable=1;
delay2();}
while (LCDFLAG==1);
Enable=0;
}

void Write_Data(void)     /*Call with character =character */
{
P1=character;
RS=1;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}


void delay(void)
{
for(i=0;i<65535;i++)
{}
}


void delay2(void)
{
for(j=0;j<255;j++)
{}
}


void Write_String(void)
{
for(pointer=0;pointer<16;pointer++)
{
character=message[pointer];
Write_Data();
}
}



void main(void)
{
Enable=0;
LCD_Config();
Display_Control();
Entry_Mode();
Cursor_Home();
Write_String();
DDRam=0x40;
DDRam_Address();
character='N';
Write_Data();

do{}
while(1);


}


Logged

Love the Lord your God with all your heart & soul and with all your mind & strength.And love your neighbor as yourself.

The devil only comes to Kill,Steal & Destroy John 10:10

UKrobotics
Microcircuits gave me schizophrenia for Php2600/month in 1992
1diyMARKET
Lead Acid Battery
*******

Pogi/Ganda Points: 4
Offline Offline

Posts: 540


WWW
« Reply #7 on: November 03, 2010, 06:21:56 PM »

Here is an old set of routines used for a HD44780 based 2X16 LCD Module.  This is a quick test and I used a software delay instead of a timer based delay.

If you are a beginner, you can just ground pin 5 R/W pin of the LCD and use a software delay.  After some practice, you can read or poll the Busy Flag to see if the LCD Module has finished it's task.
Your microcontroller and LCD Module can be damaged because of bus contention due to error in the handshaking of the LCD and the Microcontroller.  By Grounding pin no.5 of the LCD, you just write to the LCD and the databus of the LCD is in Input mode,so nothing happens even if you make a mistake.
Please take note of the control pins and databus used.  Change according to your connection.

Code:

/* DEMO LCD ROUTINES USING 8 bit interface */
/*Author Noel A. Rios */
//Microcontroller: 89C52

#include <stdlib.h>
#include <reg52.h>


sbit LCDFLAG= P1^7;
sbit Enable = P0^2;
sbit RS = P0^0;
sbit RW = P0^1;

unsigned char CGRam;  /* 0-64 */
unsigned char DDRam;
unsigned char character;
int i;
unsigned char j;
code char message[]={"Noel A. Rios    "};
unsigned char pointer;



void Clear_Display(void);
void Cursor_Home(void);
void LCD_Config(void);
void Display_Control(void);
void Cursor_Control(void);
void Entry_Mode(Void);
void CGRam_Address(void);
void DDRam_Address(void);
void Read_Busy_Flag(void);
void Write_Data(void);
void delay(void);
void delay2(void);
void Write_String(void);


void Clear_Display(void)
{
character=1;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}


void Cursor_Home(void)
{
character=0x02;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void Entry_Mode(void)
{
character=0x06;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void Display_Control(void)
{
character=0x0C;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void Cursor_Control(void)
{
character=0x14;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void LCD_Config(void)
{
character=0x38;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
delay();
Read_Busy_Flag();
}

void CGRam_Address(void)
{
character=0x40|CGRam;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void DDRam_Address(void)
{
character=0x80|DDRam;
P1=character;
RS=0;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}

void Read_Busy_Flag(void)
{
P1=0xFF;
RS=0;
RW=1;
do{
Enable=0;
Enable=1;
delay2();}
while (LCDFLAG==1);
Enable=0;
}

void Write_Data(void)     /*Call with character =character */
{
P1=character;
RS=1;
RW=0;
Enable=0;
Enable=1;
delay2();
Enable=0;
Read_Busy_Flag();
}


void delay(void)
{
for(i=0;i<65535;i++)
{}
}


void delay2(void)
{
for(j=0;j<255;j++)
{}
}


void Write_String(void)
{
for(pointer=0;pointer<16;pointer++)
{
character=message[pointer];
Write_Data();
}
}



void main(void)
{
Enable=0;
LCD_Config();
Display_Control();
Entry_Mode();
Cursor_Home();
Write_String();
DDRam=0x40;
DDRam_Address();
character='N';
Write_Data();

do{}
while(1);


}



Nice one, pero pagkahaba naman.  di ba puwede ang 4 bit interface tapos gamitin ang 4 bit build in library?
Logged

Your Support and Purchase of 1diycentre e’store products is a support to our fellow  hobbyist.  Most of the buyers here at e’store are students who do not have yet source of income.  1diyteam offer monthly payment to some items to help our fellow hobbyist.
The Philippine Electronics and Technology Forum
   

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
What is/are the hex codes of 8051?
8051 Microcontroller
Jaylord 11 1897 Last post October 09, 2008, 09:22:38 PM
by rdpzycho
8051 Tutorials
8051 Microcontroller
glenndr_15 3 930 Last post December 12, 2010, 03:02:20 PM
by electrojonix
Can I check my TX output using keil's Logic Analyzer?
8051 Microcontroller
sirc4527 3 850 Last post January 19, 2010, 06:57:58 PM
by TinTopHack
linking keil microvision to proteus
Atmel Microcontrollers
Accessories 1 270 Last post June 28, 2010, 07:33:38 PM
by Accessories
adc with 8051 problem
Microcontroller/Microprocessor Unit Projects and Programming
wootwoot 11 383 Last post December 09, 2010, 09:47:41 PM
by tiktak
atmel 8051
General Electronics and Technology Discussion
kmikze02 2 91 Last post December 29, 2010, 12:44:42 AM
by kmikze02
john curl's written Audio...... « 1 2 »
Amplifiers, Mixers and Equalizers
tony 29 488 Last post November 11, 2011, 12:44:58 AM
by danny
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!