AnsweredAssumed Answered

Very simple SPI code doesn't do anything

Question asked by Neiro on Nov 13, 2013
Latest reply on Nov 15, 2013 by wanting.wang
Hello experts,

I'm trying to get SPI with DMA running on my STM32F3board. So I wrote this code after a tutorial and the StdPeriph Lib. To test the SPI parameters I wanted  to send a 16 bit value and watch on the bus with a logic analyzer without DMA or interrupt. But nothing happens exept all pins going low after init.
Here's the code:
/* Enable DMA1 clock */
     RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);
/* Enable SPI1 clock */
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1,ENABLE);
/* Enable GPIOE clock for SPI1 CS */
     RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE,ENABLE);
/* Enable GPIOA clock other SPI1 */
     RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);
       GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_5);
       GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_5);
       GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_5);
/* Chip select */
     GPIO_PinAFConfig(GPIOE, GPIO_PinSource3, GPIO_AF_5);
/* Set values for SCK and MOSI pins */
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
       GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
       GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_DOWN;
       GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
/* SCK pin configuration */
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
     GPIO_Init(GPIOA, &GPIO_InitStructure);
/* MOSI pin configuration */
       GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
       GPIO_Init(GPIOA, &GPIO_InitStructure);
/* MISO pin configuration */
       GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
       GPIO_Init(GPIOA, &GPIO_InitStructure);
/* SPI NSS pin configuration */
       GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
       GPIO_Init(GPIOE, &GPIO_InitStructure);
/* SPI configuration */
     SPI_I2S_DeInit(SPI1);
     SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
     SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b;
/* CPOL=0 */
     SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
/* CPHA=0 */
     SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
       SPI_InitStructure.SPI_NSS = SPI_NSS_Hard;
/* APB2 = 72 MHz ; 72 MHz:8 < 10 MHz */
     SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8;
/* MSB first */
     SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
       SPI_InitStructure.SPI_CRCPolynomial = 0;
/* Act as SPI master */
       SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
/* Initialize SPI communication */
       SPI_Init(SPI1, &SPI_InitStructure);
/* Enable SPI peripheral */
       SPI_Cmd(SPI1, ENABLE);
/* Enable NSS output for master mode */
       SPI_SSOutputCmd(SPI1, ENABLE);
       SPI_I2S_SendData16(SPI1,StartupBuffer[0]);

Thanks for any help!
Best regards, 
Florian

Outcomes