AnsweredAssumed Answered

STM32 discovery DMA with SPI

Question asked by Dhananjay on Mar 2, 2016
Latest reply on Mar 3, 2016 by Clive One
Hello everyone, I'm trying to initialize the DMA for SPI2 but DMA is not working for my code , I don't know the reason. Surely I can say that it's not working as the LED which is turned ON in ISR is not glowing. My code for DMA is shown below, please someone help me to understand why it's not working.
//DMA1_Channel5 interrupt service routine
void DMA1_Channel5_IRQHandler(void)
    GPIOE->BSRR |=1<<14;
// DMA initialization
void DMA_init(void)
    DMA_InitTypeDef  DMA_InitStructure;
    u16 some_val=COLOR_YELLOW;
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
//reset DMA1 channe5 to default values;
//channel will not be used for memory to memory transfer
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
//setting normal mode (non circular)
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
//medium priority
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;
//source and destination data size word=16bit
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
//automatic memory increment disable for both Destination and source
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
//Location assigned to peripheral register will be destination
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
//chunk of data to be transfered
DMA_InitStructure.DMA_BufferSize = 64000;
//source and destination start addresses
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&SPI2->DR;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&some_val;
//send values to DMA registers
DMA_Init(DMA1_Channel5, &DMA_InitStructure);
// Enable DMA1 Channe5 Transfer Complete interrupt
DMA_ITConfig(DMA1_Channel5, DMA_IT_TC, DISABLE);
//ENABLE DMA1 channel5
DMA_Cmd(DMA1_Channel5, ENABLE);