Problem using MemToMem DMA from SRAM to FMC on STM32H755
I am using FMC LCD interface to power my TFT LCD controlled by SSD1963. FMC data width is 16-bit, and below is a workable code using pixel-by-pixel transmission.
void lcd_fill_pixels(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey,
uint16_t *pixels)
{
uint16_t xlen = ex - sx + 1;
Set_Column(sx, ex);
Set_Page(sy, ey);
SSD1963__write_memory_start();
for (int i = sy; i <= ey; i++) {
for (int j = sx; j <= ex; j++) {
TFT_RAM = *pixels;
pixels++;
}
}
}I want to convert the code in the lines 8-13 into DMA. I first tried to use MDMA since the core running on is Cortex-M7. I also tried DMA MemToMem. below is my MDMA and DMA configuration.
I checked from the build analyzer that the buffer is placed in the .bss region of RAM_D1. Also, I disable both D-Cache and I-Cache for testing. However, I still cannot see my LCD filling with pixels.
Could someone familiar with DMA on STM32H7 devices help me with it? Really appreciate it! Below is my attempt using HAL.
void lcd_fill_pixels_dma(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey,
uint16_t *pixels)
{
uint16_t xlen = ex - sx + 1;
uint16_t ylen = ey - sy + 1;
Set_Column(sx, ex);
Set_Page(sy, ey);
SSD1963__write_memory_start();
extern DMA_HandleTypeDef hdma_memtomem_dma1_stream7;
SCB_CleanInvalidateDCache();
HAL_DMA_Start(&hdma_memtomem_dma1_stream7, (uintptr_t)pixels,
(uintptr_t)&TFT_RAM, xlen * ylen * 2);
HAL_DMA_PollForTransfer(&hdma_memtomem_dma1_stream7, HAL_DMA_FULL_TRANSFER,
100);
}
void lcd_fill_pixels_mdma(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey,
uint16_t *pixels)
{
uint16_t xlen = ex - sx + 1;
uint16_t ylen = ey - sy + 1;
Set_Column(sx, ex);
Set_Page(sy, ey);
SSD1963__write_memory_start();
extern MDMA_HandleTypeDef hmdma_mdma_channel41_sw_0;
SCB_CleanInvalidateDCache();
HAL_MDMA_Start(&hmdma_mdma_channel41_sw_0, (uintptr_t)pixels,
(uintptr_t)&TFT_RAM, xlen * ylen * 2, 1);
HAL_MDMA_PollForTransfer(&hmdma_mdma_channel41_sw_0, HAL_MDMA_FULL_TRANSFER,
100);
}
