AnsweredAssumed Answered

Spi dma

Question asked by kaka on Dec 18, 2015
Latest reply on Dec 18, 2015 by kaka
Hi 

i am using stm32f4 discvery. i have configured spi for display nd it works perfectly.
Then i have included the DMA, but its not working when i am checking the flag.
/* checking the below flag */

while (DMA_GetFlagStatus(DMA2_Stream5, DMA_FLAG_TCIF5)==RESET);

kindly help. 

The configuration is below,(spi works perfectly without dma).


void spi_dmanvic_config()
{
          //clock for the dma ------ dma2
           RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2,  ENABLE);


            //DMA configuration for spi
           DMA_InitTypeDef DMA_InitStructure;
           DMA_InitStructure.DMA_BufferSize = tx_BufferSize;       //buffer size
           DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable ;
           DMA_InitStructure.DMA_FIFOThreshold =  DMA_FIFOThreshold_1QuarterFull;
           DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single ;
           DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
           DMA_InitStructure.DMA_MemoryInc =  DMA_MemoryInc_Enable;
           DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
           DMA_InitStructure.DMA_PeripheralBaseAddr =(uint32_t)(&SPI6->DR);
           DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
           DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
           DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
           DMA_InitStructure.DMA_Priority = DMA_Priority_Low;




                 /* Configure TX DMA */
           DMA_InitStructure.DMA_Channel = DMA_Channel_1 ;
           DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral ;
           DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)(&spi_TxBuffer) ;
           DMA_Init(DMA2_Stream5, &DMA_InitStructure);


           DMA_ITConfig(DMA2_Stream5, DMA_IT_TC , ENABLE);


            //enable the dma
           DMA_Cmd(DMA2_Stream5,  ENABLE);


            //spi request for transmission
           SPI_I2S_DMACmd(SPI6, SPI_I2S_DMAReq_Tx, ENABLE);


          /*** interrupt *****/
          NVIC_InitTypeDef NVIC_InitStruct;
          NVIC_InitStruct.NVIC_IRQChannel =DMA2_Stream5_IRQn ;
          NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
          NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = DISPLAY_PRIORITY ;
        NVIC_InitStruct.NVIC_IRQChannelSubPriority = DISPLAY_SUBPRIORITY ;
          NVIC_Init(&NVIC_InitStruct);
}

Outcomes