Using DMA transmission, the screen display is abnormal, the fixed position display above and below the screen is abnormal, but it is normal in the middle of the screen
H743 Mini customized version, only MCU STM32CUBEIDE
Screen is ILI9341 2.4 inch 320*240 Half duplex SPI without miso
Lvgl master,LVGL V8.1
Code to reproduce
void ILI9341_WriteData(uint8_t* buff, size_t buff_size)
{
HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin, GPIO_PIN_SET);
uint16_t chunk_size;
// split data in small chunks because HAL can't send more then 64K at once
while (buff_size > 0)
{
chunk_size = buff_size > 32768 ? 32768 : buff_size;
HAL_SPI_Transmit(HSPI_INSTANCE, buff, chunk_size, HAL_MAX_DELAY);
buff += chunk_size;
buff_size -= chunk_size;
}
HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_SET);
}
void ILI9341_WriteData_DMA(uint8_t* buff, size_t buff_size)
{
HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin, GPIO_PIN_SET);
uint16_t chunk_size;
// split data in small chunks because HAL can't send more then 64K at once
while (buff_size > 0)
{
chunk_size = buff_size > 32768 ? 32768 : buff_size;
while(HAL_SPI_Transmit_DMA(HSPI_INSTANCE, buff, chunk_size) == HAL_OK){}
while (HAL_DMA_GetState(hspi2.hdmatx) == HAL_DMA_STATE_BUSY){}
SCB_CleanDCache();
SCB_CleanInvalidateDCache();
buff += chunk_size;
buff_size -= chunk_size;
}
while (HAL_DMA_GetState(hspi2.hdmatx) == HAL_DMA_STATE_BUSY){}
HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_SET);
}
//lvgl disp port
/* Example for 3) also set disp_drv.full_refresh = 1 below*/
static lv_disp_draw_buf_t draw_buf_dsc_3;
static lv_color_t buf_3_1[MY_DISP_HOR_RES * MY_DISP_VER_RES];
static lv_color_t buf_3_2[MY_DISP_HOR_RES * MY_DISP_VER_RES];
lv_disp_draw_buf_init(&draw_buf_dsc_3, buf_3_1, buf_3_2, MY_DISP_VER_RES * MY_DISP_VER_RES);
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
int32_t act_x1 = area->x1;
int32_t act_y1 = area->y1;
int32_t act_x2 = area->x2;
int32_t act_y2 = area->y2;
ILI9341_Set_Address(act_x1,act_y1,act_x2,act_y2);
ILI9341_WriteData((uint8_t*)color_p, sizeof(uint16_t)*((act_x2 - act_x1 + 1) * (act_y2 - act_y1 + 1)));
lv_disp_flush_ready(disp_drv);
}