This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NVIC_EnableIRQ : enables only one interrupt at a time?

Looking at the one of the implementations of NVIC_EnableIRQ, Im wondering how the ISER works

static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
{
  NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
}

Calling the above two consequitve times with a different IRQn, will erase the enable of the previous interrupt. Does it mean I can enable one interrupt at a time?

NVIC_EnableIRQ(8);   // enables IRQ8

NVIC_EnableIRQ(7);   // enables IRQ7 but disables IRQ8 ?!?

Correct, or do I miss something?

Further, can I set an IER of a peripheral device without enabling its interrupt ?!?

Thanks in advance !

Parents
  • 1) No, ICER not at all. Only about the relationship between the ISER and the IER.

    2) You are saying: It is need to both Enable NVIC->ISER and UART->IER simultaneously ?

    The source of confusion is the source code of enabling the NVIC IRQ

    static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
    {
      NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
    }

    If I want to enable multiple IRQs over UART->IER simultaneously, I have to do the following ?

    NVIC_EnableIRQ(UART3_IRQn);
    
    PC_UART3->IER = ...
    
    NVIC_EnableIRQ(UART2_IRQn);    // this disables UART3 already
    
    PC_UART2->IER = ...

    So, what happens with the NVIC UART3_IRQn respectively with the PC_UART3->IER, if the NVIC_EnableIRQ(UART2_IRQn) disables the UART3_IRQn? Do I have to poll the UART3->IER than?

    Why is this connection not specified / stated clearly in the specification ?

Reply
  • 1) No, ICER not at all. Only about the relationship between the ISER and the IER.

    2) You are saying: It is need to both Enable NVIC->ISER and UART->IER simultaneously ?

    The source of confusion is the source code of enabling the NVIC IRQ

    static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
    {
      NVIC->ISER[((uint32_t)(IRQn) >> 5)] = (1 << ((uint32_t)(IRQn) & 0x1F)); /* enable interrupt */
    }

    If I want to enable multiple IRQs over UART->IER simultaneously, I have to do the following ?

    NVIC_EnableIRQ(UART3_IRQn);
    
    PC_UART3->IER = ...
    
    NVIC_EnableIRQ(UART2_IRQn);    // this disables UART3 already
    
    PC_UART2->IER = ...

    So, what happens with the NVIC UART3_IRQn respectively with the PC_UART3->IER, if the NVIC_EnableIRQ(UART2_IRQn) disables the UART3_IRQn? Do I have to poll the UART3->IER than?

    Why is this connection not specified / stated clearly in the specification ?

Children