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

Clearing CR0 interupt

Hi,
Using LPC2129.
I am using timer 0 to interupt on the falling edge of the signal on P0,2 (CAP0.0).
The interupt works fine, however I can't seem to clear the 'CR0 Interrupt' Flag after each interrupt, it just loops (always interrupting).
I have tried setting T0IR to 0x00000000 but this 'CR0 Interrupt' flag just sets it back again.
I can manually untick the flag in debug and this works fine but how do I do it in my code?
Any help would be much appreciated.
Thanks,
Andy.

Parents
  • I can manually untick the flag in debug and this works fine but how do I do it in my code?

    You need to set the T0IR bit (with a 1) you want to reset. See the DefaultIRQ below.

    #include <LPC21xx.H>    // Philips Peripheral Registers
    
    void DefaultIRQ (void) __irq
    {
    T0IR |= 1 << 6;  // Reset CC0.2 Interrupt
    }
    
    void main (void)
    {
    VICDefVectAddr = (unsigned long) DefaultIRQ;
    
    T0CCR |= 1 << 7;   // CC2 Falling Edge, CC0.2
    T0CCR |= 1 << 8;   // Interrupt on CC2 Capture
    
    PINSEL1 |= 3 << 0; // Setup P0.16 as CC0.2 input
    
    VICIntEnable |= 1 << 4;  // Enable Timer 0 Interrupts
    
    T0TCR |= 1 << 0;   // Counter Enable
    
    
    // Example for LPC2129
    // Toggle P0.16 to generate a CC interrupt
    
    while (1);
    }
    

    I just wrote and tested this example using the standard Philips LPC2129 startup.s file and it works just fine. Let me know if you are still having trouble.

    Jon

Reply
  • I can manually untick the flag in debug and this works fine but how do I do it in my code?

    You need to set the T0IR bit (with a 1) you want to reset. See the DefaultIRQ below.

    #include <LPC21xx.H>    // Philips Peripheral Registers
    
    void DefaultIRQ (void) __irq
    {
    T0IR |= 1 << 6;  // Reset CC0.2 Interrupt
    }
    
    void main (void)
    {
    VICDefVectAddr = (unsigned long) DefaultIRQ;
    
    T0CCR |= 1 << 7;   // CC2 Falling Edge, CC0.2
    T0CCR |= 1 << 8;   // Interrupt on CC2 Capture
    
    PINSEL1 |= 3 << 0; // Setup P0.16 as CC0.2 input
    
    VICIntEnable |= 1 << 4;  // Enable Timer 0 Interrupts
    
    T0TCR |= 1 << 0;   // Counter Enable
    
    
    // Example for LPC2129
    // Toggle P0.16 to generate a CC interrupt
    
    while (1);
    }
    

    I just wrote and tested this example using the standard Philips LPC2129 startup.s file and it works just fine. Let me know if you are still having trouble.

    Jon

Children