cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F405/7 Flash SPI problem

matej2
Associate II
Posted on June 06, 2016 at 07:04

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 */
}
}

0690X00000605OlQAI.png

Speed 10 MHz,

Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

0690X00000605OqQAI.png

Speed 10 MHz,

Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

0690X00000605P0QAI.png

Speed 10 MHz,

Medium GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

0690X00000605MHQAY.png

Speed 10 MHz,

Medium GPIO + Pull Down enabled (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

0690X00000605PFQAY.png

Speed 10 MHz,

Slow GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

0690X00000605PAQAY.png

Speed 5 MHz,

Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

0690X00000605PKQAY.png

Speed 5 MHz,

Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

0690X00000605MWQAY.png

Speed 5 MHz,

Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS

).

0690X00000605PPQAY.png

Speed 2,65 MHz,

Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

0690X00000605GyQAI.png

Speed 2,65 MHz,

Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).

See Attachements 10178

Speed 2,65 MHz,

Medium GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS)

See Attachements 10179

Speed 2,65 MHz,

Medium

GPIO +PD (CH1 MO, CH2 CLK, CH3 MI, CH4 CS

)

See Attachements 10180

Speed 2,65 MHz,

Slow

GPIO +PD (CH1 MO, CH2 CLK, CH3 MI, CH4 CS

)

3 REPLIES 3
Posted on June 06, 2016 at 12:54

You could drop the pin speed setting so you are driving it less aggresively.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
matej2
Associate II
Posted on June 06, 2016 at 17:22

Hi,

Tests were performed with Slow pin speed. There's a little less overshoot on positive pulse front, but still, the signal is bad. Currently the code section includes very high speed. I give you that.

Regards,

Posted on June 06, 2016 at 18:03

Ok, but what is the weird problem you are complaining about?

That the FLASH SPI device isn't driving the MISO pin? Perhaps a Logic Analyzer, and a perspective on the failing condition, as seen by the code, might shed some more light on what the problem is.

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