hd44780.c
/*************************************************************************
Initialize display
Input:    none
Returns:  none
*************************************************************************/
Initialize display
Input:    none
Returns:  none
Initialize display Input : none Returns : none
void lcd_init()
  {
    lcd_e_ddr_high();
    lcd_rs_ddr_high();
    #if RW_LINE_IMPLEMENTED==1
      lcd_rw_ddr_high();
    #endif
    lcd_db7_ddr_high();
    lcd_db6_ddr_high();
    lcd_db5_ddr_high();
    lcd_db4_ddr_high();
    #if LCD_BITS==8
      lcd_db3_ddr_high();
      lcd_db2_ddr_high();
      lcd_db1_ddr_high();
      lcd_db0_ddr_high();
    #endif
    lcd_e_port_low();
    lcd_rs_port_low();
    #if RW_LINE_IMPLEMENTED==1
      lcd_rw_port_low();
    #endif
    lcd_db7_port_high();
    lcd_db6_port_high();
    lcd_db5_port_high();
    lcd_db4_port_high();
    #if LCD_BITS==8
      lcd_db3_port_high();
      lcd_db2_port_high();
      lcd_db1_port_high();
      lcd_db0_port_high();
    #endif
    Delay_ms(DELAY_RESET);
    lcd_db7_port_low();
    lcd_db6_port_low();
    Delay_ns(100);
    lcd_e_port_high();
    Delay_ns(500);
    lcd_e_port_low();
    Delay_us(4100);
    lcd_e_port_high();
    Delay_ns(500);
    lcd_e_port_low();
    Delay_us(100);
    lcd_e_port_high();
    Delay_ns(500);
    lcd_e_port_low();
    Delay_us(40);
    #if (LCD_BITS==4)
      lcd_db4_port_low();
      Delay_ns(100);
      lcd_e_port_high();
      Delay_ns(500);
      lcd_e_port_low();
      Delay_us(40);
      lcd_db4_port_low();
      Delay_ns(100);
      lcd_e_port_high();
      Delay_ns(500);
      lcd_e_port_low();
      Delay_ns(500);
      #if (LCD_DISPLAYS==1)
        if (LCD_DISPLAY_LINES>1)
          lcd_db7_port_high();
      #else
        unsigned char c;
        switch (ActiveDisplay)
          {
            case 1 : c=LCD_DISPLAY_LINES; break;
            case 2 : c=LCD_DISPLAY2_LINES; break;
            #if (LCD_DISPLAYS>=3)
            case 3 : c=LCD_DISPLAY3_LINES; break;
            #endif
            #if (LCD_DISPLAYS==4)
            case 4 : c=LCD_DISPLAY4_LINES; break;
            #endif
          }
        if (c>1)
          lcd_db7_port_high();
      #endif
      Delay_ns(100);
      lcd_e_port_high();
      Delay_ns(500);
      lcd_e_port_low();
      Delay_us(40);
    #else
      #if (LCD_DISPLAYS==1)
        if (LCD_DISPLAY_LINES<2)
          lcd_db3_port_low();
      #else
        unsigned char c;
        switch (ActiveDisplay)
          {
            case 1 : c=LCD_DISPLAY_LINES; break;
            case 2 : c=LCD_DISPLAY2_LINES; break;
            #if (LCD_DISPLAYS>=3)
            case 3 : c=LCD_DISPLAY3_LINES; break;
            #endif
            #if (LCD_DISPLAYS==4)
            case 4 : c=LCD_DISPLAY4_LINES; break;
            #endif
          }
        if (c<2)
          lcd_db3_port_low();
      #endif
      lcd_db2_port_low();
      Delay_ns(100);
      lcd_e_port_high();
      Delay_ns(500);
      lcd_e_port_low();
      Delay_us(40);
    #endif
    lcd_command(_BV(LCD_DISPLAYMODE));
    lcd_clrscr();
    lcd_command(_BV(LCD_ENTRY_MODE) | _BV(LCD_ENTRY_INC));
    lcd_command(_BV(LCD_DISPLAYMODE) | _BV(LCD_DISPLAYMODE_ON));
  }
