2025-07-30 8:44 AM - last edited on 2025-08-15 3:33 AM by Amel NASRI
So I am currently trying out SPI connections for the ILI9341 on the 747I-Discovery board connections are as follows
#define SPI_RES_Pin GPIO_PIN_1
#define SPI_RES_GPIO_Port GPIOK
#define SPI_DC_Pin GPIO_PIN_6
#define SPI_DC_GPIO_Port GPIOJ
#define SPI_CS_Pin GPIO_PIN_5
#define SPI_CS_GPIO_Port GPIOJ
hspi5.Instance = SPI5;
hspi5.Init.Mode = SPI_MODE_MASTER;
hspi5.Init.Direction = SPI_DIRECTION_2LINES_TXONLY;
hspi5.Init.DataSize = SPI_DATASIZE_8BIT;
hspi5.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi5.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi5.Init.NSS = SPI_NSS_SOFT;
hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
hspi5.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi5.Init.TIMode = SPI_TIMODE_DISABLE;
hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi5.Init.CRCPolynomial = 0x0;
hspi5.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
hspi5.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
hspi5.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
hspi5.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi5.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi5.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
hspi5.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
hspi5.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
hspi5.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
hspi5.Init.IOSwap = SPI_IO_SWAP_DISABLE;
if (HAL_SPI_Init(&hspi5) != HAL_OK)
{
Error_Handler();
}
I am currently trying to just change the colour of the pixel like this ILI9341_DrawPixel(0, 0, 0xF800); but nothing changes.
void ILI9341_DrawPixel(uint16_t x,uint16_t y,uint16_t color)
{
if((x >=LCD_WIDTH) || (y >=LCD_HEIGHT)) return;
uint8_t bufferX[4] = {x>>8, x, (x+1)>>8, (x+1)};
uint8_t bufferY[4] = {y>>8, y, (y+1)>>8, (y+1)};
uint8_t bufferC[2] = {color>>8, color};
ILI9341_WriteCommand(0x2A); //ADDRESS
ILI9341_WriteBuffer(bufferX, sizeof(bufferX)); //XDATA
ILI9341_WriteCommand(0x2B); //ADDRESS
ILI9341_WriteBuffer(bufferY, sizeof(bufferY)); //YDATA
ILI9341_WriteCommand(0x2C); //ADDRESS
ILI9341_WriteBuffer(bufferC, sizeof(bufferC)); //COLOR
}
could someone help I am not sure where to look to check what is wrong.
Edited by ST Moderator to apply source code formatting - please follow the recommendation in this article How to insert source code
2025-08-19 1:50 AM
Hello @Goldylux
The ILI9341 LCD driver is used for the STM32F429I-Discovery board. You can find it integrated within the BSP examples as well as the LTDC application examples provided for this board. These examples demonstrate how the driver is utilized and should serve as a valuable reference.
Please review these examples on GitHub, as they are tailored for the STM32F429I-Discovery board. You can then adapt and port the relevant code to your STM32H747I-DISCO board accordingly.
Br