cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f103zet6 spi3 dma tx

linliangqiu
Associate
Posted on July 12, 2014 at 03:32

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);

#stm32-spi-dma
1 REPLY 1
Posted on July 12, 2014 at 03:55

It's an address, not the content of the register.

DMA_InitStructure.DMA_PeripheralBaseAddr = &SPI3->DR;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..