cancel
Showing results for 
Search instead for 
Did you mean: 

SPI does not working as expected

AA.10
Associate III

Hi,

i am working with STM32U575x, I am trying to implement SPI transmission (using the blocking function - HAL_SPI_Transmit.

The problem is that sometimes the function is stuck while waiting for EOT event.

someone here, in this fourm suggested to reduce the frame size (less then 1024)

my frame size is 13 bytes, but, still it happens after few frames transmissions.

did someone faced this kind of problem?

here is my SPI configuration:

/* USER CODE END SPI2_Init 1 */

  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_2EDGE;

hspi2.Init.NSS = SPI_NSS_SOFT;

hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;

hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;

hspi2.Init.TIMode = SPI_TIMODE_DISABLE;

hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

hspi2.Init.CRCPolynomial = 0x7;

hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;

hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;

hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;

hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;

hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;

hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;

hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;

hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE;

hspi2.Init.ReadyMasterManagement = SPI_RDY_MASTER_MANAGEMENT_INTERNALLY;

hspi2.Init.ReadyPolarity = SPI_RDY_POLARITY_HIGH;

 if (HAL_SPI_Init(&hspi2) != HAL_OK)

 {

  Error_Handler();

 }

 HAL_SPI_AutonomousMode_Cfg_Struct.TriggerState = SPI_AUTO_MODE_DISABLE;

 HAL_SPI_AutonomousMode_Cfg_Struct.TriggerSelection = SPI_GRP1_GPDMA_CH0_TCF_TRG;

 HAL_SPI_AutonomousMode_Cfg_Struct.TriggerPolarity = SPI_TRIG_POLARITY_RISING;

 if (HAL_SPIEx_SetConfigAutonomousMode(&hspi2, &HAL_SPI_AutonomousMode_Cfg_Struct) != HAL_OK)

 {

  Error_Handler();

 }

 /* USER CODE BEGIN SPI2_Init 2 */

thanks, Avi

1 REPLY 1

>>The problem is that sometimes the function is stuck while waiting for EOT event.

Are you inspecting the registers in the Debugger?

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