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.

problem about LCD dislay NIbble mode

Status
Not open for further replies.

hbaocr

Full Member level 4
Joined
May 13, 2007
Messages
232
Helped
25
Reputation
48
Reaction score
4
Trophy points
1,298
Location
Hochiminh City university of technology (VietNam)
Activity points
2,765
plz show me some problem I met on this project
Code:
#include "REG52.H"
// define some needed variant
sbit RS =P1^0;	 
sbit RW	=P1^1;	  
sbit EN =P1^2;  
sbit BUSY =P2^7;
// character dislay
#define CHU_A 0x41
#define CHU_B 0x42
#define CHU_C 0x43
#define	CHU_D 0x44
#define CHU_E 0x45
#define	CHU_F 0x46
#define CHU_G 0x47
#define	CHU_H 0x48
#define	CHU_I 0x49
#define CHU_J 0x4A
#define	CHU_K 0x4B
#define	CHU_L 0x4C
#define	CHU_M 0x4D
#define CHU_N 0x4E
#define	CHU_O 0x4F
#define	CHU_P 0x50
#define	CHU_Q 0x51
#define	CHU_R 0x52
#define CHU_S 0x53
#define CHU_T 0x54
#define CHU_U 0x55
#define	CHU_V 0x56
#define CHU_W 0x57
#define	CHU_X 0x58
#define	CHU_Y 0x59
#define CHU_Z 0x5A
#define KT    0x20
//					
#define DATA P2	
//declare my function
void WR_LCD( unsigned char TXT,bit RSbit);
void WAIT_LCD(void);
void INT_LCD(void);

void CLR_LCD (void);
void HOME_LCD (void);
//main program

	 
void main(void)
{
INT_LCD();
CLR_LCD();
HOME_LCD();
DATA=0X55;
WR_LCD(CHU_B,1);
WR_LCD(CHU_A,1);
WR_LCD(CHU_O,1);
while(1);
}

//==================================================
void WAIT_LCD(void)
{
unsigned char tempt=255;
BUSY=1;
EN=1  ;
RW=1  ;	//doc tu LCD ve uC
RS=0  ;//command
while (BUSY)
;
EN=0;
RW=0; //LCD nhan data
} 
//==================================================
void INT_LCD(void)
{
//function set 8 col 2 row, 5x7 dot format,NIBBLE MODE
//EN=1;
//RS=0;
//DATA=0x38;
WR_LCD(0x28,0);
//EN=0;
//WAIT_LCD();
// Dislay ON/OFF CURSOR Shift
// dislay ON, Cursor Underline on, cursor blink off
WR_LCD(0x0E,0); 
//EN=1;
//RS=0;
//DATA=0x0E;
//EN=0;
//WAIT_LCD();
//Set Charracter Mode 
// increment (dich fai) , Dislay Shift Off
WR_LCD(0x06,0);
//EN=1;
//RS=0;
//DATA=0x06;
//EN=0;
//WAIT_LCD();
}
//=======================================================

void WR_LCD( unsigned char TXT,bit RSbit)//RSbit=0 cmd,=1 data
{
RS=RSbit;
RW=0;
//write 4 bit high
EN=1	   ;
DATA=(TXT|0x0F)&DATA;
EN=0	   ;
WAIT_LCD() ;
//DATA=highTXT_lowDATA
//write 4 bit low
EN=1	   ;
DATA=((TXT<<4)|0x0F)&DATA;
//DATA=lowTXT_lowDATA

EN=0	   ;
WAIT_LCD() ;
}
void CLR_LCD(void)
{
//EN=1;
//RS=0;
//DATA=0x01;
//EN=0;
//WAIT_LCD();
WR_LCD(0x01,0);
}
void HOME_LCD (void)
{//EN=1;
 //RS=0;
 //DATA=0X02;
 //EN=1;
 //WAIT_LCD();
 WR_LCD(0x02,0);
}

conect
p2.4->p2.7 to LCD data(D4->d7)
 

suggest to change...


Code:
void INT_LCD(void) 
{ 
//function set 8 col 2 row, 5x7 dot format,NIBBLE MODE 
delay_ms(5);
EN=1; 
RS=0; 
DATA=0x30; 
EN=0;
delay_ms(5);
EN=1; 
RS=0; 
DATA=0x30; 
EN=0;
delay_ms(5);
EN=1; 
RS=0; 
DATA=0x30; 
EN=0;
delay_ms(5);
EN=1; 
RS=0; 
DATA=0x20; // here you choose nibble mode
EN=0;
delay_ms(5);

WR_LCD(0x28,0); 
// Dislay ON/OFF CURSOR Shift 
// dislay ON, Cursor Underline on, cursor blink off 
WR_LCD(0x0E,0); 
//Set Charracter Mode 
// increment (dich fai) , Dislay Shift Off 
WR_LCD(0x06,0); 
} 
//======================================================= 

void WR_LCD( unsigned char TXT,bit RSbit)//RSbit=0 cmd,=1 data 
{ 
RS=RSbit; 
RW=0; 
//write 4 bit high 
EN=1      ; 
DATA=(TXT | 0x0F) & (DATA & 0x0F); 
EN=0      ; 
WAIT_LCD() ; 
//DATA=highTXT_lowDATA 
//write 4 bit low 
EN=1      ; 
DATA=((TXT<<4)|0x0F)& (DATA & 0x0F); 
//DATA=lowTXT_lowDATA 

EN=0      ; 
WAIT_LCD() ; 
}

just implement a delay_ms() function or something like that...
(sorry I didn`t preserv low nibble of P2 at lcd-init)
you have to initialize to nibble after you are at byte mode... thats the way lcd starts...
 

hbaocr,

What's wrong ? Something appear at screen ?

You must check if it code complain with the wright onboard controler( hitachi, toschiba, etc... ).

+++
 

Hi vietdung79

I think you don't need to send three of 0x30 command.

Yes you have to send it three times. if it (hd4770 compitable) you have to send 0x28 instead of 0x30 three times.

Regards
Nandhu015
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top