cancel
Showing results for 
Search instead for 
Did you mean: 

I2S/SPI Interrupts

cmpauley
Associate
Posted on April 12, 2012 at 22:49

Hi, I have a problem with an I2S master receive connection, using SPI2. SPI2_DR is receiving values, so the I2S is working on some level, but none of the interrupts I have set are being generated. RXNE is 1, meaning data was received, and I have the receive interrupt enabled (RXNEIE), but no interrupts are occurring. My program is just stuck in its while loop in main, but it should be stuck in SPI2_IRQHandler. Any ideas of what is up?

The OVR bit is also set to 1 (since I don't care about reading the data register because interrupts aren't even working), so I also figured I would set ERRIE to see if an error interrupt occurs, but had no luck with that either.

#i2s-spi-interrupts-interrupt-isr
2 REPLIES 2
Posted on April 13, 2012 at 01:20

Any ideas of what is up?

Coding error.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stuart239955
Associate II
Posted on April 18, 2012 at 13:49

When this sort of thing happens,

Check that the interrupt is being set-up properly.

To set up an interrupt, you need to enable the interrupt with its priority & pre-emption.

Such as:

//***************************** START ***************************

  //SPI2 Interrupt setup

  NVIC_InitStructure.NVIC_IRQChannel = SPI2_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = SPI2_IRQ_PREEMPTION;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = SPI2_IRQ_SUBPRIORITY;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

//***************************** END ***************************

When running your code, use your development tools to inspect the NVIC peripheral registers.

You're looking to see if the interrupt bits are set & enabled properly. If they're not, you won't trigger the interrupt.

Refer to the 'RM0008 STM32 Reference (Section 10.1.2 Interrupt & Exception Vector table)'  & 'ARM Cortex M3 (NVIC Programmers Model)' manuals for details on these.

If you use the ST library, that should take care of it for you. Refer to ST Library examples for more code.

Hope this helps.

Stuart