Single chip microcomputer controls LCD1602 to display characters (test passed)

Publisher:upsilon30Latest update time:2015-08-26 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
This test is on the commonly used LCD1602 display screen. The operation process is very simple, but there are some minor issues to pay attention to. For example, the LCD processing speed is a bit slow, and the microcontroller needs to delay appropriately when sending control instructions, otherwise the operation may fail.

1. Hardware Introduction

1>Pin Introduction

                  

The specific pins are as follows:

The pins that need to be operated on the microcontroller are: RS, RW, E and DB0~7

 

 

2>Instruction Introduction

 

 

Here, let’s just introduce what is CGRAM and what is DDRAM?

CGRAM: It is a user-defined character storage memory. You can define characters at the specified address.

DDRAM: It is a memory corresponding to the screen position. By setting this address, it is determined where on the screen the characters will be displayed.

2. Software

#include
#include
#define DATA P0
sbit RS=P2^6;
sbit RW=P2^5;
sbit EN=P2^7;
unsigned char zifu[]={"Hello,World!0"};
unsigned char wangzhi[]={"http://shop108408772.taobao.com/"};
void delayms(unsigned char m) //适当延时
{unsigned char i;
while(m--)
{
for(i=0;i<=250;i++)
{_nop_();
}
}
}
void WRITE_BYTE(unsigned char canshu)  //写1个字节
{
RW=0;
_nop_();
_nop_();
EN=1;
_nop_();
DATA=canshu;
EN=0;
_nop_();
_nop_();
}

 

 


void main()
{
unsigned char *point;
RS=0;
WRITE_BYTE(1); //Clear screen
delayms(10); //About 23ms delay
WRITE_BYTE(2); //Cursor home
delayms(10);
WRITE_BYTE(6);   //   AC automatically increases by 1, screen does not move
delayms(10);
WRITE_BYTE(0x0F); //Cursor display flashes
delayms(10);
WRITE_BYTE(0x14);   //Cursor moves right
delayms(10);
WRITE_BYTE(0x38); //Two lines display, 5X7 characters
delayms(10);
WRITE_BYTE(0x80);    //Set DDRAM address
delayms(10);
_nop_();
point=wangzhi;
while(*point!='') //Hello, world!,http: //shop108408772.taobao.com
{RS=1;
_nop_();
WRITE_BYTE(*point);
point=point+1;
delayms(10);
if(point==wangzhi+16)
{RS=0;
WRITE_BYTE(0xC0);    //Set the DDRAM address to the first character of the downstream
delayms(10);
}    
}
while(1);
}

 

 

3. Problems in testing

1> Pay attention to the appropriate delay after each instruction, otherwise the operation will go wrong

2> In this test, the busy flag is not read, and the direct delay and operation can basically pass

4. Test Results

Reference address:Single chip microcomputer controls LCD1602 to display characters (test passed)

Previous article:LCD1602 main parameters, pin functions and initialization methods
Next article:MSP430 MCU Mode IIC Protocol C Language Program

Latest Microcontroller Articles
  • 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)
    Since development under LINUX is still quite troublesome, is there a more convenient and simple development method under WINDOWS? The answer is yes. Of course, it is not a development tool like ADS, because it ...
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
  • Learn ARM development(18)
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号