16X2 character LCD displays "LCD TEST OK"
Circuit Description:
The circuit diagram is shown below:
Port A of the HT48R50A-1 is connected to D0-D7 (data bus) of the character LCD, using the 8-bit data interface of the character LCD.
Connect PC1 of the HT48R50A-1 to the read/write pin of the LCD. When the read/write pin of the LCD is at a high level, it means that data will be read from the LCD, and when the read/write pin of the LCD is at a low level, it means that data will be written into the LCD.
Connect PC2 of the HT48R50A-1 to the LCD’s E pin. When the LCD’s E pin is at a high level, the data on the LCD’s D0-D7 pins will be written into the LCD. Normally, the LCD’s E pin remains at a low level.
Connect the PC0 of the HT48R50A-1 to the RS pin of the LCD. When the RS pin of the LCD is low and the LCD is read or written, the LCD command can be written into the LCD command register. If the LCD is read or written, the LCD busy flag and address counter can be read. The LCD busy flag is 1 bit, the address counter is 7 bits, a total of 8 bits. When the RS pin of the LCD is high, the LCD data register can be read or written.
Connect the CO pin of the character LCD to GND. The VO pin is the brightness adjustment voltage input pin of the character LCD. Usually, the characters on the character LCD are clearest when the VO pin is grounded. You can also connect the VO pin to a variable resistor to adjust the contrast of the character LCD.
The complete version of the program source code download address: http://www.51hei.com/f/htlcd.rar , the main.c file is listed below:
#include "HT46F49E.H" #define lcd_en _pc1 #define lcd_rs _pc0 #define lcd_date _pa unsigned char table1[]="LCD 1602"; unsigned char table2[]="TEST IS OK!"; unsigned char num; void delayms(unsigned int n) //ms delay { while(n>0) { _delay(984); n--; } } void write_com(unsigned char com) // write command { lcd_rs=0; //lcdrs=0, select write command mode delayms(5); lcd_date=com; // Command word sent to data bus delayms(5); lcd_en=1; //lcden=1, enable, already set low during init initialization delayms(5); lcd_en=0; } void write_date(unsigned char date) // write data { lcd_rs=1; delayms(5); lcd_date=date; delayms(5); lcd_en=1; delayms(5); lcd_en=0; } void lcd_init() { write_com(0x38); delayms(2); write_com(0x0c); delayms(2); write_com(0x06); deleyms(2); write_com(0x01); delayms(2); } void main() { lcd_init(); write_com(0x80); for(num=0;num<8;num++) { write_date(table1[num]); delayms(2); } write_com(0x80+0x40); for(num=0;num<11;num++) { write_date(table[num]); delayms(2); } while(1); }
Previous article:Some summary of embedded memory and BootLoader
Next article:HOLTEK MCU-Interrupt Priority Test
- 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
- 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
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- GD32E503V-EVAL Evaluation Summary
- 1
- SHT31 Review - In-depth Review
- Four major reasons for power module heating
- 【Home smart dashboard】esp32 s2 LED, button driver
- Does the backlight 14-leds in LCD refer to the number of LEDs in the backlight?
- [GD32L233C-START Review] III. Comparison of various image refresh drive methods for 1.5-inch monochrome 16-level grayscale OLED
- 【McQueen Trial】+ Unboxing and Assembly
- This must be a liar.
- How to find MSP430 program examples on TI's official website