STM32F091RCT6 SPI Peripheral weird behavior with 8 bits data mode
Hello,
I have a
weird
behavior with STM32F091RCT6 SPI Peripheral on Nucleo Evaluation Board.I want to interface with a 25LC640 SPI eeprom with 8 bits data mode
When i want to send a byte, i see On Oscilloscope 16 clocks pulse instead of 8 !!
I have tested several setting, i have the good number of pulses for 9 bits data size and more .
Context :
STM32F091RCT6
HAL library 1.6
Keil IDE & compiler : 5.06
SPI2 Peripheral on Port B Pin 13,14,15 Master Mode without NSS pin
SPI setup like this :
void MX_SPI2_Init(void)
{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_HIGH; hspi2.Init.CLKPhase = SPI_PHASE_1EDGE; hspi2.Init.NSS = SPI_NSS_SOFT; hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4; hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi2.Init.TIMode = SPI_TIMODE_DISABLE; hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi2.Init.CRCPolynomial = 8; hspi2.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; if (HAL_SPI_Init(&hspi2) != HAL_OK) { Error_Handler(); }}
__HAL_RCC_SPI2_CLK_ENABLE();
__HAL_SPI_ENABLE(spiHandle); /**SPI2 GPIO Configuration PB13 ------> SPI2_SCK PB14 ------> SPI2_MISO PB15 ------> SPI2_MOSI */ GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Alternate = GPIO_AF0_SPI2; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);Sending function :
static uint8_t eep_SpiSendByte (uint8_t data)
{while (( EE_SPI->SR & SPI_SR_TXE_Msk) == RESET); // Wait for empty transmit buffer
EE_SPI->DR = data;while (( EE_SPI->SR & SPI_SR_RXNE_Msk) == RESET); // Wait for received buffer with new data
return (uint8_t)EE_SPI->DR;}
Thanks
#stm32f091-spi-spi_datasize_8bit #hal-v1.6