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.

[SOLVED] Initializing LCD ST7920 ?

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Visit site
Activity points
9,442
Guys,

I tried to display message on ST7920 LCD,
It's displaying the text already, but I must reset few times before it can display properly,

Do I miss something here ?

Here's the code I used :
Code:
char menu_txt[21] = " ATMEGA128    "; 
void lcd_init(){
    //st7920
		lcd_cmd(0x30);
		_delay_ms(100);
		lcd_cmd(0x30);
		_delay_ms(100);
		lcd_cmd(0x0F);
		_delay_ms(100);
		//lcd_cmd(0x80);
		//_delay_ms(10);
		lcd_cmd(0x01); //clear screen
		_delay_ms(100);
		lcd_cmd(0x02);//Return home
		_delay_ms(100);

		lcd_cmd(0x06);//cursor to the right
		_delay_ms(100);
		    

   
	
}


void lcd_data(unsigned char data1)
{
	
	
	lcd_data_pin = data1;// & 0x0F;
	en=1;
    _delay_us(100);
	rs=1;
   _delay_us(100);
	rw=0;
	_delay_ms(10);
	en=0;
	
}

void lcd_cmd(unsigned char cmd){
	
	lcd_data_pin = cmd ;
	_delay_us(100);
	en=1;
    _delay_us(100);
	rs=0;
    _delay_us(100);
	rw=0;

	_delay_ms(10);
	en=0;
	
	
	
}



void lcd_string(unsigned char *str){
	
	while(*str){
		lcd_data(*str++);
	}
	
}

lcd_string(menu_txt);

Any ideas ?
thanks
 

Try this Function for initialization
Code:
void LCD_init()
{
delay(100);
	LCD_cmd(0x38);		// or 0x30 as you have mentioned
	LCD_cmd(0x0C);		// You Can Write 0x0E also but It will show the Cursor
	LCD_cmd(0x01);         //Clear Display
	LCD_cmd(0x06);        //Entry Mode from  Left To Right 
	LCD_cmd(0x80);       //1st Row , 1st Column
}
void LCD_cmd(unsigned char command)
{
command = LCD_DATA ;  delay(50) ;  RS = 0 ; RW = 0 ; EN=1 delay(5); EN = 0 ; 
}
void LCD_data(unsigned char data)
{
data = LCD_DATA ;  delay(50) ;  RS = 1 ; RW = 0 ; EN=1 delay(5); EN = 0 ;
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top