Driving Graphical LCD with STM32F103ZET6

STM32F103ZET6 board comes with 3.2 inches graphical LCD which features an ILI9320 controller. Equipped LCD is capable of displaying 252144 colors when driven in 18-bit mode. We are going to run it in 16-bit mode, so we are limiting it to 65K colors.

Driving Graphical LCD with STM32F103ZET6

LCD driver is based on the existing code found on the internet, originally developed for the STM3210E board. Only minor modifications were needed, like assigning the proper control pins.

STM32F103ZET6 board was designed so that LCD was connected to Flexible Static Memory Controller (FSMC) of STM32. FSCM allows connecting most of the external parallel memory types like ROM, SRAM, NOR Flash, NAND Flash. ILI9320 driven LCD is plugged in 16-bit mode to FSMC Bank1 4th subpage and is seen as SRAM memory, so once configured, controlling LCD becomes the same as writing to SRAM. LCD memory starts from address 0x6C000000

#define LCD_BASE ((u32)(0x60000000 | 0x0C000000))
#define LCD ((LCD_TypeDef *) LCD_BASE)

LCD is controlled by using an index register which points to the selected register and with the next operation, we can write to its memory. So for this, there is a simple structure used:

what allows writing to register with a simple routine:

voidLCD_WriteReg(u8 LCD_Reg, u16 LCD_RegValue)
{
//Write 16-bit Index, then Write Reg
LCD->LCD_REG = LCD_Reg;
LCD->LCD_RAM = LCD_RegValue;
}

There are 152 registers used to control LCD, and most of these have to be initialized before accessing LCD. As I mentioned, it is already done in the LCD library no need to wary for now. In the attached project, you’ll find a working example of LCD, which displays a bitmap image stored in MCU SRAM.

By pressing one of four buttons, you can cycle through other functions like drawing simple shapes, displaying text, and drawing sine wave. Hopefully, you’ll find this useful. STM32F103ZET6GLCD

5 Comments:

  1. Great project. I will give it a try in my mini STM32 board. What is the IDE for this files? I am using keil.

  2. Project is based on CodeSourcery GCC with Eclipse editor.

  3. پروژه الکترونیک

    Is there any schematic for the TFT?

  4. Hello,

    What tool are you using to convert the images into .c/.h files?

    Regards,

    Robert

  5. Hi, there,

    Do you know how to read file from SD card and display it onto LCD ?
    I’m using STM32F103VCT

    Thanks

Leave a Reply