2016-06-05 10:04 PM
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 */
}
}
Speed 10 MHz, Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
Speed 10 MHz,Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
Speed 10 MHz,
Medium GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
Speed 10 MHz,
Medium GPIO + Pull Down enabled (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
Speed 10 MHz,
Slow GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
Speed 5 MHz,
Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
Speed 5 MHz,
Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
Speed 5 MHz,
Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS
).Speed 2,65 MHz,
Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
Speed 2,65 MHz,
Fastest GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS).
See Attachements 10178Speed 2,65 MHz,
Medium GPIO (CH1 MO, CH2 CLK, CH3 MI, CH4 CS)
See Attachements 10179Speed 2,65 MHz,
Medium
GPIO +PD (CH1 MO, CH2 CLK, CH3 MI, CH4 CS
) See Attachements 10180Speed 2,65 MHz,
Slow
GPIO +PD (CH1 MO, CH2 CLK, CH3 MI, CH4 CS
)2016-06-06 03:54 AM
You could drop the pin speed setting so you are driving it less aggresively.
2016-06-06 08:22 AM
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,2016-06-06 09:03 AM
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.