LCD display direction

LCD display direction

1. Mapping of ILI9341 memory to display address

  This article only discusses "normal display" and does not discuss "vertical scrolling display" mode.

  It can be seen that the physical memory is accessed by two pointers, the row pointer and the column pointer , the row pointer ranges from 000h to 013Fh, and the column pointer ranges from 0000h to 00EFh. That is to say , the corresponding relationship between physical memory and LCD display screen is a corresponding relationship between vertical screen (240*320) . As for how to display the GRAM data on the LCD screen, we don't need to think about it, as long as we know the corresponding relationship.

  Then ILI9341 has 8 display modes: upper left corner -> lower right corner (vertical screen), lower left corner -> upper right corner (vertical screen), upper right corner -> lower left corner (vertical screen), lower right corner -> upper left corner (vertical screen) ), upper left corner -> lower right corner (horizontal screen), lower left corner -> upper right corner (horizontal screen), upper right corner -> lower left corner (horizontal screen), lower right corner -> upper left corner (horizontal screen), how to achieve What about?

2. The direction of MCU reading and writing GRAM

1. Read and write data stream from MCU

2. Control of ILI9341 reading and writing GRAM

1) The structure diagram of the ILI9341 controller for reading and writing GRAM

2) The conversion relationship from virtual address to physical address

  It can be seen that the mapping direction of the picture written into the GRAM is changed through the conversion of the virtual address to the physical address. That is to say, by changing the position of writing into GRAM, the display direction of LCD is changed.

3. Display direction description in 8

Look at the picture description:

  1. The control bits of MV, MX, and MY are in the register corresponding to command 0x36
  2. Image in the Memory (MPU) describes that an image "F" is displayed in 240 (width)*320 (height)*16bit (assuming 565 display mode) of the MCU.
  3. Image In the Driver (Frame Memory) describes the data display array that is actually transferred to the GRAM after a virtual address to physical address converter.
  4. B and E respectively describe the start position and end position of the data stream transmitted by the MCU.

Note: (x,y) stands for (column address, row address)

example 1: Y-Mirror

   The MCU writes data to (0,0), and after converting the virtual address to the physical address, the address actually written to the GRAM is (0,319), which corresponds to the lower left corner of the LCD. The MCU writes data to (239,319), and after converting the virtual address to the physical address, the address actually written to the GRAM is (239,0), which corresponds to the upper right corner of the LCD. The final effect is that the display of the LCD realizes the flipping in the Y direction.

example 1: X-Y Exchange

   The MCU writes data to (0,0), and after converting the virtual address to the physical address, the address actually written to the GRAM is (0,0), which corresponds to the upper left corner of the LCD. The MCU writes data to (239,319), and after converting the virtual address to the physical address, the address actually written to the GRAM is (319,239), corresponding to the lower right corner of the LCD.

  After such a transformation, the LCD becomes a horizontal screen display. The final effect is that the display of the LCD realizes the exchange of ranks and columns.

4. Exploration of 8 display directions

  Regardless of the display direction, the corresponding relationship between the GRAM physical memory and the LCD display does not actually change, that is to say, the corresponding relationship between the GRAM physical memory and the display, and the scanning method from the memory to the LCD are fixed.

  So how did this display direction start?

  In fact, the display direction refers to the corresponding relationship between the MCU's display cache MPU (or the data flow of the MCU reading and writing GRAM) and the LCD display. Since the corresponding relationship between GRAM physical memory and LCD display will not change, it is the corresponding relationship between MPU and GRAM, that is, the conversion relationship between virtual address and physical address.

  When the user writes the program, the LCD display operation is to change the content of the MPU, and the transmission from the MPU to the GRAM is completed by the driver. That is to say, the user controls the displayed content and contacts the MPU, and changing the display direction needs to configure the registers of the ILI9341.

  In fact, the scanning direction function of ILI9341 can also be disabled. At this time, the user's own software is required to convert it. In fact, it is the conversion relationship table.

3. Test

1. Upper left corner -> lower right corner (vertical screen)

2. Lower left corner -> upper right corner (vertical screen)

3. Upper right corner -> lower left corner (vertical screen)

4. Lower right corner -> upper left corner (vertical screen)

5. Upper left corner -> lower right corner (horizontal screen)

6. Lower left corner -> upper right corner (horizontal screen)

7. Upper right corner -> lower left corner (horizontal screen)

8. Lower right corner -> upper left corner (horizontal screen)

Reference: "ILI9341 Chip Manual"

Attached STM32 test code: GramScan_Test.zip

Category:  Stm32

Guess you like

Origin blog.csdn.net/u010783226/article/details/131656054