cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 SPI IRQn never triggered

Gabriel T
Senior

Hi,

I am using SPI1 and interrupt are enabled in this function

void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{
  ........................
 
    /* SPI1 interrupt Init */
    HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(SPI1_IRQn);
  /* USER CODE BEGIN SPI1_MspInit 1 */
 
  /* USER CODE END SPI1_MspInit 1 */
  }

Spi works fine in blocking mode, I want to switch to DMA mode but I never enter this function :

void SPI1_IRQHandler(void)
{
  /* USER CODE BEGIN SPI1_IRQn 0 */
 
  /* USER CODE END SPI1_IRQn 0 */
  HAL_SPI_IRQHandler(&hspi1);
  /* USER CODE BEGIN SPI1_IRQn 1 */
 
  /* USER CODE END SPI1_IRQn 1 */
}

Any ideas why my interrupts are never triggered ?

Gabriel

5 REPLIES 5

Hello.

Is not enough to enable SPI global interrupt.

Need to enable also a particular bit of SPI like TXEIE for empty TX buffer , RXNEIE for incomming data, etc.

__HAL_SPI_ENABLE_IT(&hspi1, SPI_IT_RXNE) ;

Gabriel T
Senior

Thanks, I added

static void mySPI1_Init(void)
{
  ...............
  HAL_SPI_Init(&hspi1);
  __HAL_SPI_ENABLE_IT(&hspi1, SPI_IT_EOT) ;
}

But I still never go into SPI1_IRQHandler() :sad_but_relieved_face:

I want to use :

void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)

Hello🙂

End of Transmision interrupt implies that a byte is clocked out before, SPI is enabled and configured properly.

To have HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi) called , HAL_SPI_Receive_DMA(..) or HAL_SPI_Receive_IT(..) must called first.

There are some working examples for SPI inside repository. C:\Users\you\STM32Cube\Repository

This document contains HAL SPI explanations for every function , structures and how to use it.

Gabriel T
Senior

My transfert gets triggered here, I checked with debugger and I get into this function (ads_buf is located in D2 RAM with MPU region in WT)

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
	if((GPIO_Pin == DRDY_ADC_Pin)&&(data_flag))
	{
		ADS1x9x_csn_0_en();
		//HAL_SPI_Receive(&hspi1, ads_buf, READBACK_LENGTH,500);
		HAL_SPI_Receive_DMA(&hspi1, ads_buf, READBACK_LENGTH);
	}
}

But I dont go into this one

void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)
{

My spi1 handler says :

RxXferSize = 27 and RxXferCount = 27 so the Rx is completed

pRxBuffPtr is 0x30000000 so right in my D2 RAM buffer

state is HAL_SPI_STATE_BUSY_RX

My DMA state is HAL_DMA_STATE_BUSY

My buffer doesn't get written, any ideas why it can't ?

Gabriel T
Senior

I have the same problem when using IT function, I receive the message but never trigger any interrupt