C51 program for HT1621 driving segment LCD

Publisher:cangartLatest update time:2016-11-22 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/ *
=
...​​ =================================================================================*/ /*========================================================*/ #include /* Please modify the 8051 register definition to your own file*/ typedef unsigned char uchar; typedef unsigned int uint; sbit _CS =P2^0; //Chip select  sbit _WR =P2^1; //Write clock  sbit _DAT=P2^4; //Data line  /*-----------------*/ delay(int t) /*Delay function*/ {     int i,j;     for(i=0;i

















    




































    



































    k=dat<<4; //Four-bit display datafor
    (i=0;i!=4;i++) /*Write Display data :xxxxC0~C3*/
    {
        if(k&0x80==0)
            _DAT=0;
        else
            _DAT=1;

        _WR=0; //Send a write clock pulse_WR
        =1;
        k=k<<1; //Prepare for the next bit of data
    }

    _CS=1; //Cancel the chip select signal
}

DISP_NUM(uchar dat) /*Write a number*/
{
    uchar i,j,addr;

    for (i=8;i!=28;i++)
    {
        write_dat(i,dat<<4); //One byte needs to be transmitted twicewrite_dat
        (++i,dat);
    }
}


DIS(uchar dat)
{
    uchar i,j;

    for(i=0;i!=28;i++)
        write_dat(i,dat);
}

setup_lcd(void)
{
    delay(100);
    write_com(0x01); /*Enable system,SYS EN command*/
    write_com(0x18); /*CLOCK SOURCE IS 256kRC ON CHIP,RC 256K*/
    write_com(0x29); /*BIAS=1/3 DUTY=1/4,LCD 1/3 bias,4 COM*/
    write_com(0x03); /*Display on, turn on LCD bias generator*/
    DIS(0x00); /*Clear LCD,clear the screen (fill the display memory with all 0s)*/
    delay(20);
}

main()
{
    uchar i,j,temp;

    delay(100);
    setup_lcd(); //Initialize LCD driver IC
    delay(10);

    while(1)
    {
        delay(200);
        DIS(0x0f); //Display black and white stripes
        delay(200);
        DIS(0x00); //Clear screen
        
        temp=0xf8;
        for(i=0;i!=8;i++) /*Display ICONs*/
        {
            for(j=0;j=4;j++)
            {
                write_dat(i,temp>>1);
                delay(20);
            }
        }

        write_dat(13,0x01);
        write_dat(19,0x01);
        write_dat(23,0x01);

        delay(200);
        DISP_NUM(0xbe); */ //Seven-segment digital display

        delay(200);
        DISP_NUM(0x06); /*1*/         delay(200);

        DISP_NUM (
        0x7c);         /*2*/         delay(200);         DISP_NUM(0x5e); /*3*/         delay(200);         DISP_NUM(0xc6); 5*/         delay(200);         DISP_NUM(0xfa); /*6*/         delay(200);         DISP_NUM(0x0e); /*7*/         delay(200);         DISP_NUM(0xfe); /*8*/         delay(200);         DISP_NUM(0xde); /*9*/     }






















}

Reference address:C51 program for HT1621 driving segment LCD

Previous article:C51 driver for 1602LCD module
Next article:uC/OS-II transplantation steps on C51

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号