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-06-24 06:03 AM
Try to locate arduino library for ILI9488, study init procedure.
To verify connection read back internal registers, ID, etc, and verify.
2024-07-12 11:01 PM
@MasterT Can you refer any Arduino library related to a 3.5-inch ILI9488 TFT without touch?
2024-07-12 11:43 PM
I showed you here:
But no answer...nothing.
Which you choose ? or why not using this examples ?
2024-07-13 12:20 AM
In this example, the configuration is done using STM32CubeMX, and the settings and configuration are different. I am unable to understand it, but I am using STM32CubeIDE.
2024-07-13 12:43 AM
>but I am using STM32CubeIDE
me too.
>the configuration is done using STM32CubeMX
yes, its exactly same.
>am unable to understand it
ok, so this might be more easy to understand:
https://github.com/timagr615/TFT_ILI9488
(it is from the search/list i posted, so why you dont use it / try it ?? )
2024-07-13 02:27 AM
thank you @AScha.3 for your support, i will try
2024-07-18 06:46 AM
HI, @AScha.3 I tried the ILI9488 TFT, but it's not working. I have a doubt about the SPI configuration. I will send my IOC configuration as well as the code for sending a single command to the TFT through SPI. and I am checking the MOSI pin using an oscilloscope, but it is not showing any signal. I want to be aware of the SPI configuration.
help me!
#define RESET_PIN GPIO_PIN_2
#define RESET_PORT GPIOE
#define DC_PIN GPIO_PIN_4
#define DC_PORT GPIOE
#define CS_PIN GPIO_PIN_12
#define CS_PORT GPIOB
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_ICACHE_Init();
MX_UART7_Init();
MX_SPI2_Init();
//MIPI-DBI Type C Option 3 (4-line SPI)
HAL_GPIO_WritePin(GPIOF,GPIO_PIN_8,SET);//IM0--->1
HAL_GPIO_WritePin(GPIOF,GPIO_PIN_9,SET);IM1--->1
HAL_GPIO_WritePin(GPIOF,GPIO_PIN_10,SET);IM2--->1
TFT_init();
while (1)
{
ILI9488_SendCommand(0xE); // Adjust Control
HAL_Delay(1000);
}
}
void TFT_init()
{
HAL_GPIO_WritePin(CS_PORT,CS_PIN,GPIO_PIN_SET);
HAL_GPIO_WritePin(RESET_PORT,RESET_PIN,GPIO_PIN_SET);
HAL_Delay(1); // Delay 1ms
HAL_GPIO_WritePin(RESET_PORT,RESET_PIN,GPIO_PIN_RESET);
HAL_Delay(10); // Delay 10ms // This delay time is necessary
HAL_GPIO_WritePin(RESET_PORT,RESET_PIN,GPIO_PIN_SET);
HAL_Delay(120); // Delay 100 ms
}
void ILI9488_SendCommand(uint8_t com)
{
//*(__IO uint8_t *)(0x60000000) = com;
uint8_t tmpCmd = com;
//Set DC HIGH for COMMAND mode
//HAL_GPIO_WritePin(tftDC_GPIO, tftDC_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(DC_PORT,DC_PIN,GPIO_PIN_RESET);
//Put CS LOW
//HAL_GPIO_WritePin(tftCS_GPIO, tftCS_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(CS_PORT,CS_PIN,GPIO_PIN_RESET);
//Write byte using SPI
HAL_SPI_Transmit(&hspi2, &tmpCmd, 1, 1);
//SendByte(tmpCmd);
//WaitLastData();
HAL_GPIO_WritePin(CS_PORT,CS_PIN,GPIO_PIN_SET);
//Bring CS HIGH
//HAL_GPIO_WritePin(tftCS_GPIO, tftCS_PIN, GPIO_PIN_SET);
}
static void MX_SPI2_Init(void)
{
/* USER CODE END SPI2_Init 1 */
/* SPI2 parameter configuration*/
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_MASTER;
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_SOFT;
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 0x7;
hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE;
hspi2.Init.ReadyMasterManagement = SPI_RDY_MASTER_MANAGEMENT_INTERNALLY;
hspi2.Init.ReadyPolarity = SPI_RDY_POLARITY_HIGH;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
}
2024-07-18 06:53 AM
1. Is this
according to the ds of ILI9488 ?
2024-07-19 05:32 AM