cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743 getting SPI interrupt when no SPI interrupts are enabled.

rammit
Senior

My STM32H743 SPI interrupt handler is being repeatedly called even though the interrupt enable register (IER) is 0. I'm running in slave mode and probably doing something really wrong for this to happen.

Here are the register values:

Name   Value   Access   

CR1   0x00000001   ReadWrite   

    IOLOCK   0   ReadWrite   

    TCRCI   0   ReadWrite   

    RCRCI   0   ReadWrite   

    CRC33_17   0   ReadWrite   

    SSI   0   ReadWrite   

    HDDIR   0   ReadWrite   

    CSUSP   0   ReadWrite   

    CSTART   0   ReadWrite   

    MASRX   0   ReadWrite   

    SPE   1   ReadWrite   

CR2   0x00000003   ReadWrite   

    TSER   0x0000   ReadWrite   

    TSIZE   0x0003   ReadWrite   

CFG1   0x2000040F   ReadWrite   

CFG2   0x05000000   ReadWrite   

IER   0x00000000   ReadWrite   

    TSERFIE   0   ReadWrite   

    MODFIE   0   ReadWrite   

    TIFREIE   0   ReadWrite   

    CRCEIE   0   ReadWrite   

    OVRIE   0   ReadWrite   

    UDRIE   0   ReadWrite   

    TXTFIE   0   ReadWrite   

    EOTIE   0   ReadWrite   

    DPXPIE   0   ReadWrite   

    TXPIE   0   ReadWrite   

    RXPIE   0   ReadWrite   

SR   0xFFF80002   ReadOnly   

    CTSIZE   0xFFF8   ReadOnly   

    RXWNE   0   ReadOnly   

    RXPLVL   0x0   ReadOnly   

    TXC   0   ReadOnly   

    SUSP   0   ReadOnly   

    TSERF   0   ReadOnly   

    MODF   0   ReadOnly   

    TIFRE   0   ReadOnly   

    CRCE   0   ReadOnly   

    OVR   0   ReadOnly   

    UDR   0   ReadOnly   

    TXTF   0   ReadOnly   

    EOT   0   ReadOnly   

    DXP   0   ReadOnly   

    TXP   1   ReadOnly   

    RXP   0   ReadOnly   

16 REPLIES 16
TDK
Guru

Is your NVIC SPI interrupt enabled? Look at VECTACTIVE to see which interrupt is really active. Might be a vector table issue.

If you feel a post has answered your question, please click "Accept as Solution".

> SPI interrupt handler is being repeatedly called

How do you know?

Which interrupt handler? What's its name?

Do you use Cube/HAL?

JW

berendi
Principal

Check the interrupt vectors.

Find the interrupt address offset in the Interrupt and exception vectors section of the reference manual.

Read the value at the address offset counted from the beginning of the flash, i.e. the address offset of the SPI4 interrupt is 0x190, then examine the value at 0x08000190. This is the address of the interrupt handler function.

Now find the address (minus 1) in the .map file. Is it your interrupt handler or something else?

rammit
Senior

Thaks for all your answers.

I'm partially using HAL.

Vector table looks correct and VTOR is correct.

I'm running from flash and it works up until a point.

I'm working on what point that is, but is it possible to get a SPI interrupt if IER is 0? I assume by all your responses that the answer is no.

Generally no, but it depends on what exactly do you mean by "SPI interrupt".

Answer the questions we've given.

JW

rammit
Senior

Interrupt handler is SPI4_IRQHandler.

Constantly hitting breakpoint in the handler.

What is VECTACTIVE?

Did I miss any questions?

rammit
Senior

Found VECTACTIVE.

Name   Value   Access   

CPUID   0x411FC271      

ICSR   0x04C46864      

    NMIPENDSET   0      

    PENDSVSET   0      

    PENDSVCLR   0      

    PENDSTSET   1      

    PENDSTCLR   0      

    ISRPENDING   1      

    VECTPENDING   0x46

    RETTOBASE   1      

    VECTACTIVE   0x64      

VTOR   0x08040000      

AIRCR   0xFA050300      

SCR   0x00000000      

CCR   0x00040200      

SHPR1   0x00000000      

SHPR2   0x00000000      

SHPR3   0xF0F00000      

SHCRS   0x00000000      

CFSR_UFSR_BFSR_MMFSR   0x00000000   

HFSR   0x00000000      

MMFAR   0x00000000      

BFAR   0x00000000      

rammit
Senior

In my EXTI interrupt handler for handling chip select transitions I enable the TXP interrupt on CS low. If I skip or remove that the problem goes away.

I need to send a status word as the first word. Since it can be changed by another task I need to place it in the FIFO on CS low.

void EXTI4_IRQHandler(void)

{

 __HAL_GPIO_EXTI_CLEAR_IT(HostSPISelect_Pin);

 GPIO_PinState state = HAL_GPIO_ReadPin(HostSPISelect_GPIO_Port, HostSPISelect_Pin);

 if (state == GPIO_PIN_RESET) // CS active

 {

   __HAL_SPI_CLEAR_TXTFFLAG(hspi);

   (*(__IO SPIDataType *)&hspi->Instance->TXDR) = StatusHeader;

   __HAL_SPI_CLEAR_UDRFLAG(hspi);

     hspi->pTxBuffPtr = (uint8_t *)aTxBuffer;

     hspi->TxXferCount = hspi->TxXferSize;

     __HAL_SPI_ENABLE_IT(hspi, SPI_IT_TXP);

     __HAL_SPI_DISABLE_IT(hspi, SPI_IT_RXP);

...

So, you enable an SPI interrupt and the SPI interrupts? Where's the problem then?

JW