AnsweredAssumed Answered

F4 Discovery Max SPI Speed

Question asked by valdez.jess on Aug 11, 2012
Latest reply on Aug 13, 2012 by valdez.jess
Hello,
1. What is the maximum SPI speed I am suppose to achieve with the 8MHz HSE?
2. I would like to achieve at least 25MHz, what would it take to achieve that both code and HW? Currently with my code below I get 13MHz.

void configure_spi_r(void)
{
  //Init GPIO structure 
  GPIO_InitTypeDef GPIO_InitStructure;
  //Init SPI structure 
  SPI_InitTypeDef SPI_InitStructure; 
  
   //Enable SPI clocks  
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1,ENABLE); 
  
  /* Enable GPIO clocks */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
  
  //Set GPIOs 
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; 
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; 
  GPIO_Init(GPIOA, &GPIO_InitStructure); 


  /* Connect SPI pins to AF5 */  
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_SPI1); //CLK
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_SPI1); //MOSI


  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_1Edge; 
  SPI_InitStructure.SPI_NSS = SPI_NSS_Hard; 
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; 
  SPI_InitStructure.SPI_CRCPolynomial = 7; 
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2; 
  
  //SPI1- for CLK, DATA, CS(DIR) 
  SPI_Init(SPI1,&SPI_InitStructure); 
  SPI_SSOutputCmd(SPI1,ENABLE); 
  SPI_Cmd(SPI1,ENABLE); 
}

Outcomes