AnsweredAssumed Answered

stm32f103zet6 spi3 dma tx

Question asked by michael.lin on Jul 12, 2014
Latest reply on Jul 12, 2014 by Clive One
hi everyone,

how can I use the SPI3 DMA TX,the following is my configuration(it do  not work):

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);//IO时钟


     RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE);//DMA 2时钟启动
     //RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);


     /* 使能SPI3时钟 */
     RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);
     /* SPI3配置 */ 
     SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
     SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
     SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
     SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
     SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
     SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
     SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
     SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
     SPI_InitStructure.SPI_CRCPolynomial = 7;
     SPI_Init(SPI3, &SPI_InitStructure);


     SPI_I2S_DMACmd(SPI3, SPI_I2S_DMAReq_Tx, ENABLE);


     /* 使能SPI1  */
     SPI_Cmd(SPI3, ENABLE); 
DMA_DeInit(DMA2_Channel2);
     DMA_InitStructure.DMA_PeripheralBaseAddr = SPI3->DR;
     DMA_InitStructure.DMA_MemoryBaseAddr = (u32)leddis18;
     DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
     DMA_InitStructure.DMA_BufferSize = 100;
     DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
     DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
     DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
     DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
     DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
     DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
     DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
     DMA_Init(DMA2_Channel2, &DMA_InitStructure);

Outcomes