This is a library for those LCDs using 16-bit parallel interface based on ILI9341.
Actually there isn't much information about HAL's FSMC's usage in LCD controller.
I have referred articles below and they did a lot help to me:
Martnak's lib is based on SPI and in some occasions it's quite slow. So FSMC is a good choice to drive a high-speed lcd display.
Configure FSMC in cubeMX and other necessary params(For details you can look into the demo in the repo.)
And Generate Code, I use Clion + cmake to build project so i choose SW4STM32.
Then follow the procedure below :
- include "ili9341.h" in main.c
- refer ILI9341_Init(); in main() function(before while (1)).
- refer ILI9341_Test(); in while(1) to test whether it's fine.
- Enjoy :)
FSMC parameters generated by cubeMx is not quite perfect for lcd displays.
If you want faster speed, you can change the params in Src/fsmc.c 's MX_FSMC_Init() function
Here is an example:
//params generated be cubeMx automatically
/*
Timing.AddressSetupTime = 15;
Timing.AddressHoldTime = 15;
Timing.DataSetupTime = 255;
Timing.BusTurnAroundDuration = 15;
Timing.CLKDivision = 16;
Timing.DataLatency = 17;
*/
//Changed value as below
Timing.AddressSetupTime = 2;
Timing.AddressHoldTime = 2;
Timing.DataSetupTime = 16;
Timing.BusTurnAroundDuration = 2;
Timing.CLKDivision = 16;
Timing.DataLatency = 2;
This will improve the display speed a lot. Hope it helps.
STM32 | ILI9341_LCD | Comment |
---|---|---|
FSMC_Dx | DBx | 16 pins in total |
FSMC_NOE | LCD_RD | Read |
FSMC_NWE | LCD_WR | Write |
FSMC_NEx | LCD_CS | Chip select |
FSMC_Ax | LCD_RS | Register Select (Not Reset!) |
User defined RST pin | LCD_RST | Reset |