SPI with extra CE# pulse and not enough bytes
Hey,
I'm a beginner.
I'm working with STM32F303RET6 and I'm trying to communicate with SST26VF064B (Flash) over SPI.
This is how I configured my SPI (Using MXCuce):
static void MX_SPI2_Init(void)
{
/* USER CODE BEGIN SPI2_Init 0 */
/* USER CODE END SPI2_Init 0 */
/* USER CODE BEGIN SPI2_Init 1 */
/* USER CODE END SPI2_Init 1 */
/* SPI2 parameter configuration*/
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_MASTER;
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_HARD_OUTPUT;
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 7;
hspi2.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI2_Init 2 */
/* USER CODE END SPI2_Init 2 */
}I'm expecting to receive a byte of data by doing so:
static void Read_Flash(unsigned char *buffer, uint8_t add0, uint8_t add1, uint8_t add2)
{
unsigned char TX[4];
TX[0] = READ;
TX[1] = add0;
TX[2] = add1;
TX[3] = add2;
HAL_SPI_TransmitReceive_IT(&hspi2, &TX, &buffer, 5);
}I was not getting any answer from the flash so I looked at it's pins with a scope and noticed that it's not behaving as the datasheet of the Flash is expecting to.

As you can see in the picture above, once you start communicating with the flash, the CE# goes low and stays low throughout the entire communication.
Now in my case there's 2 problems:
- The CE# goes low before every byte of data and then goes up again. creating this narrow pulses before each byte.
- I can only send 2 bytes (in my case it sends TX[0] and TX[1]). for some reason it stops sending after the seconds byte.
What am I doing wrong?
Thanks in advance,
Rony.
