Skip to main content
Visitor II
June 24, 2024
Question

ILI9488 -TFT (without touch) not working on STM32H563ZIT6

  • June 24, 2024
  • 1 reply
  • 5226 views

Hi, I am trying to interface with a 3.5-inch ILI9488 TFT display (without touch) on an STM32H563ZIT6 microcontroller. I'm attempting to write a test function to fill the entire screen with a solid red color, but it's not working. Could anyone please help me? I will attach my code. How can I verify that SPI is properly working with the TFT?

#include "main.h"

SPI_HandleTypeDef hspi2;

UART_HandleTypeDef huart7;

#define ILI9488_CMD_MEMORY_WRITE 0x2C
#define ILI9488_CMD_MEMORY_ACCESS_CTRL 0x36

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ICACHE_Init(void);
static void MX_SPI2_Init(void);
static void MX_UART7_Init(void);
void ILI9488_FillScreen(uint16_t color);
void ILI9488_SendData(uint8_t data);
void ILI9488_SendCommand(uint8_t cmd);
void ILI9488_Init(void);
void testFillScreen(uint16_t color);

#define WIDTH 320
#define HEIGHT 480
#define CS_PORT GPIOB
#define CS_PIN GPIO_PIN_12

#define DC_PORT GPIOE
#define DC_PIN GPIO_PIN_4

#define RESET_PORT GPIOE
#define RESET_PIN GPIO_PIN_2
uint8_t tx_buffer[50];
int uart_buffer_len;
char spi_buffer[20];
int main(void)
{
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();
/* Configure the system clock */
 SystemClock_Config();
/* Initialize all configured peripherals */
 MX_GPIO_Init();
 MX_ICACHE_Init();
 MX_SPI2_Init();
 MX_UART7_Init();
 ILI9488_Init();
 // Test filling screen with red color
 ILI9488_FillScreen(0xF800); // Red color in 16-bit RGB
 while (1)
 {

 }
}
void ILI9488_Init(void)
{
	 // Reset display
 ILI9488_SendCommand(0x01); // Software Reset
 HAL_Delay(150);
 ILI9488_SendCommand(0x11); // Sleep Out
 HAL_Delay(150);
 ILI9488_SendCommand(0x29); // Display On
}
void ILI9488_SendCommand(uint8_t cmd)
{
 HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_RESET); // DC low for command
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); // CS low
 HAL_SPI_Transmit(&hspi2, &cmd, 1, HAL_MAX_DELAY);
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); // CS high
}
void ILI9488_FillScreen(uint16_t color)
{
 uint8_t highByte = color >> 8;
 uint8_t lowByte = color & 0xFF;

 ILI9488_SendCommand(0x2C); // Memory Write

 for (int i = 0; i < WIDTH * HEIGHT; i++)
 {
 ILI9488_SendData(highByte);
 ILI9488_SendData(lowByte);
 }
}
void ILI9488_SendData(uint8_t data)
{
 HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET); // DC high for data
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET); // CS low
 HAL_SPI_Transmit(&hspi2, &data, 1, HAL_MAX_DELAY);
 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); // CS high
}
    This topic has been closed for replies.

    1 reply

    Explorer
    June 24, 2024

    Try to locate arduino library for ILI9488, study init procedure.

    To verify connection read back internal registers, ID, etc, and verify.

    Visitor II
    July 13, 2024

    @MasterT Can you refer any Arduino library related to a 3.5-inch ILI9488 TFT without touch?

    Super User
    July 13, 2024

    I showed you here:

    https://community.st.com/t5/stm32-mcus-boards-and-hardware/ili9488-tft-example-code-in-stm32h563zit6/td-p/688509

    But no answer...nothing.

    Which you choose ? or why not using this examples ?