I have an SPI LCD and a routine that fills a quadrilateral by filling it as two triangles. This worked correctly using spi_write_blocking. However, after switching to DMA with dma_spi_write, a small gap appears between the two triangles.
I made the switch by replacing the spi_write_blocking call with dma_spi_write (see code below). During debugging, I found that adding a sleep_us(2) at the end of the function eliminates the gap as using sleep_us(1) was not enough.
So
A. Am I doing the DMA correctly?
B. Is the wait a normal thing as the ST7789 does not have a busy flag that can be polled?
C. Is dma_channel_wait_for_finish_blocking returning too soon?
Thanks
I made the switch by replacing the spi_write_blocking call with dma_spi_write (see code below). During debugging, I found that adding a sleep_us(2) at the end of the function eliminates the gap as using sleep_us(1) was not enough.
So
A. Am I doing the DMA correctly?
B. Is the wait a normal thing as the ST7789 does not have a busy flag that can be polled?
C. Is dma_channel_wait_for_finish_blocking returning too soon?
Thanks
Code:
static int dma_chan;dma_chan=dma_claim_unused_channel(true);static void dma_spi_write(const uint8_t *buf, size_t len) {dma_channel_config cfg; cfg = dma_channel_get_default_config(dma_chan); channel_config_set_read_increment(&cfg, true); channel_config_set_write_increment(&cfg, false); channel_config_set_dreq(&cfg, spi_get_dreq(SPI_PORT, true)); channel_config_set_transfer_data_size(&cfg, DMA_SIZE_8); dma_channel_configure(dma_chan, &cfg, &spi_get_hw(SPI_PORT)->dr, buf, len, true); dma_channel_wait_for_finish_blocking(dma_chan); sleep_us(2);}Statistics: Posted by ygator — Tue Sep 30, 2025 9:43 pm