Purpose
I bought this parallel port screen to make a NES emulator game console. The SPI screen I used before was quite time-consuming to display the game screen because it was serial data. So I planned to try the parallel port screen and understand the driving method of the parallel port 8080.
Parallel Port Protocol
The 8080 timing is also called the Intel bus, which is usually found on LCDs in MCU (MPU) mode.
There are four Inter bus control lines:
RD: Write Enable
WR: Read Enable
DC(RS): - Data/Command
CS: Chip Select
Then there are several data lines, such as 8 or 16.
Write timing diagram
Reading Timing Diagram
It is important to note that the reading and writing of data are both valid on the rising edge of RD or WR. So we can write data first and then create a rising edge, or pull it low first and then pull it high after writing data. However, from the figure, the former is recommended.
ST7789 Pin Definition
There are several ways to use ST7789. Today we will only talk about the 16-bit parallel port driver.
Hardware Hookup
#define P_LEDA_PORTGPIOA
#define P_LEDA_PINGPIO_PIN_5//Backlight
#define P_RD_PORTGPIOA
#define P_RD_PINGPIO_PIN_9 //RD
#define P_WR_PORTGPIOA
#define P_WR_PINGPIO_PIN_10 //WR
#define P_CD_PORTGPIOA
#define P_CD_PINGPIO_PIN_11 //RS 0 is command 1: data
#define P_CS_PORTGPIOA
#define P_CS_PINGPIO_PIN_12 //cs 0 is selected
#define P_RESET_PORTGPIOA
#define P_RESET_PINGPIO_PIN_14 //REST
#define P_DATA_PORTGPIOB
#define P_DATA_PIN0xFFFF
in,
Backlight, some screens are called BLK, we can directly connect to the high level.
CS, we can directly connect it to low level, which is selected by default.
RD, we can directly pull the level high without the read function.
CD, some screens are called RS.
We use GPIOB 0~15 for data lines. Be careful here, or the screen will be distorted if you connect them wrong.
Then define the following control macro
#define P_CD_LOWP_CD_PORT->DATA &= ~P_CD_PIN
#define P_CD_HIGHP_CD_PORT->DATA |= P_CD_PIN
#define P_RESET_LOWP_RESET_PORT->DATA &= ~P_RESET_PIN
#define P_RESET_HIGHP_RESET_PORT->DATA |= P_RESET_PIN
#define P_WR_LOWP_WR_PORT->DATA &= ~P_WR_PIN
#define P_WR_HIGHP_WR_PORT->DATA |= P_WR_PIN
Here is how w801 is written, with the pins set high and low.
ST7789 core functions
The two most basic control functions of LCD display are writing registers and writing data.
void P_WriteReg(uint16_t reg)
{
P_CD_LOW;
WRITE_REG(P_DATA_PORT->DATA,reg);
P_WR_LOW;
P_WR_HIGH;
P_CD_HIGH;
}
void P_WriteData(uint16_t data)
{
WRITE_REG(P_DATA_PORT->DATA,data);
P_WR_LOW;
P_WR_HIGH;
}
Here we focus the modification of the control lines entirely on the write registers, because the write registers are used less frequently, so when writing data, the efficiency is higher.
Then the initialization function
void LCD_Init(void)
{
LCD_Reset_On();
HAL_Delay(120);
LCD_Reset_Off();
HAL_Delay(120);
LCD_WriteReg(0x3A); //65k mode
LCD_WriteData8(0x05);
LCD_WriteReg(0xC5); //VCOM
LCD_WriteData8(0x1A);
LCD_WriteReg(0x36);//Screen display direction settings
LCD_WriteData8(0x00);
//-------------ST7789V Frame rate setting-----------//
LCD_WriteReg(0xb2);
LCD_WriteData8(0x05);
LCD_WriteData8(0x05);
LCD_WriteData8(0x00);
LCD_WriteData8(0x33);
LCD_WriteData8(0x33);
LCD_WriteReg(0xb7);
LCD_WriteData8(0x35);
//--------------ST7789V Power setting---------------//
LCD_WriteReg(0xBB);//VCOM
LCD_WriteData8(0x3F);
LCD_WriteReg(0xC0); //Power control
LCD_WriteData8(0x2c);
LCD_WriteReg(0xC2);
LCD_WriteData8(0x01);
LCD_WriteReg(0xC3);
LCD_WriteData8(0x0F); //0Dgvd
LCD_WriteReg(0xC4);
LCD_WriteData8(0x20);
LCD_WriteReg(0xC6);
LCD_WriteData8(0X11); //0x0F
LCD_WriteReg(0xd0);
LCD_WriteData8(0xa4);
LCD_WriteData8(0xa1);
LCD_WriteReg(0xE8);
LCD_WriteData8(0x03);
LCD_WriteReg(0xE9);
LCD_WriteData8(0x09);
LCD_WriteData8(0x09);
LCD_WriteData8(0x08);
//---------------ST7789V gamma setting-------------//
LCD_WriteReg(0xE0); //Set Gamma
LCD_WriteData8(0xD0);
LCD_WriteData8(0x05);
LCD_WriteData8(0x09);
LCD_WriteData8(0x09);
LCD_WriteData8(0x08);
LCD_WriteData8(0x14);
LCD_WriteData8(0x28);
LCD_WriteData8(0x33);
LCD_WriteData8(0x3F);
LCD_WriteData8(0x07);
LCD_WriteData8(0x13);
LCD_WriteData8(0x14);
LCD_WriteData8(0x28);
LCD_WriteData8(0x30);
LCD_WriteReg(0XE1); //Set Gamma
LCD_WriteData8(0xD0);
LCD_WriteData8(0x05);
LCD_WriteData8(0x09);
LCD_WriteData8(0x09);
LCD_WriteData8(0x08);
LCD_WriteData8(0x03);
LCD_WriteData8(0x24);
LCD_WriteData8(0x32);
LCD_WriteData8(0x32);
LCD_WriteData8(0x3B);
LCD_WriteData8(0x14);
LCD_WriteData8(0x13);
LCD_WriteData8(0x28);
LCD_WriteData8(0x2F);
LCD_WriteReg(0x11);
HAL_Delay(120);
LCD_Clear(0x0000);/*Manually clear the screen before displaying to prevent screen distortion*/
LCD_WriteReg(0x29);//Turn on display
}
The screen orientation can be modified
LCD_WriteReg(0x36); //Screen display direction setting
LCD_WriteData8(0x00);
0x00 is the normal vertical screen
0xA0 is horizontal screen to the left
There are two other types, 0x60 and 0xC0, which are probably inverted and horizontal to the right. If you are interested, you can try them.
Error-prone points
The most error-prone part of the 16-bit driver is the coordinate setting. I thought the coordinates were 16 bits, so I could just write four coordinates. This is exactly wrong. It needs to be compatible with 8 bits, and each 16 bits must be written twice. Otherwise, there will be a screen distortion problem.
I spent a day to fix this bug.
void LCD_Address_Set(uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye)
{
LCD_WriteReg(0x2a);
LCD_WriteData(xs>>8);
LCD_WriteData(xs&0xff);
LCD_WriteData(xe>>8);
LCD_WriteData(xe&0xff);
LCD_WriteReg(0x2b);
LCD_WriteData(ys>>8);
LCD_WriteData(ys&0xff);
LCD_WriteData(ye>>8);
LCD_WriteData(ye&0xff);
LCD_WriteReg(0x2c);
}
Previous article:MCU---HLK-W801 drives touch screen
Next article:MCU---ESP8266Wifi SmartConfig one-click configuration (Part 2)
Recommended ReadingLatest update time:2024-11-24 19:07
- 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)
- 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)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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?
- 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
- Lead-free/RoHS latest notice
- Summary of Power Supply Problems Researched by Daniel for Many Years 2 (Benefited a lot)
- EEWORLD University Hall----Live Replay: ADI Energy Storage System Helps Build Electric Vehicle Fast Charging Stations
- Digital Temperature Servo Control System Based on Microcontroller
- Recruiting embedded system engineers
- About the power supply problem of LED constant current chip
- LIN communication, no response error, please help
- Amplifier Distortion
- Very useful, a summary of RF dry goods (worth collecting)
- MOS tube packaging types and packaging and improvements of mainstream companies