cancel
Showing results for 
Search instead for 
Did you mean: 

stm32F2 Max Speed Master SPI

pedro23
Senior
Posted on February 28, 2015 at 10:47

Hi. I'm trying to set the spi at max speed (in theory 30mbit/s spi in stm32F2), but I just get 15mbits on SPI output.

This is my spi initialization (for SPI3). 

I'm using DMA to transfer a buffer, but in theory that is independent of SPI speed.

Where is my problem?

//SPI3 initialization

static void SPI_Config(void)

{

  GPIO_InitTypeDef GPIO_InitStructure;

  NVIC_InitTypeDef NVIC_InitStructure;

  SPI_InitTypeDef  SPI_InitStructure;

  /* Peripheral Clock Enable -------------------------------------------------*/

  /* Enable the SPI clock */

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);

  

  /* Enable GPIO clocks */

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);

  /* SPI GPIO Configuration --------------------------------------------------*/

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SPI3);

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SPI3);

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_DOWN;

  /*!< SPI SCK pin configuration */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;

  GPIO_Init(GPIOC, &GPIO_InitStructure);

 

  /*!< SPI MOSI pin configuration */

  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_10;

  GPIO_Init(GPIOC, &GPIO_InitStructure);

 

 

  /* SPI configuration -------------------------------------------------------*/

  SPI_I2S_DeInit(SPI3);

  SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Tx;

  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;

  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;

  SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;

  SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;

  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_Cmd(SPI3, ENABLE);

}

#spi3 #dma #spi
1 REPLY 1
pedro23
Senior
Posted on February 28, 2015 at 10:49

Ok forget it :p 

''SPI1 can communicate at up to 30 Mbits/s, while SPI2 and SPI3 can communicate at up to 15 Mbit/s.''