Sixiu Electronic Studio "Xiangyun Little Prince" development version
Define Pins
/**************************Port/pin definition area****************************/
#define LCDRS PF_ODR_ODR0 //LCD1602 data/command selection port
#define LCDRW PF_ODR_ODR3 //LCD1602 read and write control port
#define LCDEN PF_ODR_ODR4 //LCD1602 enable signal port
#define LCDDATA PB_ODR //LCD1602 data port D0 to D7
initialization
/****************************************************************/
//LCD1602 initialization function LCD1602_init(), no parameters or return values
/****************************************************************/
void LCD1602_init(void)
{
LCD1602_Write(0x38,0); //Configure 16*2 display, 5*7 dot matrix, 8-bit data interface
LCD1602_Write(0x0C,0); //Set to display, do not display cursor
LCD1602_Write(0x06,0); //Address automatically increases by 1 after writing characters
LCD1602_Write(0x01,0); //display cleared to 0, data pointer cleared to 0
}
Write LCD module command or data function
void LCD1602_Write(u8 cmdordata,u8 writetype)
{
if(writetype==0)//Judge the write type
LCDRS=0; //Write command information
else
LCDRS=1; //Write data information
LCDDATA=cmdordata; //Write information to the data line port
delay(5); //delay to wait for stabilization
LCDEN=1; //module enable
delay(5); //delay waiting for writing
LCDEN=0; //Module is disabled
}
Display character function
void LCD1602_DIS(void)
{
u8 i; //define control loop variable i
LCD1602_Write(0x80,0); //Select the first line
for(i=0;i<16;i++)
{
LCD1602_Write(table1[i],1); //Write the contents of table1[]
delay(5);
}
LCD1602_Write(0xC0,0); //Select the second line
for(i=0;i<16;i++)
{
LCD1602_Write(table2[i],1); //Write the contents of table2[]
delay(5);
}
}
Move screen
void LCD1602_MOV(void)
{
u8 i;
LCD1602_Write(0x01,0); //Clear screen
LCD1602_Write(0x90,0); //Select the end of the first line (invisible)
for(i=0;i<16;i++)
{
LCD1602_Write(table1[i],1); //Write the contents of table1[]
delay(2);
}
LCD1602_Write(0xD0,0); //Select the end of the second line (invisible)
for(i=0;i<16;i++)
{
LCD1602_Write(table2[i],1); //Write the contents of table2[]
delay(2);
}
for(i=0;i<16;i++)
{
LCD1602_Write(0x18,0); //Loop 16 times and move the screen left one by one
delay(100);
}
}
Set address to write character
/****************************************************************/
//Set the address to write the character function LCD1602_DIS_CHAR(), with parameters x, y, z and no return value
//x represents the row of the 1602 LCD, y represents the column address, and z represents the character to be written
/****************************************************************/
void LCD1602_DIS_CHAR(u8 x,u8 y,u8 z)
{
u8 address;
if(x==1) //If you want to display it in the first line
address=0x80+y; //The first row address + column address
else
address=0xC0+y; //The first address of the second row + the column address
LCD1602_Write(address,0); //Set display address
LCD1602_Write(z,1); //Write character data
}
/****************************************************************/
//Combined graphics display function LCD1602_DIS_FACE(), invisible parameters and return values
/****************************************************************/
void LCD1602_DIS_FACE(void)
{
LCD1602_DIS_CHAR(1,1,'*');
LCD1602_DIS_CHAR(2,2,'.');
LCD1602_DIS_CHAR(1,3,'*');
LCD1602_DIS_CHAR(1,4,'|');
LCD1602_DIS_CHAR(2,4,'|');
LCD1602_DIS_CHAR(1,5,'*');
LCD1602_DIS_CHAR(2,6,'_');
LCD1602_DIS_CHAR(1,7,'*');
LCD1602_DIS_CHAR(1,8,'|');
LCD1602_DIS_CHAR(2,8,'|');
LCD1602_DIS_CHAR(1,9,'*');
LCD1602_DIS_CHAR(2,10,'x');
LCD1602_DIS_CHAR(1,11,'*');
LCD1602_DIS_CHAR(1,12,'|');
LCD1602_DIS_CHAR(2,12,'|');
LCD1602_DIS_CHAR(1,13,'*');
LCD1602_DIS_CHAR(2,14,'v');
LCD1602_DIS_CHAR(1,15,'*');
}
Previous article:STM8L152 LCD module principle and driver
Next article:STM8 4-wire driver 1602 garbled code
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- To drive a 24V5A motor, what current should the freewheeling diode have?
- CC2640R2F supports Alibaba Cloud Link IoT platform
- Some understanding of MSP430 usage
- 【HomeBao】Supplementary experiment for project submission: Connecting HomeBao to HomeAssistant
- 1. Unpacking and running the Helloworld example
- 【Repost】Thirty Practical Experiences in Switching Power Supply Design (Part 1)
- blue_nrg, how to turn off subscription function
- CC26xx product model and suffix description
- AD19, board layer, layer type, what are the uses of each? Please guide
- Melexis for you: Detailed explanation of the implementation and technical support of functional safety in semiconductor R&D. Registration for the prize-winning live broadcast is open!