This article has three topics: FSMC configuration, a string of characters display principle, Chinese character display principle. . Let's get to the point.
1. FSMC configuration (the blogger uses FSMC_A10):
From someone else's blog http://blog.csdn.net/jxnu_xiaobing/article/details/8718566
I won't introduce the introduction of FSMC, there are a lot of them on the Internet. Let's discuss why the address line of FSMC is connected to the RS pin of TFTLCD? And how do we write data/commands to LCD?
FSMC is called variable static storage controller. Variable: It is called "variable" because by setting the special function register, FSMC can send out corresponding data/address/control signal types to match the signal speed according to different external memory types. (This is very important and will be mentioned later..) Let me
explain briefly~ Why not connect the IO port of STM32 directly to the corresponding pin of LCD? (Just look at the link I sent above and you will understand), it's basically troublesome to operate and inefficient. . Well, FSMC uses TFTLCD as an SRAM device. Its operation timing is completely similar to that of SRAM. The only difference is that TFTLCD has RS signal, but no address signal.
TFTLCD uses RS signal to determine whether the transmitted data is data or command, which can be understood as an address signal in essence. For example, we connect RS to A10 (of course, A0-Axx is OK). So how does LCD determine whether we are writing a command or data? Here is the key point! ! !
Take the program of Battleship as an example:
here, because the data line width is 16 bits, HADDR[25:1]->FSMC[24:0], which is equivalent to shifting one bit right. Here is the A10 offset given by Battleship:
0x6c000000 is no problem for everyone. It stands to reason that the offset of A10 should be 2 to the 11th power (0-10) = 2048, which is 800 in hexadecimal, which is also two bits larger than 7FE!
(Here is a review of the basics: RS=0, write command; RS=1, write data.)
Why? This is how I understand it (backward deduction): According to my thinking, if we take the address 0x6c000800 of LCD->LCD_REG, when the address is shifted right, the 10th bit is not 0, but 1. Corresponding to RS=1, then for the LCD it is not a write command, but write data; and because of the internal member alignment rules of the structure, the address of LCD->LCD_RAM is 0x6c00802, when the address is shifted right, the 10th bit is also 1, corresponding to RS=1. Still write data! ! ! !
You should understand it by this. If calculated according to the normal algorithm, RS will only be equal to 1, and will not distinguish between write commands and write data. Therefore ,
we have to subtract two bits from the offset of A10. We get 0x000007FE of the battleship in the figure. The address of LCD->LCD_REG is 0x6c0007FE. When the address is shifted right by one bit, the 10th bit is 0, corresponding to RS=0, which means a write command for the LCD; and because of the alignment rules of the internal members of the structure, the address of LCD->LCD_RAM is 0x6c000800. When the address is shifted right by one bit, the 10th bit is 1, corresponding to RS=1, which means data is written for the LCD. In this way, FSMC can distinguish whether the data or command is transmitted. . It's done!
At this point, the question arises: how can we complete the reading and writing by controlling the A10 line? Who controls the levels of more than ten pins?
This mysterious "character" is the FSMC we mentioned above! Let's first look at a register write function on a battleship:
The first figure: LCD->LCD_REG here is an address (0x6c000007FE), and the register number here refers to the register address defined in the LCD manual. As long as we write a variable (address) to the address LCD->LDC_REG. Because the address LCD->LDC_REG is under the jurisdiction of FSMC. So at this time, FSMC must bravely stand up and manage it~FSMC will generate the corresponding timing by itself, including CS, WR, RD and IO direction are all controlled by FSMC! This greatly facilitates our control of LCD. The
second figure: LCD->LCD_RAM here is also an address (0x6c00000800), LCD->LCD_RAM=data; is to write data into the register address.
2. The display principle of a string of characters (battleship)
1. For example, we want to display a string LCD_ShowString(x,x,x,"hello 21ic");x: are some coordinates and font size parameters, ignore them for now →_→
2. Then we have to call the character display function: LCD_ShowChar(); to get all the dots of a character.
3. Characters are composed of dots, so the dot drawing function LCD_DrawPoint(); is constantly called in the character function to draw dots (write color values to LCD->LCD_RAM, and this color value is defined as a 16-bit address in lcd.h).
4. So far, the LCD screen has been initialized in lcd_init() (setting display parameters), and it can be displayed.
5. Let's briefly analyze the principles of superposition and non-superposition →_→
Superposition means that if the character dot matrix is '1', the pen color is assigned, and if it is '0', the background color is assigned (the background color of that character has nothing to do with the full-screen background color). No problem! Because there is an overlay function when it is displayed at the end. That is, the full-screen color is displayed first, and then your character is overlaid on the basis of the full-screen color. So it shows superposition and non-superposition (only one brush color).
3. The principle of Chinese character display
In fact, the Chinese character display and English display are the same principle. It's very simple! The principle of display is to draw dots according to the byte size of your Chinese character font.
Let me briefly talk about it: Everyone knows that the principle of letter display is two for loops (the blogger knows this), the first for controls the 'row', and the second for controls the 'column'. Here are two examples: for example, to display a 16*08 letter, the first for loops 16 times, and the second for loops 8 times; to display a 24*24 Chinese character, the first for loops 72 times, and the second for loops 8 times. I don't know if you can see any pattern here →_→
Rule: The first for is the number of bytes occupied by the font, and the second for draws 8 bits each time (drawing 8 points from the highest point of the column down). There will be y-y0 in the middle of the character display function, which is to judge whether the number of points in a column has reached 16 or 24. If it is, it is x+1 and the next column is changed.
In general, the font bytes of Chinese characters are larger than the font bytes of letters. The parameters in the first fo and y-y0 are modified.
Previous article:stm32_FSMC Notes
Next article:STM32-TFT-LCD touch screen and FSMC basics
Recommended ReadingLatest update time:2024-11-16 11:51
- 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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- MSP430 library ADC12 module
- A one-page quick reference table of git commands
- Questions about the nonlinear capacitance of MOSFET tubes
- 【GD32L233C-START Review】1. Unboxing test to light up the color screen
- 【RT-Thread software package application works】+ unpacking and development environment establishment
- [STM32WB55 Review] 7# Use and configuration of ADC on STM32WB development board
- Why are we not allowed to take photos without core technology?
- Square wave triangle wave generating circuit
- Espressif ESP32-C3-DevKitM-1 review is coming soon. Let’s learn about this board first.
- After deleting a wire that was previously laid, AD09 got stuck.