code show as below:
#include
#include
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef bit BOOL ;
sbit rs = P2^0; //
sbit rw = P2^1;
sbit ep = P2^2;
BYTE code dis1[] = {"welcome!"};
BYTE code dis2[] = {"china !!!refuel!"};
delay(BYTE ms)
{ // Delay subroutine
BYTE i;
while(ms--)
{
for(i = 0; i< 250; i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
}
BOOL lcd_bz()
{ // Test LCD busy status
BOOL result;
rs = 0;
rw = 1;
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
result = (BOOL)(P0 & 0x80);
ep = 0;
return result;
}
lcd_wcmd(BYTE cmd)
{ // Write command data to LCD
while(lcd_bz());
rs = 0;
rw = 0;
ep = 0;
_nop_();
_nop_();
P0 = cmd;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 0;
}
lcd_pos(BYTE pos)
{ //Set the display position
lcd_wcmd(pos | 0x80);
}
lcd_wdat(BYTE dat)
{ //Write character display data to LCD
while(lcd_bz());
rs = 1;
rw = 0;
ep = 0;
P0 = that;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 1;
_nop_();
_nop_();
_nop_();
_nop_();
ep = 0;
}
lcd_init()
{ //LCD initialization settings
lcd_wcmd(0x38); //
delay(1);
lcd_wcmd(0x0c); //
delay(1);
lcd_wcmd(0x06); //
delay(1);
lcd_wcmd(0x01); //Clear the LCD display content
delay(1);
}
main()
{
BYTE i;
lcd_init(); // Initialize LCD
delay(10);
lcd_pos(4); // Set the display position to the 5th character in the first line
i = 0;
while(dis1[i] != '\0')
{ // Display the text "welcome!"
lcd_wdat(dis1[i]);
i++;
}
lcd_pos(0x41); // Set the display position to the second character in the second line
i = 0;
while(dis2[i] != '\0')
{
lcd_wdat(dis2[i]); // Display characters
i++;
}
while(1); //
}
Previous article:Use of timer of STC89C52 microcontroller
Next article:Microcontroller LCD Experiment 1
Recommended ReadingLatest update time:2024-11-23 08:05
Design of Decimal Calculator System Based on AT89C51 Single Chip Microcomputer
introduction
This system uses AT89C51 single-chip microcomputer as the controller to realize the four-digit "+", "-", "*", "/" operation. The operation result is displayed through the digital tube and has a clearing function. AT89C51 has the following features: 40 pins, 4k BytesFlash on-chip program me
[Microcontroller]
51 MCU series - how to write external interrupts (explanation + example: change the pipeline
When I was learning about 51 MCU interrupts, I was often confused by external interrupts, timers/counters, and serial ports. I was originally a primary school student, how could I stand the torture! ! ! I have nothing to do, so I wrote this today to introduce and explain the external interrupts INT0 and INT1. I will
[Microcontroller]
Design of broadband DC amplifier based on MSP430F449 single chip microcomputer
According to the design requirements, the maximum voltage gain ≥ 60dB is achieved within a wide signal bandwidth (0-10MHz), and the ability to continuously adjust the gain or preset the gain in 5dB steps is the biggest difficulty and one of the key points of the design. Another difficulty is that the maximum output
[Microcontroller]
2: The first 51 single-chip microcomputer assembly experiment
An instruction is an instruction that instructs the microcontroller to perform a certain operation. 1. Machine code instructions are expressed in binary (or hexadecimal). This form of instruction can be directly recognized and executed by computer hardware. For example: binary code "0000 0100B", (hexadecimal "04H").
[Microcontroller]
In-Application Programming MAXQ Microcontrollers with Erasable Program and Data Partitions
Abstract: This application note describes the program and data flash memory in MAXQ microcontrollers and how to erase/write the flash memory using the built-in application ROM. This application note applies to all MAXQ microcontrollers that use sector-erasable flash memory.
introduction
This application note d
[Analog Electronics]
Calculation of accurate timing of the timer of PIC microcontroller
Here, TMR0 of 16C711 microcontroller is used as timer interrupt, hoping to achieve accurate timing. In the program, TMR0 uses the 32-frequency division of the crystal oscillator, and the initial value is #0FCH. Therefore, POPBEAR brothers calculated the timing time of each timer interrupt as (256-X)*32*4/32768=0.01562
[Microcontroller]
PID Water Temperature Control System Based on 51 Single Chip Microcomputer
1. Hardware Solution This design mainly uses the 51 single-chip microcomputer system for temperature acquisition and control; the temperature signal is collected by the digital temperature sensor DS18B20, and the main controller actively obtains the sensor temperature value, calculates it with the set temperature thro
[Microcontroller]
Some basic issues of microcontrollers
What do 1T 4T 6T 12T microcontrollers generally refer to?
The standard 51 is 12T, which means 12 clock cycles (crystal cycle, for example, 12M, the cycle is 1/12M, unit is second), the machine does an instruction cycle, exactly 1/12M*12=1uS, common instructions such as nop is one cycle, exactly 1uS, most of the othe
[Microcontroller]
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Recommended Content
Latest Microcontroller Articles
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
MoreDaily News
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
Guess you like
- Causes of thermal resistor soft breakdown and troubleshooting of thermal resistor soft breakdown
- "Playing with the board" + lighting up the SPI touch screen of Xintao
- Ultrasonic flaw detection system using high-speed and high-resolution signal acquisition card
- 2020-7-5-Abdominal breathing training trainer
- ST MEMS Device Resource Library - Hardware Design Guide
- &FF0000 and &880000 are both red. What is the difference between these two reds?
- Internet radio design based on RSIC-V RVB2601 (3)
- LIS2MDL three-axis magnetometer package and code
- Live broadcast with prizes: Enter the TI robot production class, starting on Friday, reservations are in progress! (Share 100% to get gifts)
- Do you have any use for STM8S005C6T6? Special price for delivery