Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCD display

Status
Not open for further replies.
If writing 8 bits is the problem then a write nibble function should solve it,

Code:
[COLOR="Blue"]void LCD_nibble(unsigned char nibble){
    LCD_CTRL_PORT &= ~(1<<LCD_rs); 
    LCD_DATA_PORT = (nibble & 0xF0)|(LCD_DATA_PORT & 0x0F); 
    LCD_enable(); 
}[/COLOR]

void LCD_init() 
{ 

   //initialize LCD control lines 
   LCD_CTRL_PORT &= ~(1<<LCD_rs);   // RS low 
   LCD_CTRL_PORT &= ~(1<<LCD_rw);   // R/W low 
   LCD_CTRL_PORT &= ~(1<<LCD_en);   // E low 

   // initialize LCD control lines to output 
   LCD_CTRL_DDR |= (1<<LCD_rs); 
   LCD_CTRL_DDR |= (1<<LCD_rw); 
   LCD_CTRL_DDR |= (1<<LCD_en); 

   // initialize LCD data port to input 
    LCD_DATA_DDR |= 0xF0;// Data on high four bits of port 

[COLOR="blue"]    _delay_ms(15);		//start of required sequnce
    LCD_nibble(0x30);
    _delay_ms(5); 
    LCD_nibble(0x30);
    _delay_ms(1); 
    LCD_nibble(0x30);	
    _delay_ms(1); 
    LCD_nibble(0x20);		//switch to 4 bit mode[/COLOR]

   LCD_start(); 
   LCD_function_set(); 
    _delay_us(40); 
   LCD_display_off(); 
   _delay_us(40); 
   LCD_display_clear(); 
   _delay_ms(2); 
   LCD_mode_set(); 
   LCD_display_on(); 
}

The blue bits are the changes from your original code.

Mike.

thanks a lot, at last it works!

keep up that good work!
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top