cancel
Showing results for 
Search instead for 
Did you mean: 

DMA on SPI not sure if working !

monta
Associate II
Posted on July 21, 2015 at 21:24

Hi , I'm driving a 1.4'' TFT LCD on STM32F4 Disco , via SPI3 . I wanted to increase the speed of writing to the LCD so I decided to use DMA. The code compiles and work nicely but still too slow and no difference can be seen.

I'm suspecting something wrong with my code.

All I added was:

char Buffer[16384];  // 128 * 128 pixels

 

 

void initDMA() {

 

dma_is.DMA_Channel = DMA_Channel_0;

 

dma_is.DMA_Memory0BaseAddr = (uint32_t) Buffer;

 

dma_is.DMA_PeripheralBaseAddr = (uint32_t) &SPI3->DR;

 

dma_is.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;

 

dma_is.DMA_PeripheralDataSize = DMA_MemoryDataSize_Byte;

 

dma_is.DMA_DIR = DMA_DIR_MemoryToPeripheral;

 

dma_is.DMA_Mode = DMA_Mode_Normal;

 

dma_is.DMA_MemoryInc = DMA_MemoryInc_Enable;

 

dma_is.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

 

dma_is.DMA_BufferSize = (uint16_t)sizeof(Buffer);

 

dma_is.DMA_Priority = DMA_Priority_High;

 

dma_is.DMA_MemoryBurst = DMA_MemoryBurst_Single;

 

dma_is.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;

 

dma_is.DMA_FIFOMode = DMA_FIFOMode_Disable;

 

 

 

DMA_Init(DMA1_Stream5, &dma_is);

 

}

I did not change much to my code after that. 

I use something like this to transfer data:

void writeData(uint16_t data){

 

GPIO_SetBits(GPIOB, AOPin); // Set A0 D/C pin LOW for data select.

 

SPI_I2S_SendData(SPI3, data);

 

while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_BSY) == SET);

 

}

 

void writeData16(uint16_t data){

 

GPIO_SetBits(GPIOB, AOPin); // Set A0 D/C pin LOW for data select.

 

SPI_I2S_SendData(SPI3, data>>8);

 

while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_BSY) == SET);

 

SPI_I2S_SendData(SPI3, data);

 

while(SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_BSY) == SET);

 

}

 

Is everything ok ?? Or I am doing something wrong ?? 

Thank you.
1 REPLY 1
jpeacock
Associate III
Posted on July 21, 2015 at 22:37

The SPI port is the limit on how fast you send data to the LCD controller, not DMA.  Using DMA instead of polled TX to SPI port won't make the SPI port run any faster. 

You'll have to speed up the SPI port frequency, but be sure to check both access and cycle times on the LCD controller first.  A lot of these SPI type controllers (Ilitek, Solomon etc) have different cycle times for commands and data, so your SPI port has to run at the slowest cycle time.

  Jack Peacock