cancel
Showing results for 
Search instead for 
Did you mean: 

May I ask does anyone of you have sample codes for STM32F103 to dive ILI9341 OLED display by SPI and DMA?

fedora4
Associate

Many many thanks.😊

4 REPLIES 4

Probably need to find something close and port

https://github.com/afiskon/stm32-ili9341

https://vivonomicon.com/2018/06/17/drawing-to-a-small-tft-display-the-ili9341-and-stm32/

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
fedora4
Associate

Thank you Clive. I have succeed in controlling the ILI9341 in SPI but can never get the SPI to work with DMA, any idea?

> can never get the SPI to work with DMA

Show us what did you do.

DMA for Tx is as much as (assuming DMA clock is alrady enabled in RCC):

  • look up in RM the channel appropriate to your peripheral
  • prepare data in memory
  • in DMA, clear the status register bits respective to given channel, for that channel set the memory address to the buffer with data, peripheral address to SPIx_DR, NDTR to number of data, in control register select direction of transfer to M->P, set width on both sides (to byte I presume, according to how the SPI is set), and set enable
  • in SPI, enable DMA for Tx by setting SPI_CR2.TXDMAEN

JW

Jack Peacock_2
Senior III

The problem with using DMA on these low end LCD controllers is the cycle time between commands. The datasheet is vague on just what the minimal time between two commands should be. On the IL9341 it seems to imply 450us between reads, but it isn't clear if that's for GRAM only or some registers. There's a separate cycle time for ID read, so my guess is the cycle times vary considerably based on what you're doing.

Unfortunately that means you can't just send a long string of DMA commands at the fastest clock rate. Either one SPI clock cycle has to be the longest possible cycle time for the LCD controller, or you have to pause the DMA between each command, in which case there's really no benefit in using DMA.

Jack Peacock