AnsweredAssumed Answered

STM32F405/7 Flash SPI problem

Question asked by kulica on Jun 6, 2016
Latest reply on Jun 6, 2016 by Clive One
Hi there,

I have a problem when I'm sending data to and from external SPI chip (Spansion S25FL032P). The problem is I'm getting a really weird signals when I'm over 2,5 MHz speed (see the attached images). I'm not sure if this is entirely HW problem or we can enable some sort of compensation. This project uses CubeMX interface and I've tried all possible settings there, but the result is the same.

I found a call to the compensation cell (HAL_EnableCompensationCell();), but the documentation is sparse. As far as I understand this, it's only applicable with speeds exceeding 50 MHz (directly wired to the output pin). I'd be grateful of any new information regarding this problem.

SPI init code:
/* SPI1 init function */
void MX_SPI1_Init(void)
{
 
  hspi1.Instance = SPI1;
  hspi1.Init.Mode = SPI_MODE_MASTER;
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi1.Init.CRCPolynomial = 10;
  HAL_SPI_Init(&hspi1);
 
}
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{
 
  GPIO_InitTypeDef GPIO_InitStruct;
  if(hspi->Instance==SPI1)
  {
  /* USER CODE BEGIN SPI1_MspInit 0 */
    SetWgFramPower(ENABLE);
    HAL_Delay(POWER_DELAY_TIME);
  /* USER CODE END SPI1_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_SPI1_CLK_ENABLE();
   
    /**SPI1 GPIO Configuration   
    PA5     ------> SPI1_SCK
    PA6     ------> SPI1_MISO
    PA7     ------> SPI1_MOSI
    */
    GPIO_InitStruct.Pin = FRAM_SPI_SCK_Pin|FRAM_SPI_MISO_Pin|FRAM_SPI_MOSI_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
  /* USER CODE BEGIN SPI1_MspInit 1 */
 
  /* USER CODE END SPI1_MspInit 1 */
  }
}


slika1.png
Speed 10 MHz, Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

slika2.png
Speed 10 MHz, Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
slika3.png
Speed 10 MHz, Medium GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
slika4.png
Speed 10 MHz, Medium GPIO + Pull Down enabled (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
slika5.png
Speed 10 MHz, Slow GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
slika6.png
Speed 5 MHz, Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
slika7.png
Speed 5 MHz, 
Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
slika8.png
Speed 5 MHz, Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
slika9.png
Speed 2,65 MHz, Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
slika10.png
Speed 2,65 MHz, Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
slika11.png
Speed 2,65 MHz, Medium GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS) 
slika12.png
Speed 2,65 MHz, Medium GPIO +PD (CH1 MO, CH2 CLK, CH3 MI, CH4 CS
slika13.png
Speed 2,65 MHz, Slow GPIO +PD (CH1 MO, CH2 CLK, CH3 MI, CH4 CS

Outcomes