void lcd_init ( ) { lcd_e_ddr_high ( ) ; lcd_rs_ddr_high ( ) ; #if RW_LINE_IMPLEMENTED == 1 lcd_rw_ddr_high ( ) ; #endif lcd_db7_ddr_high ( ) ; lcd_db6_ddr_high ( ) ; lcd_db5_ddr_high ( ) ; lcd_db4_ddr_high ( ) ; #if LCD_BITS == 8 lcd_db3_ddr_high ( ) ; lcd_db2_ddr_high ( ) ; lcd_db1_ddr_high ( ) ; lcd_db0_ddr_high ( ) ; #endif lcd_e_port_low ( ) ; lcd_rs_port_low ( ) ; #if RW_LINE_IMPLEMENTED == 1 lcd_rw_port_low ( ) ; #endif lcd_db7_port_high ( ) ; lcd_db6_port_high ( ) ; lcd_db5_port_high ( ) ; lcd_db4_port_high ( ) ; #if LCD_BITS == 8 lcd_db3_port_high ( ) ; lcd_db2_port_high ( ) ; lcd_db1_port_high ( ) ; lcd_db0_port_high ( ) ; #endif Delay_ms ( DELAY_RESET ) ; lcd_db7_port_low ( ) ; lcd_db6_port_low ( ) ; Delay_ns ( 100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; Delay_us ( 4100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; Delay_us ( 100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; Delay_us ( 40 ) ; #if ( LCD_BITS == 4 ) lcd_db4_port_low ( ) ; Delay_ns ( 100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; Delay_us ( 40 ) ; lcd_db4_port_low ( ) ; Delay_ns ( 100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; Delay_ns ( 500 ) ; #if ( LCD_DISPLAYS == 1 ) if ( LCD_DISPLAY_LINES > 1 ) lcd_db7_port_high ( ) ; #else unsigned char c ; switch ( ActiveDisplay ) { case 1 : c = LCD_DISPLAY_LINES ; break ; case 2 : c = LCD_DISPLAY2_LINES ; break ; #if ( LCD_DISPLAYS >= 3 ) case 3 : c = LCD_DISPLAY3_LINES ; break ; #endif #if ( LCD_DISPLAYS == 4 ) case 4 : c = LCD_DISPLAY4_LINES ; break ; #endif } if ( c > 1 ) lcd_db7_port_high ( ) ; #endif Delay_ns ( 100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; Delay_us ( 40 ) ; #else #if ( LCD_DISPLAYS == 1 ) if ( LCD_DISPLAY_LINES < 2 ) lcd_db3_port_low ( ) ; #else unsigned char c ; switch ( ActiveDisplay ) { case 1 : c = LCD_DISPLAY_LINES ; break ; case 2 : c = LCD_DISPLAY2_LINES ; break ; #if ( LCD_DISPLAYS >= 3 ) case 3 : c = LCD_DISPLAY3_LINES ; break ; #endif #if ( LCD_DISPLAYS == 4 ) case 4 : c = LCD_DISPLAY4_LINES ; break ; #endif } if ( c < 2 ) lcd_db3_port_low ( ) ; #endif lcd_db2_port_low ( ) ; Delay_ns ( 100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; Delay_us ( 40 ) ; #endif lcd_command ( _BV ( LCD_DISPLAYMODE ) ) ; lcd_clrscr ( ) ; lcd_command ( _BV ( LCD_ENTRY_MODE ) | _BV ( LCD_ENTRY_INC ) ) ; lcd_command ( _BV ( LCD_DISPLAYMODE ) | _BV ( LCD_DISPLAYMODE_ON ) ) ; }
Initialize display
Input:    none
Returns:  none
Initialize display Input : none Returns : none
//Set All Pins as Output
 //Set All Control Lines Low
 //Set All Data Lines High
 //Startup Delay
 //Initialize Display
 //Init differs between 4-bit and 8-bit from here
 //Display Off
 //Display Clear
 //Entry Mode Set
 //Display On
