Skip to main content
jjuniman
Associate
March 10, 2011
Question

How do you properly ack peripheral IRQs in STM32L?

  • March 10, 2011
  • 2 replies
  • 541 views
Posted on March 10, 2011 at 15:55

How do you properly ack peripheral IRQs in STM32L?

    This topic has been closed for replies.

    2 replies

    jjuniman
    jjunimanAuthor
    Associate
    May 17, 2011
    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.

    ColdWeather
    Senior
    May 17, 2011
    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

    }