Skip to main content
Visitor II
August 25, 2007
Question

Clearing ENET Interrupts (ENET_ISR)

  • August 25, 2007
  • 2 replies
  • 659 views
Posted on August 25, 2007 at 12:17

Clearing ENET Interrupts (ENET_ISR)

    This topic has been closed for replies.

    2 replies

    saraoAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:46

    What is the proper way to clear the interrupt bits for the ENET_ISR?

    Below is some code snippets. Is this the correct way to handle clearing the interrupt? Is there a better way? Is there something else I should do?

    I enable the following interrupts:

     

    ENET_DMA->IER = 0x00000000; // clear all bits

     

    ENET_DMA->IER |= 0x02000000; // TX_MERR_INT_EN

     

    ENET_DMA->IER |= 0x00800000; // TX_DONE_EN

     

    ENET_DMA->IER |= 0x00400000; // TX_NEXT_EN

     

    ENET_DMA->IER |= 0x00000200; // RX_MERR_INT_EN

     

    ENET_DMA->IER |= 0x00000080; // RX_DONE_EN

     

    ENET_DMA->IER |= 0x00000040; // RX_NEXT_EN

     

    ENET_DMA->IER |= 0x00000020; // PACKET_LOST_EN

     

    I enable the ENET interrupt vector

     

    VIC_Config( ENET_ITLine, VIC_IRQ, 2 );

     

    VIC_ITCmd( ENET_ITLine, ENABLE );

     

    My ISR gets called okay:

     

    void ENET_IRQHandler(void)

     

    {

     

    u32 currentState = ENET_DMA->ISR;

     

    u32 irqToClear = 0;

     

    if ( currentState & 0x00800000 ) // TX_DONE_EN

     

    {

     

    MUTEX_ENET = 1;

     

    irqToClear |= 0x00800000;

     

    }

     

     

    // TODO: Check for Received packet

     

    if ( currentState & 0x00000080 )

     

    {

     

    MUTEX_ENET_REC = 1;

     

    irqToClear |= 0x00000080;

     

     

    }

     

    // TODO: Check for Errors?

     

     

    if ( currentState & 0x00000020 )

     

    {

     

    irqToClear |= 0x00000020;

     

    }

     

     

     

    // Clear Interupt: Is this okay?

     

    ENET_DMA->ISR = irqToClear; // 0xFFFFFFF

     

     

    }

     

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:46

    Hi

    The method looks correct - simply write the bit to be cleared with 1.

    However I see no advantage in collecting the serviced interrupt bits and clearing them all at the end of the routine.

    Rather than doing

    irqToClear |= 0x00000020;

    you could simply do

    ENET_DMA->ISR = 0x00000020;

    Also it may be an idea to use a loop in the routine so that it only exits when all interrupt have been service (an interrupt can arrive while in the IRQ so it can be serviced without having to first quit.

    Eg:

    while ((ENET_ISR) & ENET_IER) { // while enabled interrupts waiting, handle them all

    if (ENET_ISR & TX_CURR_DONE_EN) {

    ENET_ISR = TX_CURR_DONE_EN; // reset flag

    // etc.

    }

    if (ENET_ISR & RX_ENTRY_EN) {

    ENET_ISR = RX_ENTRY_EN; // reset flag

    // etc.

    }

    // etc....

    }

    Regards

    Mark

    http://www.uTasker.com