cancel
Showing results for 
Search instead for 
Did you mean: 

ILI9488 -TFT (without touch) not working on STM32H563ZIT6

Berlin-raj123
Associate II

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
}
16 REPLIES 16

So looks like:

AScha3_0-1721393804797.png

 

If you feel a post has answered your question, please click "Accept as Solution".

WhatsApp Image 2024-07-19 at 7.20.00 PM.jpeg

 

I connected one probe to the SPI MOSI pin and sent the data 0xE to the TFT, but it showed 0xFF.

hi @AScha.3  sorry for my late reply. I tried, but the signal shows a value of 0xFFWhatsApp Image 2024-07-22 at 10.43.59 AM.jpeg

I see no useful signal...

Ask (your teacher ? ) how to use a scope.

1. set probes to  10:1 

2. control/adjust probes with ref.signal

3. connect mosi + clk , show the traces

4. maybe set scope to decode mosi+clk

If you feel a post has answered your question, please click "Accept as Solution".

@AScha.3  Our company is small, and I am a fresher, so no one is available to help me. Please give me some guidelines. How do I calculate the prescaler value for SPI in the ILI9488? The HCLK is 250 MHz. Based on the dot clock frequency (DOTCLK = 20 MHz), I set the prescaler

Ok,

so see in Cube/IDE what you set:

AScha3_0-1721635255731.png

+

>so no one is available to help me

So they should pay someone, that knows, how to do it :

https://www.fiverr.com/categories/programming-tech/electronics-engineering/embedded-systems-iot

 

If you feel a post has answered your question, please click "Accept as Solution".

thank's for sharing!!