cancel
Showing results for 
Search instead for 
Did you mean: 

Simple SPI Interrupt mode not working for STM32H745 boards

HPate.10
Associate III

Hello Support Team,

I have configured SPI2 (for STM32H745 board)from STM32Cube configuration and enable global interrupt.

I have used simple HAL_SPI_TransmitReceive_IT() API for transmit as well as receive the data.

But In IRQ handler no any interrupt generated for SPI transmit call.

Normal Polling mode is working fine for me.But issue faced in interrupt mode.

Could you give the any example link which is working fine for STM32H745 Discovery board.

Below I have attached my code please look into these.If found any issue or miss configuration suggest that configuration for proper work.

SPI Handle Configuration which is configured in STM32H745.

#ifdef MASTER_BOARD

 hspi2.Init.Mode = SPI_MODE_MASTER;

#else

 hspi2.Init.Mode = SPI_MODE_SLAVE;

 HAL_Delay(10);

#endif

 /* 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_SOFT;

 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 = 0x0;

 hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;

 hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;

 hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;

 hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;

 hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;

 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;

Thank you In Advance

7 REPLIES 7
Mike_ST
ST Employee

Hello,

What makes you think that the ISR is not called ?

I have tested your code on nucleo H743ZI2, and the following function

void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)

{

 wTransferState = TRANSFER_COMPLETE;

}

is called after transmission.

HPate.10
Associate III

Hello Mike

Thank you for your quick reply.

I want to ask you about which step followed by you.

1.) Have you changed any line(shared code by me) or code configuration for your STM32HNucleo board.

2.) Could you run this same code on STM32H745 discovery board?

  • It is very helpful for me.
  • Also give the data about which extra configuration required for STM32H745 board.

3.) My Final goal is achieve the SPI + DMA communication on STM32H745 discovery board.

If you found any SPI + DMA communication working example for my STM32H745 It will be grateful for me.

Thank you once again.

Mike_ST
ST Employee

>> 1.) Have you changed any line(shared code by me) or code configuration for your STM32HNucleo board.

Just commented the following, because H743 is single core:

/* wait until CPU2 wakes up from stop mode */

while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET) && (timeout-- > 0));

if ( timeout < 0 )

{

//Error_Handler();

}

>> 2.) Could you run this same code on STM32H745 discovery board?

Sorry I don't have that one here.

>> 3.) My Final goal is achieve the SPI + DMA communication on STM32H745 discovery board.

If you found any SPI + DMA communication working example for my STM32H745 It will be grateful for me.

You have examples in the STM32H7 software package:

STM32Cube_FW_H7_V1.10.0\Projects\NUCLEO-H745ZI-Q\Examples\SPI

By the way, you forgot to answer my question.

MM..1
Chief III

Try test exmples from FW package and your code :

#ifdef MASTER_BOARD
 hspi2.Init.Mode = SPI_MODE_MASTER;
#else
 hspi2.Init.Mode = SPI_MODE_SLAVE;
 HAL_Delay(10);
#endif
 /* USER CODE END SPI2_Init 1 */
 /* SPI2 parameter configuration*/
 hspi2.Instance = SPI2;
 hspi2.Init.Mode = SPI_MODE_MASTER;
 hspi2.Init.Direction = SPI_DIRECTION_2LINES;

never configure SLAVE ...

HPate.10
Associate III

Hello Mike,

Apologize for forgot to answer your question.

>>What makes you think that the ISR is not called ?

  • I have debug the code step by step and calling the HAL_SPI_TransmitReceive_IT() after transfer completion in Tx FIFO. I am waiting at SPI2_IRQHandler() (putted breakpoint in this IRQ) but no any control appear in this code.
  • According this step I have concluded ISR is not called.

I need little favor from you Could you take one STM32H745 board from your colleague and check this below code or send it to them if they can run easily it would be very appreciate.

Mike_ST
ST Employee

Please try:

 hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;

Got the same issue with a STM32H743

It seems that 100MHz clock was too high.

Using "hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;" (50MHz Clock on SPI2) solved it and my interruption triggered.