Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Lcd for bit data sending through a 8 bit port

Status
Not open for further replies.

gravity123

Newbie level 6
Joined
Mar 30, 2011
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,363
Hello friends ,
I want to send an 4 bit data to LCD along with the enable and RS data through the same port of an 8 bit controller.
that is the Data is 4 bit consider my data is "C'
controllerport = ((c >> 4) & 0x0f) | EN | RS;
is it correct ?
or how can i send the EN and RS data without affect the c data.
 

Hello friends ,
I want to send an 4 bit data to LCD along with the enable and RS data through the same port of an 8 bit controller.
that is the Data is 4 bit consider my data is "C'
controllerport = ((c >> 4) & 0x0f) | EN | RS;
is it correct ?
or how can i send the EN and RS data without affect the c data.

Hoped, this will help you
This codes for PIC 16F877a MCU using HI_TECH C compiler and HD44780 compatible LCD
In your case you did not mention MCU and compiler which are using
Code:
#define LCD_EN RB3
#define    LCD_RS RB5
#define    LCD_RW RB4
#define LCD_DATA    PORTD
#define    LCD_STROBE()    ((LCD_EN = 1),(LCD_EN=0)


4 bit mode sending data to LCD
Code:
void lcddata(unsigned char value)
    {
LCD_RS = 1; 

LCD_DATA= ((val>>4)&0x0F);
LCD_STROBE;
LCD_DATA =(val&0x0F); 
LCD_STROBE;

__delay_ms(10);
    }

8 bit mode sending data to LCD

Code:
void lcddata(unsigned char value)
    {
LCD_DATA = value;
LCD_RS = 1; 
LCD_RW = 0;
LCD_EN = 1;
__delay_ms (1);
LCD_EN = 0;

    }
 
Last edited:
View attachment lcd 4bit.rar
Code:
#include <REGX51.H>

#include <stdio.H>

 

 

#define LCDPORT P2
 

sbit RS = LCDPORT ^ 4;

sbit EN = LCDPORT ^ 5;

 

void delay(unsigned int msec)
{

int i, j;

for (i = 0; i < msec; i++)

for (j = 0; j < 1275; j++);

}
 

void LCDSTROBE(void)

{

EN = 1;

    delay(4);
EN = 0;

}

 

void dt(unsigned char c)

{
RS = 1;

delay(50);

LCDPORT = ((c >> 4) & 0x0f);

LCDSTROBE();

    LCDPORT = (c & 0x0F) ;
 

LCDSTROBE();

}

 

void cmd(unsigned char c)
{

RS = 0;

delay(50);

LCDPORT = ((c >> 4) & 0x0f);

    LCDSTROBE();
LCDPORT = (c  & 0x0F);

LCDSTROBE();

}

 

void lcdclear(void)
{

cmd(0x01);

delay(2);

}


 

void lcd_init()

{

delay(15);

    cmd(0x38);
delay(1);

cmd(0x38);

delay(100);

cmd(0x38);

    cmd(0x28);			// Function set (4-bit interface, 2 lines, 5*7Pixels)
	delay(1);
cmd(0x28);			// Function set (4-bit interface, 2 lines, 5*7Pixels)

cmd(0x0c);			// Make cursorinvisible

lcdclear();			// Clear screen

cmd(0x6);			// Set entry Mode(auto increment of cursor)

}
 

void string(const char *q)

{

while (*q) {

	dt(*q++);
}

}

 

 

main()
{

delay(50);

lcd_init();

LCDPORT = 0x00;

 while (1) {
cmd(0x80);

string("HELLO WORLD");

cmd(0xc0);

string("IT IS WORKING:-)");


}

}
This is the my code but it is not working what is the problem .
Am using 8051 with keil
attached full projects with proteus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top