STM32 FSMC driving TFTLCD Difficulties Analysis

Publisher:火星叔叔Latest update time:2018-06-03 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:STM32 Reference address:STM32 FSMC driving TFTLCD Difficulties Analysis

Previous article:stm32_FSMC Notes
Next article:STM32-TFT-LCD touch screen and FSMC basics

Recommended ReadingLatest update time:2024-11-16 11:51

How to download programs using the STM32 serial port (USB serial port)
1. Steps for STM32 serial port download program  1) Install "CH340 driver (USB serial port driver)_XP_WIN7 common"  2) Open the serial port download software "STM32F4 serial port download software (FLYMCU)"  3) Connect the USB interface of the development board to the USB port of the computer and power the development
[Microcontroller]
FSMC driving TFTLCD principle, timing and register introduction
1. Introduction to FSMC FSMC: Flexible Static Storage Controller Capable of interfacing with synchronous or asynchronous memories and 16-bit PC memory cards The FSMC interface of STM32 supports memories including SRAM, NAND FLASH, NOR FLASH and PSRAM STM32 407 and 103 do not support SD RAM, 429, 439 support SD RAM ope
[Microcontroller]
The difference between using stm32 JTAG and SWD
Regarding the difference between the use of JTAG and SWD, I think the following article explains it clearly, so I repost it here, hoping it will be helpful to novices.  Differences and usage of SWD and JTAG 1. Differences between SWD and traditional debugging methods       1. SWD mode is more reliable than
[Microcontroller]
The difference between using stm32 JTAG and SWD
STM32-Serial communication printf redirection
Preface: When we do C language programming, we often use the printf function to print out and debug the code. However, this printf function C library has already implemented it for us, and usually we only need to call it directly. But if we are on a new development platform, if the library has not implemented it for u
[Microcontroller]
STM32 accurate delay 1us and 1ms function
Delay 1us:      1 /********************************************************      2 * Function name: delay_us       3 * Function function: delay function, delay us       4 * Input: i       5 * Output: None       6 ***************************************************************************/       7 void delay_us(u32 i)
[Microcontroller]
STM32 MDK project establishment
After two days of hard work, I finally understood the structure of the entire firmware library project and recorded the entire process for later review. 1. Create a new project in MDK and assign the chip 2. Add the startup file, located in ..\STM32F10x_StdPeriph_Lib_V3.2.0\Libraries\CMSIS\CM3\DeviceSupport\ST\S
[Microcontroller]
stm32 Boot0, Boot1 pin settings
Boot0, Boot1 pin settings?         (1) After Boot0 is set to 0, the code will be started from the main Flash, starting from the place where we are currently programming. As long as the program is normal, it can work normally after power-on. This is generally used as ISP Program download simulation burning. In normal m
[Microcontroller]
STM32 Study Notes--EXTI
1. PA0 ... PF0 share an interrupt flag EXT0       PA1 ... PF1 share an interrupt flag EXT1        . .        . .      PA15... PF15 share an interrupt flag EXT15 2. EXT5-9 share an interrupt source       EXT10-15 share an interrupt source    3. Before enabling interrupts, you need to ENABLE the multiplexing funct
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号