This productis a 2.0inch IPSdisplaymodule,ithas a resolution of320x240.ituses a 4-wire SPIcommunicationmethodand the inner ICis ST7789.The module contains an LCDdisplayand PCBbackboard.
Product Features
2.0-inch color screen,support65Kcolor display,displayrich colors320X240resolution,clear display
Large viewing angle(fullangle),displaycolor undistorted.Using the 4-line-SPIserialbus,itonlytakes a fewIOs to illuminate the displayProvide a rich STM32,C51,Arduino and MSP430sample programMilitary-grade process standards,long-termstable workProvide underlying driver technicalsupport
1. The following pin numbers 1~8refer to the module pin numbers of our company with PCB backplane. If you are buying a bare screen, please refer to the pin definition of the bare screen specification, refer to the wiring according to the signal type instead of directlyaccording to the following. The module pin number is used for wiring. For example:DCis6feet on our module. It may be x pin on different size barescreen.
2. About VCC supplyvoltage: The IPS display module can onlybe connected to 3.3V.
3. About backlight voltage: Themodulewith PCB backplane hasintegrated triode backlight control circuit, only need to input high level or PWMwave on BL pin to backlight. If you are buying a barescreen, the LEDAx is connected to 3.0V-3.3V, and the LEDKx can begrounded.
The LCDmodule hardware circuitcomprises two parts:an LCDdisplaycontrolcircuit
and a backlightcontrolcircuit.
The LCDdisplaycontrolcircuitis used to controlthe pins ofthe LCD,including
controlpins and data transfer pins.
The backlightcontrolcircuitis used to controlthe backlightto be on and off.Ofcourse,ifthe backlightis notrequired to be be on and off,can be directlyconnected to the 3.3Vpower supply.
working principle
1.Introduction to ST7789Controller
The ST7789controller supports a maximumresolution of240*320and a 172800-byte GRAM.Italso supports 8-bit,9-bit,16-bit,and 18-bitparallelportdata buses.Italso supports 3-wire and 4-wire SPIserialports.Since parallelcontrolrequires a large numberofIOports,the mostcommon one is SPIserialportcontrol.The ST7789alsosupports 65K,262KRGBcolor display,displaycolor is veryrich,while supporting rotating displayand scrolldisplayand video playback,displayin a varietyofways.
The ST7789controller uses 16bit(RGB565) to controla pixeldisplay,so itcan displayup to 65Kcolors per pixel.The pixeladdresssetting is performed in the orderofrows and columns,and the incrementing and decreasing direction is determined bythe scanning mode.The ST7789displaymethod is performed bysetting the address and thensetting the color value.
2.Introduction to SPI communication protocol
The 4-wire SPIbus write mode timing is shown in the following figure:
CSXis a slave chip select,and the chip is enabled onlywhen CSXis low.D/CXis the data/command controlpin ofthe chip.When DCXis low,the command is written.When itis high,the data is written.SCL is the SPIbus clock,and each rising edge transmits 1 bitofdata;SDAis the data transmitted bySPI,and ittransmits 8-bitdata ata time.The data formatis as shown below:
The high position is in frontand transmitted first.ForSPIcommunication,the data has a transmission timing,thatis,a combination ofclockphase (CPHA)and clockpolarity(CPOL):The CPOL leveldetermines the idle state levelofthe serialsynchronous clock,CPOL =0,which is low.CPOL does nothave a lotofimpacton the transportprotocol;The levelofCPHAdetermines whether the serialsynchronous clockis acquired on the firstclocktransition edge or the second clocktransition edge.When CPHL =0,data acquisition is performed on the firstedge ofthe transition;The combination ofthe two becomes the four SPIcommunication methods.SPI0 is usuallyused in China,thatis,CPHL =0,CPOL =0.
The IPSmodule provides software SPIand hardware SPIsample code (exceptSTC89C52RC,because itdoes nothave hardware SPIfunction),the two sample code does notmake anydifference in the displaycontent,butthe following aspects are different:
A.displayspeed
The hardware SPIis significantlyfaster than the software SPI,which is determined bythe hardware.
B.GPIOdefinition
The software SPIallcontrolpins mustbe defined,anyidle pin can be used,the hardware SPIdata and clocksignalpins are fixed (depending on the platform),other controlpins should be defined bythemselves,or anyidle reference can be used. foot.
C.initialization
When the software SPIis initialized,onlythe GPIOfor pin definition needs to be initialized (notrequired bythe C51 platform).When the hardware SPIis initialized,the relevantcontrolregisters and data registers need to be initialized.
3.GPIO definition description
A.STM32test program GPIOdefinitiondescription
non-SPIGPIOdefinition isplaced in lcd.h as shown below(takeSTM32F103RCT6microcontroller FSMCtestprogramas an example):
Allpin definitions can be modified and can be defined as anyother free GPIO.Ifyou are using a hardware SPItestprogram,you do notneedto define the GPIOofthe SPI.
Ifyou use the software SPItestprogram,the SPIGPIOdefinition is placed in spi.h,as shown below(take STM32F103RCT6 microcontroller testprogramas an example):
allpin definitions can be modified and can be defined as anyother free GPIO.
B.C51test program GPIOdefinitiondescription
GPIOdefinition is placed in the lcd.h file,as shown below:
Ifthe software SPIisused,allpin definitions can be modified and can be defined as anyother free GPIO.Ifhardware SPIis used,the LCD_BL,LCD_RS,LCD_CS,and LCD_RSTpin definitions can be modified and can be defined as anyother free GPIO.LCD_CLKand LCD_SDIdo notneed to be defined.
C.Arduino test program GPIOdefinitiondescription
The LCDscreen and touch screen GPIOdefinitions ofthe Arduino testprogramare placed separatelyin each application,which means thateach application can flexiblydefine GPIOaccording to requirements.As shown below(take UNOsoftware SPItestprogramas an example):
non-SPIGPIOdefinition isplaced in lcd.h as shown below:
Allpin definitions can be modified and can be defined as anyother free GPIO.Ifyou are using a hardware SPItestprogram,you do notneedto define the GPIOofthe SPI.Ifyou use the software SPItestprogram,the SPIGPIOdefinition is placed in spi.h,as shown below:
allpin definitions can be modified and can be defined as anyother free GPIO.
4.SPI communication code implementation
A.STM32 test program SPIcommunication code implementation
Hardware SPIcommunication is implemented bythe system.We onlyneedtooperate the register and callthe relevantfunction.For details,please refer to the MCUrelated documentation.
The software SPIcommunication code is implemented in spi.c ,as shown in the following figure:
Ifthe transmitted data bitis 1,the SPIdata pin is pulled high.When itis 0,the SPIdata pin is pulled low,one byte ofdata is transferred each time,the upperbitis first,and one bitofdata istransmitted on each rising edgeofthe clock.
B.C51test program SPIcommunicationcodeimplementation
The software SPIcommunication code is implemented in lcd.c ,as shown in the following figure:
Ifthe transmitted data bitis 1,the SPIdata pin is pulled high.When itis 0,the SPIdata pin is pulled low,one byte ofdata is transferred each time,the upperbitis first,and one bitofdata istransmitted on each rising edgeofthe clock.
C.Arduino test program SPIcommunicationcode implementation
Hardware SPIcommunication is implemented bythe system.We onlyneedto operate the register and callthe relevantfunction.For details,please refer to the MCUrelated documentation.
The software SPIcommunication code is implemented in the LCDWIKI_SPI.cpp
Ifthe transmitted data bitis 1,the SPIdata pin is pulled high.When itis 0,the SPIdata pin is pulled low,one byte ofdata is transferred each time,the upperbitis first,and one bitofdata istransmitted on each rising edgeofthe clock.
D.MSP430test program SPIcommunicationcode implementation
The software SPIcommunication code is implemented in spi.c ,as shown in the following figure:
Ifthe transmitted data bitis 1,the SPIdata pin is pulled high.When itis 0,the
SPIdata pin is pulled low,one byte ofdata is transferred each time,the upperbitis first,and one bitofdata istransmitted on each rising edgeofthe clock.
Common software
This setoftestexamples requires the displayofChinese and English,symbols and
pictures,so the modulo software is used.There are two types ofmodulo software:Image2Lcd and PCtoLCD2002.Here is onlythe setting ofthe modulo softwarefor the testprogram.The PCtoLCD2002modulo software settings are as follows:
Dotmatrix formatselectDarkcodethe modulo mode selectthe progressive modeTake the modelto choose the direction (high positionfirst)Outputnumber systemselects hexadecimalnumberCustomformatselection C51 formatThe specific setting method is as follows: