12232c LCD display and 8051 microcontroller interface C language program

Publisher:张延强Latest update time:2016-07-15 Source: eefocusKeywords:12232c Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The following is a C language program written by Mr. Peng. I have used it! Wow! When writing the first four digits of the communication protocol in atmega128, it seems that you cannot send them one by one, but you have to write them as a hexadecimal whole shift! The comm in the program is the instruction to write 0 to write 12232c, and dat is 1 to write data. cs, sclk, std are chip select, clock, and data io ports respectively, which can be defined by sbit instruction.

/************lcd initialization program**************/
void init_lcd (void)                         
{
  wr_lcd (comm,0x30); /*30---basic instruction set action, 8-bit control interface*/   
  wr_lcd (comm,0x01); /*clear screen, address pointer points to 00H*/
  delay (80);
  wr_lcd (comm,0x06); /*cursor movement direction, cursor moves right*/
  wr_lcd (comm,0x0c); /*turn on display, turn off cursor*/
}

/******************LCD displays arbitrary quantity program************************/
void eng_disp (uchar x,uchar y,uchar code *eng)
{
  uchar i,j;
  wr_lcd (comm,0x30);
  wr_lcd (comm,0x80); /*The starting address of the first line*/
  for(j=0;j   {
  for (i=0;i   wr_lcd (dat,eng[j*16+i]);                 
  if((y==2)&&(j==1))
  {wr_lcd (comm,0x90);
  for (i=0;i<8;i++)
  wr_lcd (dat,eng[j*16+i]);
  }
  }
}

/*************************LCD displays Chinese (welcome interface) program******************/

void chn_disp (uchar code *chn) /*lcd displays Chinese*/
{
  uchar i,j;
  wr_lcd (comm,0x30);
  wr_lcd (comm,0x80); /*The starting address of the first line*/
  j=0;
  for (i=0;i<16;i++)
  wr_lcd (dat,chn[j*16+i]);
  wr_lcd (comm,0x90); //The starting address of the second line
  j=1;
  for (i=0;i<16;i++)
  wr_lcd (dat,chn[j*16+i]);
}

/***************************LCD clear memory program**********************/
void clrram (void) //lcd clear memory
{
  wr_lcd (comm,0x30);
  wr_lcd (comm,0x01);
  delay (120);
}

/*************LCD write data or write command subroutine****************/

void wr_lcd (uchar dat_comm,uchar content) /*lcd write data*/
{
  uchar a,i,j;
  delay (40);
  a=content; //a is the instruction code or data
  cs=1; //set cs to start transmitting data
  sclk=0; //pull sclk low to prepare for the rising edge, send data
  std=1; //set 1
  for(i=0;i<5;i++) /*transmit the start byte first, first 5 1s, the rising edge of sclk starts the transmission*/
  {
    sclk=1;
    sclk=0;
  }
  std=0; //RW=0;
  sclk=1;
  sclk=0;
  if(dat_comm)
    std=1; //if it is data, RS is 1
  else
  std=0; //if it is a control word, RS is 0
  sclk=1; //give the rising edge, start the transmission
  sclk=0; //pull sclk low
  std=0; //the 8th bit is 0, the start byte transmission is completed
  sclk=1; //Give rising edge to start transmission
  sclk=0;
  for(j=0;j<2;j++) //A byte is sent twice. The first time, the high four bits are sent, followed by 4 zeros. The second time, the low four bits are sent, followed by 4 zeros.
  {
    for(i=0;i<4;i++) //Transmit the high 4 bits first
    {
      a=a<<1; //Data is cyclically shifted left by one bit, and the low bit is filled with 0
      std=CY; //Transmit the carry                     
      sclk=1;
      sclk=0;
    }
    std=0;
    for(i=0;i<4;i++) //The last 4 bits of data are 4 0s
    {
      sclk=1;
      sclk=0;
    }
  }
}

/**********************LCD delay program************************************/
void delay (uint us) //lcd delay time
{
  while(us--);
}
void delay1 (uint ms)
{
  uint i,j;
  for(i=0;i   for(j=0;j<15;j++)
  delay(1);
}
/*************************Display data bit subroutine*******************/

void math_disp(uint math)
{ uint k;
       uchar i;
       uchar j;
       k=math;
    dispbuf[0]=k/10000; //get the ten thousand digit
    k=k%10000;
    dispbuf[1]=k/1000; //get the thousand digit
    k=k%1000;
    dispbuf[2]=k/100; //get the hundred digit
    k=k%100;
    dispbuf[3]=k/10; //get the ten digit
    dispbuf[4]=k%10; //get the unit digit
       wr_lcd (comm,0x90); //give the starting address of the second line so that the data can be displayed in the second line,
       for(i=0;i<5;i++)
  {
   for(j=0;j<2;j++) //continuously display the bytes in two tab2, LCD automatically connects these two bytes to display one data
   {
     wr_lcd(dat,tab2[xs2*dispbuf[i]+j]); //Call display subfunction
     }
    }
}

Keywords:12232c Reference address:12232c LCD display and 8051 microcontroller interface C language program

Previous article:Homemade 51 MCU common header files (st7920 parallel mode)
Next article:51 MCU and PC serial communication program and hardware circuit diagram

Recommended ReadingLatest update time:2024-11-16 15:00

Design of digital multi-motor control platform based on single-chip microcomputer C8051F020
   introduction   Stepper motors are very suitable for open-loop position control systems because of their low rotor inertia, high positioning accuracy, and no cumulative error. DC motors are commonly used in servo control. However, in actual systems, multiple moving parts often exist at the same time to meet differ
[Microcontroller]
Design of digital multi-motor control platform based on single-chip microcomputer C8051F020
89C52 and LCD1602
I have read C51 data in the past two days and familiarized myself with the statements. I haven't read any resources for 51 yet, but I wrote this program in a hurry. It's very clumsy. Finally, LCD1602 works and displays. Difficulty 1: Timing, Difficulty 2: 11 instructions of LCD1602; If the timing is correct, LCD1602
[Microcontroller]
Taiwan media: LCD panel manufacturers refuse to raise prices, driving IC design companies under pressure
According to industry sources, LCD driver IC design companies will raise their quotations to reflect the continued rise in chip foundry service costs, but LCD panel makers are reluctant to accept higher prices as panel prices have continued to fall since the end of the second quarter of 2021. According to digitimes,
[Mobile phone portable]
The Path of Learning for a Newbie in Single-Chip Microcomputers (Part 41) --- Understanding LCD1602 Liquid Crystal
Objective: Understand the working principle of LCD1602 liquid crystal 1. LCD1602 Introduction 1602 LCD is also called 1602 character LCD. It can display 2 lines of character information, and each line can display 16 characters, so it is referred to as 1602. It is a dot matrix LCD module specially used to display let
[Microcontroller]
The Path of Learning for a Newbie in Single-Chip Microcomputers (Part 41) --- Understanding LCD1602 Liquid Crystal
12864LCD dot matrix font display based on STM8/32
The main control of this solution uses STM8S207C8T6, 1.7-inch 128*64 LCD display, LCD driver chip uses UC1701 (compatible with ST7565), and font display uses Qualcomm GT20L16S1Y font chip to realize display on the LCD interface. The following are the module circuits of STM8S207C8T6, UC1701 and GT20L16S1Y in the schema
[Microcontroller]
12864LCD dot matrix font display based on STM8/32
TCL Huaxing successfully developed the world's narrowest LCD bottom frame
Today, TCL Huaxing announced that after two years of overcoming several technical difficulties, it has finally compressed the bottom bezel of the LCD module to the world's smallest 2.4mm (from the display area to the FPC bending apex), and successfully developed the world's narrowest LCD bottom bezel module product.
[Mobile phone portable]
vivo T1 5G may be launched in India: Snapdragon 695 + 6.58-inch LCD screen + 5000mAh battery
      Vivo has confirmed that it will release the T1 5G phone in the Indian market on February 9. Before the official release, the specifications and appearance of the phone have been exposed. According to the real spy photos shared by the whistleblower Ishan Agarwal (@ishanagarwal24), the back of the phone uses a spo
[Mobile phone portable]
Design of Oscilloscope Monitoring Program Based on C8051F020
The design uses the high-performance single-chip microcomputer C8051F020 as the control chip to monitor the status of 40 buttons, 3 coding switches and 4 potentiometers on the oscilloscope panel. The working principles of the keyboard, coding switch and potentiometer, as well as the hardware circuit and software pro
[Microcontroller]
Design of Oscilloscope Monitoring Program Based on C8051F020
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号