AnsweredAssumed Answered

DMA on SPI not sure if working !

Question asked by ghanmy.montassar on Jul 21, 2015
Latest reply on Jul 21, 2015 by peacock.jack.003
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.

Outcomes