info:lcd_4_bit_interfacing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
info:lcd_4_bit_interfacing [2011/01/15 09:13] tomgeeinfo:lcd_4_bit_interfacing [2011/01/16 11:29] (current) tomgee
Line 22: Line 22:
 The steps are: The steps are:
  
-   1. Mask lower 4-bits+   1. Load high 4-bits on 4 LCD data pins
    2. Send to the LCD port    2. Send to the LCD port
-   3. Send enable signal +   3. Toggle enable signal 
-   4. Mask higher 4-bits+   4. Load lower 4-bits on 4 LCD data pins
    5. Send to LCD port    5. Send to LCD port
-   6. Send enable signal+   6. Toggle enable signal
  
 ==== C code to perform the above ==== ==== C code to perform the above ====
Line 71: Line 71:
         lcd_cmd(0x06);       // Automatic Increment - No Display shift.         lcd_cmd(0x06);       // Automatic Increment - No Display shift.
         lcd_cmd(0x80);       // Address DDRAM with 0 offset 80h.         lcd_cmd(0x80);       // Address DDRAM with 0 offset 80h.
 +   }
 +
 +==== Sending Command/Data to LCD in 4-bit mode ====
 +
 +   void lcd_cmd (char cmd)
 +   {
 +        lcd_port = ((cmd >> 4) & 0x0F)|LCD_EN;
 +        lcd_port = ((cmd >> 4) & 0x0F);
 +
 +        lcd_port = (cmd & 0x0F)|LCD_EN;
 +        lcd_port = (cmd & 0x0F);
 +
 +        delayus(200);
 +        delayus(200);
 +   }
 +
 +   void lcd_data (unsigned char dat)
 +   {
 +        lcd_port = (((dat >> 4) & 0x0F)|LCD_EN|LCD_RS);
 +        lcd_port = (((dat >> 4) & 0x0F)|LCD_RS);
 +       
 +        lcd_port = ((dat & 0x0F)|LCD_EN|LCD_RS);
 +        lcd_port = ((dat & 0x0F)|LCD_RS);
 +
 +        delayus(200);
 +        delayus(200);
    }    }
info/lcd_4_bit_interfacing.1295100791.txt.gz · Last modified: 2011/01/15 09:13 by tomgee