2022-06-28 05:46 AM
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
2022-06-28 07:03 AM
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.
2022-06-28 07:19 AM
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?
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.
2022-06-28 07:29 AM
>> 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.
2022-06-28 07:41 AM
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 ...
2022-06-28 07:55 AM
Hello Mike,
Apologize for forgot to answer your question.
>>What makes you think that the 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.
2022-06-28 10:08 AM
Please try:
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
2024-11-12 02:54 AM
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.