cancel
Showing results for 
Search instead for 
Did you mean: 

How do you properly ack peripheral IRQs in STM32L?

jjuniman
Associate
Posted on March 10, 2011 at 15:55

How do you properly ack peripheral IRQs in STM32L?

2 REPLIES 2
ColdWeather
Senior
Posted on May 17, 2011 at 14:27

In general you should clear in the PERIPHERAL the bit that caused the interrupt or disable the interrupt.

  NVIC_ClearPendingIRQ(SPI2_IRQn); // not really neccessary.

  NVIC_EnableIRQ(SPI2_IRQn);

  pSpiBus->CR2 |= SPI_CR2_TXEIE;

However as soon as I enable the interrupt, I hit the ISR over & over because I'm not acking the interrupt correctly. My ISR looks like this:

void SPI2_IRQHandler(void)

{

    // contunue transmission:

   pSpiBus-> DR = ....;

    // or

      pSpiBus->CR2 &= ~SPI_CR2_TXEIE; // disable interrupt

}

jjuniman
Associate
Posted on May 17, 2011 at 14:27

Wait a minute, I'm an idiot. The SPI_CR2_TXEIE generates an interrupt whenever the TX buffer is empty, not when it's done transmitting. That's why I'm hitting it over & over. duh.