EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / LCD

LCD

|

Microcontroller › 8051 › LCD

  • This topic has 0 replies, 1 voice, and was last updated 13 years, 4 months ago by V.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • June 6, 2013 at 6:17 pm #2470
    V
    Participant

    Hello, I’ve problem with LCD. I use at89c2051

     

    #include <at89x51.h>
    #include “lcd.h”
    #define PRELOAD01 (65536 – (tWord)(OSC_FREQ / (OSC_PER_INST * 1020)))
    #define PRELOAD01H (PRELOAD01 / 256)
    #define PRELOAD01L (PRELOAD01 % 256)

    #define LCD_RS         P1_5
    #define LCD_EN         P1_4
    #define LCD_DATA    P1

    void delay_10ms(void)
    {
    TMOD &=0xF0;
    TMOD |=0x01;

    ET0=0;

    TH0=0xDF;
    TL0=0x73;

    while(TF0==0);
    TR0=0;
    }

    void delay_70ms(void)
    {
    TMOD &=0xF0;
    TMOD |=0x01;

    ET0=0;

    TH0=0x1C;
    TL0=0x23;

    while(TF0==0);
    TR0=0;
    }

    void delay_5ms(void)
    {
    TMOD &=0xF0;
    TMOD |=0x01;

    ET0=0;

    TH0=0xEF;
    TL0=0xBA;

    while(TF0==0);
    TR0=0;
    }

    void delay_100u(void)
    {
    TMOD &=0xF0;
    TMOD |=0x01;

    ET0=0;

    TH0=0xFF;
    TL0=0xAD;

    while(TF0==0);
    TR0=0;
    }

    void delay_70u(void)
    {
    TMOD &=0xF0;
    TMOD |=0x01;

    ET0=0;

    TH0=0xFF;
    TL0=0xC6;

    while(TF0==0);
    TR0=0;
    }

    void delay_10u(void)
    {
    TMOD &=0xF0;
    TMOD |=0x01;

    ET0=0;

    TH0=0xFF;
    TL0=0xF8;

    while(TF0==0);
    TR0=0;
    }

    void LCD_STROBE (void);

    void lcd_write(unsigned char c)
    {
    delay_70u();
    LCD_DATA = ( ( c >> 4 ) & 0x0F );
    LCD_STROBE();
    LCD_DATA = ( c & 0x0F );
    LCD_STROBE();
    }

    /*
    * Clear and home the LCD
    */

    void lcd_clear(void)
    {
    LCD_RS = 0;
    lcd_write(0x1);
    delay_10u();
    }

    /* write a string of chars to the LCD */

    void lcd_puts(const char * s)
    {
    LCD_RS = 1; // write characters
    while(*s)
    lcd_write(*s++);
    }

    /* write one character to the LCD */

    void lcd_putch(char c)
    {
    LCD_RS = 1; // write characters
    lcd_write( c );
    }

    /*
    * Go to the specified position
    */

    void lcd_goto(unsigned char pos)
    {
    LCD_RS = 0;
    lcd_write(0x80+pos);
    }

    /* initialise the LCD – put into 4 bit mode */

    void lcd_init()
    {
    char init_value;

    init_value = 0x3;

    LCD_RS = 0;
    LCD_EN = 0;

    delay_70ms(); // delay for 150ms
    delay_70ms();
    delay_10ms();
    LCD_DATA = 0x3;
    LCD_STROBE();

    delay_5ms();

    LCD_DATA = 0x3;
    LCD_STROBE();
    delay_100u();

    LCD_DATA = 0x3;
    LCD_STROBE();
    delay_100u();

    LCD_DATA = 0x2;
    LCD_STROBE();
    delay_100u();

    LCD_DATA = 0x2;
    LCD_STROBE();
    LCD_DATA = 0x8;
    LCD_STROBE();
    delay_100u();

    LCD_DATA = 0x0;
    LCD_STROBE();
    LCD_DATA = 0x8;
    LCD_STROBE();
    delay_100u();

    LCD_DATA = 0x0;
    LCD_STROBE();
    LCD_DATA = 0x1;
    LCD_STROBE();
    delay_5ms();

    LCD_DATA = 0x0;
    LCD_STROBE();
    LCD_DATA = 0x6;
    LCD_STROBE();
    delay_100u();

    LCD_DATA = 0x0;
    LCD_STROBE();
    LCD_DATA = 0xC;
    LCD_STROBE();
    delay_100u();

    LCD_RS = 1;
    }

    void LCD_STROBE(void)
    {
    LCD_EN = 1;
    delay_10u();
    LCD_EN= 0;
    }

    void main (void)
    {

    lcd_init();
    lcd_goto(0);

    lcd_puts(“T”);

    }

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS feed: Recent Posts Recent Posts

  • Subject: [FS] Soviet Vintage Electronic Components (Capacitors, Transistors, ICs, Relays, Vacuum Tubes) October 13, 2026
  • Request for a 5W transistor controlled LED flash light controller circuit review October 12, 2026
  • Frustration, single phase, high KW, high voltage battery charge module, rectifier. October 12, 2026
  • Delco alternator (12SI) AC-tap - what is the mate to this connector called and where to find it? October 11, 2026
  • Voltage divider response time - is it relevant? October 11, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 Arrowfly LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of Arrowfly
Privacy Policy | Advertising

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise