16x2 Alphanumeric LCD Interfacing :: AVR Tutorials


Posted on Feb 5, 2014

The RW line is the `Read/Write` control line. When RW is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the LCD. Only one instruction (`Get LCD status`) is a read command. All others are written commands so RW will almost always be low. >>While using LCD in 4 bit data mode it


16x2 Alphanumeric LCD Interfacing :: AVR Tutorials
Click here to download the full size of the above Circuit.

saves 4 bits of our total GPIO lines, that ’s why it is most commonly used. MSB of any data or commnad is sent first over 4 bits and then 4 LSB sent by shifting the data byte 4 times left. /* Example program For 4 bit LCD interfacing with ATmega16 File name - LCD. h (to be included in main program) Compiler - WinAVR / AVR GCC <7465> / #define lcd_port PORTB //LCD connected to PORTB as shown above #define LCD_RS 0G—01 #define LCD_RW 0G—02 #define LCD_EN 0G—08 void lcd_reset(void) { lcd_port = 0xFF; _delay_ms(20); lcd_port = 0G—30+LCD_EN; lcd_port = 0G—30; _delay_ms(10); lcd_port = 0G—30+LCD_EN; lcd_port = 0G—30; _delay_ms(1); lcd_port = 0G—30+LCD_EN; lcd_port = 0G—30; _delay_ms(1); lcd_port = 0G—20+LCD_EN; lcd_port = 0G—20; _delay_ms(1); } void lcd_cmd (char cmd) { lcd_port = (cmd & 0xF0)|LCD_EN; lcd_port = (cmd & 0xF0); lcd_port = (cmd << 4) & 0xF0)|LCD_EN; lcd_port = (cmd << 4) & 0xF0); _delay_ms(2); _delay_ms(2); } void lcd_init (void) { lcd_reset(); // Call LCD reset lcd_cmd(0G—28); // 4-bit mode – 2 line – 5G—7 font. lcd_cmd(0G—0C); // Display no cursor – no blink. lcd_cmd(0G—06); // Automatic Increment – No Display shift. lcd_cmd(0G—80); // Address DDRAM with 0 offset 80h. } // Function to display single Character void lcd_data (unsigned char dat) { lcd_port = (dat & 0xF0)|LCD_EN|LCD_RS); lcd_port = (dat & 0xF0)|LCD_RS); lcd_port = (dat << 4) & 0xF0)|LCD_EN|LCD_RS); lcd_port = (dat << 4) & 0xF0)|LCD_RS); _delay_ms(2);...




Leave Comment

characters left:

Related Circuits

  • New Circuits

    .

     


    Popular Circuits

    Receiver monitor
    Portable-amplifier
    Preregulated-high-voltage-supply
    Electronic Thermometer
    Simple Sine-Wave Generator Circuit
    door lock schematic
    musical continuity
    LM1830 low level detector schematic circuit design
    SIMPLE CONTINUITY TESTER CIRCUIT
    ELECTRONIC_ONE_ARM_BANDIT
    IC rprecision waveform generator with sweep and frequency modulation



    Top