CS: Chip Select chip select, low level valid
RS: Register Select register select
WR: Write write signal, low level valid
RD: Read read signal, low level valid
RESET: Reset signal, low level valid
DB0-DB15: Data line
Suppose all these lines are controlled by ordinary IO ports. According to the LCD control chip manual (most control chips have similar timing):
If the situation is as follows:
All IOs of DB0-DB15 are 1 (indicating data 0xff), or any other value, here we take 0xff as an example.
CS is 0 (indicating that the chip is selected, and the chip will be effective for the incoming data when CS is pulled low)
RS is 1 (indicating that the value transmitted on DB0-15 is to be written to the register), if it is 0, it means that the data is transmitted.
WR is 0, RD is 1 (indicating a write action), and vice versa is a read action.
RESET is always high, if RESET is low, it will cause the chip to restart.
In this case, a value of 0xff will be transmitted to the chip, and the LCD control chip will interpret it as a write register value. After the LCD control chip receives the value on DB0-15, according to the situation of other control lines, it concludes that this 0xff is used to set the register. In general, the LCD control chip will treat the upper 8 bits of the incoming register value as the register address (because there must be more than one register inside the chip), and the lower 8 bits as the actual value to be assigned to the corresponding register. In this way, the timing of writing the internal register of the LCD control chip is completed.
If the above situation remains unchanged and only RS is set low, the situation is as follows: the LCD control chip will treat the data on DB0-15 as a simple data value. If the LCD is in the drawing state, the value 0xff passed in will be displayed on the corresponding point, and 0xffff means white, so the corresponding point is white. Before this data value is passed, the program will definitely tell the LCD control chip where the point to be written is by setting the register value.
If the above two situations remain unchanged, the WR and RD signals are reversed (WR=1, RD=0), then the write signal will be converted into a read signal. Under the read signal, the main control chip needs to read the value of DB0-15, and the LCD control chip will set the value of DB0-15 to complete the timing of reading data.
The timing of reading registers is a little more complicated. The first step is to set both WR and RD low, and the main control chip transmits the register address through DB0-15. The second step is the same as reading data before, set WR high, RD low, and read the value of DB0-15. During this whole process, RS is always low.
Well, the above is the method of directly controlling LCD with IO. If it is put into STM32, direct control with IO is very inefficient. STM32 has FSMC (in fact, other chips basically have similar bus functions). The advantage of FSMC is that once you set it up, the control lines and data lines such as WR, RD, DB0-DB15 are all automatically controlled by FSMC. For example, when you write in the program:
*(volatile unsigned short int *)(0x60000000)=val;
then FSMC will automatically perform a write operation, and the corresponding WE and RD pins of the main control chip will show the write timing (that is, WE=0, RD=1), and the value of data val will also be automatically presented through DB0-15 (that is, FSMC-D0:FSMC-D15=val). The address 0x60000000 will be presented on the data line (that is, A0-A25=0, the correspondence of the address line is the most troublesome, it depends on the specific situation, and you should read the FSMC manual carefully).
Then in terms of hardware, what we need to do is just the connection between MCU and LCD control chip:
WE-WR, both are valid at low level
RD-RD, both are valid at low level
FSMC-D0-15 connected to LCD DB0-15
After the connection is completed, the read and write timing will be automatically completed by FSMC. But there is still a very critical problem, that is, RS is not connected, CS is not connected. Because in FSMC, there is no corresponding RS and CS pins. What should I do? At this time, there is a good way, which is to use a certain address line to connect RS. For example, if we choose A16 as the address line to connect, then when we want to write to the register, we need RS, that is, A16 to be set high. How to do it in software? That is to change the address that FSMC wants to write to 0x60020000, as follows:
*(volatile unsigned short int *)(0x60020000)=val;
At this time, A16 will be pulled high while executing other FSMC, because A0-A18 will present the address 0x60020000. Bit17=1 in 0x60020000 will cause A16 to be 1.
When reading data, the address is changed from 0x60020000 to 0x60000000, and A16 is 0 at this time.
Then some friends will have questions. First, why is the address 0x6xxxxxxx instead of 0x0xxxxxxx? Second, how to connect CS? Third, why does Bit17 correspond to A16?
Let's look at the first two questions first. Everyone finds the FSMC manual of STM32. In the FSMC manual, we can easily find that FSMC uses the address of 0x60000000-0x6fffffff as NOR/PRAM (a total of 256M address range). And this storage block is divided into four parts, each with a 64M address range. When reading and writing one of the storage blocks, the corresponding NEx will be set low. Here, we solve our two problems. First, the operation timing of LCD is the same as NOR/PRAM (why is it the same? Find the timing of NOR/PRAM yourself), so we choose the address range of 0x6xxxxxxx (select this address range, when operating this address, FSMC will show the timing of NOR/PRAM). Second, we can connect NEx to the CS of the LCD, as long as the address we operate on is within the first memory block (i.e. the address range 0-0x3ffffff).
For the third question, let's look at the description of memory word width in the FSMC manual. We found that when the external memory is 16 bits, the hardware pins A0-A24 represent the values of address lines A1-A25, so we need to shift the value of Bit17, which will actually be reflected in the IO A16. Regarding the data width and shift, beginners may be confused. When you come into contact with devices such as NOR/PRAM, you will find that the buses of many chips are designed in this way to save address lines.
The above completely solves the problem of how to connect the LCD driver to the FSMC. If the reader does not understand, it is recommended to copy the above text and the chapter corresponding to NOR/PRAM in the FSMC manual. If you still don't understand, continue to copy it until you understand.
Although the above only explains FSMC for LCD, the operation of NOR and external RAM is similar, except that there are more address lines for addressing.
Previous article:STM32 SST25VF016B Driver
Next article:STM32 serial port experiment printf output problem
Recommended ReadingLatest update time:2024-11-17 01:59
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- MSP430 serial port receiving program (using interruption)
- Starting tomorrow: Follow the experts and challenge yourself to learn FreeRTOS in 21 days ~ win gifts + cash
- I heard that iPhone 13 will add reverse charging function???
- About the parallel and series resistors at OUT in the crystal oscillator circuit
- Video animation: intuitive understanding of electromagnetic radiation
- Single-chip microcomputer controlled xc1004 four-axis SPI motion control chip information
- I would like to ask a basic question: Is the discharge speed of parallel capacitors determined by the ESR of the capacitors?
- How to choose the appropriate inductor and its parameters? | MPS invites you to learn practical tips and win gifts by commenting!
- I need help with soldering tips. Why does flux often splash out when I add tin to my soldering iron, burning my hands?
- What are the differences between RTU and DTU?