2024-06-24 02:32 AM
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
}
2024-07-19 05:57 AM
So looks like:
2024-07-19 06:53 AM
I connected one probe to the SPI MOSI pin and sent the data 0xE to the TFT, but it showed 0xFF.
2024-07-21 10:14 PM
hi @AScha.3 sorry for my late reply. I tried, but the signal shows a value of 0xFF
2024-07-21 10:52 PM
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
2024-07-22 12:50 AM
@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
2024-07-22 01:04 AM
Ok,
so see in Cube/IDE what you set:
+
>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
2024-07-22 02:50 AM
thank's for sharing!!
2024-07-26 02:58 AM
@AScha.3 I checked that the SPI is working well on the oscilloscope and i saw the signal also, but the TFT is still not working. i want small changes in my TFT like showing bg color.if i get anything,easily i will take into another level.
2024-07-26 03:08 AM
>but the TFT is still not working.
Thats "standard" ! (None of my TFTs working at first - always something was wrong. )
IF hardware/wires ok ...
IF SPI setting/timing ok...
IF TFT start/init settings ok...
THEN you see first (!) time something , anything happens on the screen. random pixels...
THEN your close, write cls/filled rect , etc. - it will work.
Now you still at the "IF" stage. :)
2024-07-26 03:13 AM
@AScha.3 :smiling_face_with_smiling_eyes: ok.. thank you