2025-11-27 1:44 AM - last edited on 2025-11-27 2:47 AM by Andrew Neil
I want to use ILID9341 screen on STM32F407G-DISC1 without any libraries, just spi protocol. However, while the screen turns on, I can't draw anything on it. Why is this the case?
This is SPI configuration.
I have checked the physical wiring, and it seems to be correct.
This is the code that is relevant for the LCD screen (there is also a code for functions for reading values from accelometer, which is probably not relevant).
#define RST_GPIO_PORT GPIOD
#define RST_GPIO_PIN GPIO_PIN_9
#define DC_GPIO_PORT GPIOB
#define DC_GPIO_PIN GPIO_PIN_14
#define SET_ROW_CMD 0x2B
#define SET_COL_CMD 0x2A
#define SET_COLOR_CMD 0x2C
void Reset_Screen() {
HAL_GPIO_WritePin(RST_GPIO_PORT, RST_GPIO_PIN, GPIO_PIN_RESET); // pull low
HAL_Delay(10);
HAL_GPIO_WritePin(RST_GPIO_PORT, RST_GPIO_PIN, GPIO_PIN_SET); // release reset
HAL_Delay(120);
}
void Write_Rectangle(uint16_t row_lower, uint16_t row_higher, uint16_t col_lower, uint16_t col_higher, uint16_t color) {
//16 bit/pixel color order (R:5-bit, G:6-bit, B:5-bit)
//1.Set column
uint8_t col_params[4] = {(uint8_t)(col_lower >> 8), (uint8_t)(col_lower & 0x00FF),
(uint8_t)(col_higher >> 8), (uint8_t)(col_higher & 0x00FF)};
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET); //send command
uint8_t set_col_cmd[] = {SET_COL_CMD};
HAL_SPI_Transmit(&hspi2, set_col_cmd, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET); //send data for command
HAL_SPI_Transmit(&hspi2, col_params, 4, 100);
//2.Set row
uint8_t row_params[4] = {(uint8_t)(row_lower >> 8), (uint8_t)(row_lower & 0x00FF),
(uint8_t)(row_higher >> 8), (uint8_t)(row_higher & 0x00FF)};
uint8_t set_row_cmd[] = {SET_ROW_CMD};
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET); //send command
HAL_SPI_Transmit(&hspi2, set_row_cmd, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET); //send data for command
HAL_SPI_Transmit(&hspi2, row_params, 4, 100);
//3.Set color
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET); //send command
uint8_t set_color_cmd[] = {SET_COLOR_CMD};
HAL_SPI_Transmit(&hspi2, set_color_cmd, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET); //send data for command
// Compute rectangle size
uint32_t width = col_higher - col_lower + 1;
uint32_t height = row_higher - row_lower + 1;
uint32_t pixels = width * height;
// Send color repeatedly
//uint8_t *pix_array = malloc(pixels);
//for (int i = 0; i < ; i++) {
// pix_array[i] =
//}
uint8_t pix[2] = {(uint8_t)(color >> 8), (uint8_t)(color & 0xFF)};
//uint32_t total_bytes = pixels * 2;
//HAL_SPI_Transmit(&hspi2, pix_array, total_bytes, 1000);
//free(pix_array);
for (uint32_t i = 0; i < pixels; i++) {
HAL_SPI_Transmit(&hspi2, pix, 2, 100);
}
}
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_I2S3_Init();
MX_SPI1_Init();
MX_USB_HOST_Init();
MX_SPI2_Init();
/* USER CODE BEGIN 2 */
//Reset the screen
Reset_Screen();
//screen experiment, delete later (black rectangle)
Write_Rectangle(0, 10, 0, 10, 0);
//Set everything for the accelometer
uint8_t OUT_X_L = 0x28;
uint8_t OUT_X_H = 0x29;
uint8_t OUT_Y_L = 0x2A;
uint8_t OUT_Y_H = 0x2B;
uint8_t OUT_Z_L = 0x2C;
uint8_t OUT_Z_H = 0x2D;
uint8_t CTRL_REG5 = 0x24; //for sensitivity (change from default 2 to 4/8) (bits 5-4)
//receivers and transmitters
//xyz_addr[6] = {OUT_X_L, OUT_X_H, OUT_Y_L, OUT_Y_H, OUT_Z_L, OUT_Z_H};
xyz_addr[0] = OUT_X_L; xyz_addr[1] = OUT_X_H; xyz_addr[2] = OUT_Y_L; xyz_addr[3] = OUT_Y_H; xyz_addr[4] = OUT_Z_L; xyz_addr[5] = OUT_Z_H;
uint8_t ctrl_val;
//fill buffer with 0s
for (int i = 0; i < ACC_BUF_SIZE; i++) {
acc_values_buf[i] = 0;
}
//receive and set accelerator sensitivity
HAL_SPI_TransmitReceive(&hspi1, &CTRL_REG5, &ctrl_val, 1, 100);
ctrl_val = ctrl_val | 0x08; //set FSCALE0
uint8_t tx_buf[2];
tx_buf[0] = CTRL_REG5 & 0x7F; //register address
tx_buf[1] = ctrl_val; //data to write into it
HAL_SPI_Transmit(&hspi1, tx_buf, 1, 100);
//initial dma call
HAL_SPI_TransmitReceive_DMA(&hspi1, xyz_addr, xyz_data, 6);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
MX_USB_HOST_Process();
/* USER CODE BEGIN 3 */
//During each SPI clock cycle, full-duplex transmission of a single bit occurs.
//1 clock cycle is 168/32MHz = 5.25MHz
//meaning there are 5.25 * 10^6 bit, or 5.25 * 10^6/8 bytes = 656250 bytes
//or, all coordinates are received 109375 times.
}
/* USER CODE END 3 */
}I think that my initialization function may be not complete, but I don't know how to complete it.
2025-11-27 2:55 AM - edited 2025-11-27 3:02 AM
Welcome to the forum.
Please see How to write your question to maximize your chances to find a solution for best results.
Did you resolve your previous issue with this board? If so, please mark the solution in that thread.
@cockatoo wrote:I have checked the physical wiring, and it seems to be correct.
Please post the schematic so that others can check & confirm.
Also a good, clear photo can help.
Have you checked carefully that the connections you use are not "obstructed" by other features on the board?
Have you established that the basic SPI comms is working?
@cockatoo wrote:there is also a code for functions for reading values from accelometer, which is probably not relevant
It would be best to remove it - concentrate on just one problem at a time; minimise the number of unknowns.
PS:
Have you confirmed that the screen works on a known-good system; eg, Arduino ?
2025-11-27 5:33 AM
Code does not appear to pay attention to any error or status code returns.
Use subroutines for common repetitive code.
Verify that basic SPI comms are succeeding with the controller. That chip select and read-back are viable.
That you can dump and inspect register content in the controller.
2025-11-27 6:13 AM
And, to add to the already given useful hints, there is no way to avoid studying the screen controller datasheet.
The DS gives detailed timing information for each initialisation step, most often even including a pseudo-code init example.
Especially ramping up the LCD's internal voltage generation can take dozens or hundreds of milliseconds.
2025-11-27 7:06 AM
>I think that my initialization function may be not complete
I think same.
or
There is no TFT init at all !!!
So at first a TFT needs the init...just look at a driver on git and copy it. Then try again....with init.
2025-12-02 2:40 AM
I have done this, however, it still does not work.
void Reset_Screen() {
//reset the screen
HAL_GPIO_WritePin(RST_GPIO_PORT, RST_GPIO_PIN, GPIO_PIN_RESET); // pull low
HAL_Delay(10);
HAL_GPIO_WritePin(RST_GPIO_PORT, RST_GPIO_PIN, GPIO_PIN_SET); // release reset
HAL_Delay(120);
/* Configure LCD */
//based on https://github.com/STMicroelectronics/stm32-ili9341/blob/main/ili9341.c
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_0xCA[1] = {0xCA};
HAL_SPI_Transmit(&hspi2, cmd_0xCA, 1, 100); //ili9341_WriteReg(0xCA);
uint8_t params_0xCA[3] = {0xC3, 0x08, 0x50};
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
HAL_SPI_Transmit(&hspi2, params_0xCA, 3, 100); //ili9341_WriteData(0xC3); ili9341_WriteData(0x08); ili9341_WriteData(0x50);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_POWERB[1] = {LCD_POWERB};
HAL_SPI_Transmit(&hspi2, cmd_LCD_POWERB, 1, 100); //ili9341_WriteReg(LCD_POWERB);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_POWERB[3] = {0x00, 0xC1, 0x30};
HAL_SPI_Transmit(&hspi2, params_LCD_POWERB, 3, 100); //ili9341_WriteData(0x00); ili9341_WriteData(0xC1); ili9341_WriteData(0x30);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_POWER_SEQ[1] = {LCD_POWER_SEQ};
HAL_SPI_Transmit(&hspi2, cmd_LCD_POWER_SEQ, 1, 100); //ili9341_WriteReg(LCD_POWER_SEQ);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_POWER_SEQ[4] = {0x64, 0x03, 0x12, 0x81};
HAL_SPI_Transmit(&hspi2, params_LCD_POWER_SEQ, 4, 100); //ili9341_WriteData(0x64); ili9341_WriteData(0x03); ili9341_WriteData(0x12); ili9341_WriteData(0x81);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_DTCA[1] = {LCD_DTCA};
HAL_SPI_Transmit(&hspi2, cmd_LCD_DTCA, 1, 100); //ili9341_WriteReg(LCD_DTCA);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_DTCA[3] = {0x85, 0x00, 0x78};
HAL_SPI_Transmit(&hspi2, params_LCD_DTCA, 3, 100); //ili9341_WriteData(0x85); ili9341_WriteData(0x00); ili9341_WriteData(0x78);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_POWERA[1] = { LCD_POWERA };
HAL_SPI_Transmit(&hspi2, cmd_LCD_POWERA, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_POWERA[5] = { 0x39, 0x2C, 0x00, 0x34, 0x02 };
HAL_SPI_Transmit(&hspi2, params_LCD_POWERA, 5, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_PRC[1] = { LCD_PRC };
HAL_SPI_Transmit(&hspi2, cmd_LCD_PRC, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_PRC[1] = { 0x20 };
HAL_SPI_Transmit(&hspi2, params_LCD_PRC, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_DTCB[1] = { LCD_DTCB };
HAL_SPI_Transmit(&hspi2, cmd_LCD_DTCB, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_DTCB[2] = { 0x00, 0x00 };
HAL_SPI_Transmit(&hspi2, params_LCD_DTCB, 2, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_FRMCTR1[1] = { LCD_FRMCTR1 };
HAL_SPI_Transmit(&hspi2, cmd_LCD_FRMCTR1, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_FRMCTR1[2] = { 0x00, 0x1B };
HAL_SPI_Transmit(&hspi2, params_LCD_FRMCTR1, 2, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_DFC[1] = { LCD_DFC };
HAL_SPI_Transmit(&hspi2, cmd_LCD_DFC, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_DFC[2] = { 0x0A, 0xA2 };
HAL_SPI_Transmit(&hspi2, params_LCD_DFC, 2, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_POWER1[1] = { LCD_POWER1 };
HAL_SPI_Transmit(&hspi2, cmd_LCD_POWER1, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_POWER1[1] = { 0x10 };
HAL_SPI_Transmit(&hspi2, params_LCD_POWER1, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_POWER2[1] = { LCD_POWER2 };
HAL_SPI_Transmit(&hspi2, cmd_LCD_POWER2, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_POWER2[1] = { 0x10 };
HAL_SPI_Transmit(&hspi2, params_LCD_POWER2, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_VCOM1[1] = { LCD_VCOM1 };
HAL_SPI_Transmit(&hspi2, cmd_LCD_VCOM1, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_VCOM1[2] = { 0x45, 0x15 };
HAL_SPI_Transmit(&hspi2, params_LCD_VCOM1, 2, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_VCOM2[1] = { LCD_VCOM2 };
HAL_SPI_Transmit(&hspi2, cmd_LCD_VCOM2, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_VCOM2[1] = { 0x90 };
HAL_SPI_Transmit(&hspi2, params_LCD_VCOM2, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_MAC[1] = { LCD_MAC }; //MAYBE CHANGE PARAMETER
HAL_SPI_Transmit(&hspi2, cmd_LCD_MAC, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_MAC[1] = { 0xC8 };
HAL_SPI_Transmit(&hspi2, params_LCD_MAC, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_3GAMMA_EN[1] = { LCD_3GAMMA_EN };
HAL_SPI_Transmit(&hspi2, cmd_LCD_3GAMMA_EN, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_3GAMMA_EN[1] = { 0x00 };
HAL_SPI_Transmit(&hspi2, params_LCD_3GAMMA_EN, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_RGB_INTERFACE[1] = { LCD_RGB_INTERFACE };
HAL_SPI_Transmit(&hspi2, cmd_LCD_RGB_INTERFACE, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_RGB_INTERFACE[1] = { 0xC2 };
HAL_SPI_Transmit(&hspi2, params_LCD_RGB_INTERFACE, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_DFC2[1] = { LCD_DFC };
HAL_SPI_Transmit(&hspi2, cmd_LCD_DFC2, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_DFC2[4] = { 0x0A, 0xA7, 0x27, 0x04 };
HAL_SPI_Transmit(&hspi2, params_LCD_DFC2, 4, 100);
/*HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_COLUMN_ADDR[1] = { LCD_COLUMN_ADDR };
HAL_SPI_Transmit(&hspi2, cmd_LCD_COLUMN_ADDR, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_COLUMN_ADDR[4] = { 0x00, 0x00, 0x00, 0xEF };
HAL_SPI_Transmit(&hspi2, params_LCD_COLUMN_ADDR, 4, 100);*/
/*HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_PAGE_ADDR[1] = { LCD_PAGE_ADDR };
HAL_SPI_Transmit(&hspi2, cmd_LCD_PAGE_ADDR, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_PAGE_ADDR[4] = { 0x00, 0x00, 0x01, 0x3F };
HAL_SPI_Transmit(&hspi2, params_LCD_PAGE_ADDR, 4, 100);*/
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_INTERFACE[1] = { LCD_INTERFACE };
HAL_SPI_Transmit(&hspi2, cmd_LCD_INTERFACE, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_INTERFACE[3] = { 0x01, 0x00, 0x06 };
HAL_SPI_Transmit(&hspi2, params_LCD_INTERFACE, 3, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_GRAM[1] = { LCD_GRAM };
HAL_SPI_Transmit(&hspi2, cmd_LCD_GRAM, 1, 100);
HAL_Delay(200); // wait 200 ms before sending pixel data
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_GAMMA[1] = { LCD_GAMMA };
HAL_SPI_Transmit(&hspi2, cmd_LCD_GAMMA, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_GAMMA[1] = { 0x01 };
HAL_SPI_Transmit(&hspi2, params_LCD_GAMMA, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_PGAMMA[1] = { LCD_PGAMMA };
HAL_SPI_Transmit(&hspi2, cmd_LCD_PGAMMA, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_PGAMMA[15] = {
0x0F, 0x29, 0x24, 0x0C, 0x0E,
0x09, 0x4E, 0x78, 0x3C, 0x09,
0x13, 0x05, 0x17, 0x11, 0x00
};
HAL_SPI_Transmit(&hspi2, params_LCD_PGAMMA, 15, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_NGAMMA[1] = { LCD_NGAMMA };
HAL_SPI_Transmit(&hspi2, cmd_LCD_NGAMMA, 1, 100);
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_SET);
uint8_t params_LCD_NGAMMA[15] = {
0x00, 0x16, 0x1B, 0x04, 0x11,
0x07, 0x31, 0x33, 0x42, 0x05,
0x0C, 0x0A, 0x28, 0x2F, 0x0F
};
HAL_SPI_Transmit(&hspi2, params_LCD_NGAMMA, 15, 100);
// Sleep Out
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_SLEEP_OUT[1] = { LCD_SLEEP_OUT };
HAL_SPI_Transmit(&hspi2, cmd_LCD_SLEEP_OUT, 1, 100);
HAL_Delay(200); // wait 200 ms for the LCD to wake up
// Display On
HAL_GPIO_WritePin(DC_GPIO_PORT, DC_GPIO_PIN, GPIO_PIN_RESET);
uint8_t cmd_LCD_DISPLAY_ON[1] = { LCD_DISPLAY_ON };
HAL_SPI_Transmit(&hspi2, cmd_LCD_DISPLAY_ON, 1, 100);
}The driver is https://github.com/STMicroelectronics/stm32-ili9341/blob/main/ili9341.c.
Basic SPI communication does work, because the following snippet visibly resets the screen.
//reset the screen
HAL_GPIO_WritePin(RST_GPIO_PORT, RST_GPIO_PIN, GPIO_PIN_RESET); // pull low
HAL_Delay(10);
HAL_GPIO_WritePin(RST_GPIO_PORT, RST_GPIO_PIN, GPIO_PIN_SET); // release reset
HAL_Delay(120);
2025-12-02 2:49 AM
@cockatoo wrote:Basic SPI communication does work, because the following snippet visibly resets the screen.
But that snippet does not use SPI at all !
It's purely asserting the hardware reset line.
So that tells you absolutely nothing about the operation of the SPI !
2025-12-02 2:57 AM
I have commented out the main() code for non-screen functionality, however, it still does not work.
2025-12-02 3:01 AM - edited 2025-12-02 3:05 AM
Have you verified the basic SPI operation yet ?
Without basic SPI comms, nothing is ever going to work.
PS:
Edited as you have a write-only SPI, so can't read anything
2025-12-02 3:32 AM
How do I check if it works?