avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] ATmega644 pin-change interrupts


From: Per-Tore Aasestrand
Subject: [avr-gcc-list] ATmega644 pin-change interrupts
Date: Thu, 29 Nov 2007 15:44:18 +0100

Hi list,

I am using an ATmega644 and is attempting to set up pin-change interrupts for ports PA4/PCINT4 & PA5/PCINT5. I've used the following code. Apparently, no interrupts are coming. Any obvious faults?

When in the interrupt handler, how should a decide what pin created the interrupt? I can't find a flag-bit that carries this information.

Regards,

Per-Tore

-----------------------------------------------------------------------------------------------

#define          BSET(p,b)        ((p) |=  (1<<b))                  // Set bit
#define          BCLR(p,b)       ((p) &= ~(1<<b))                  // Clear bit

...

//-------------------------------
// Initialize External Interrupts
//-------------------------------
void InterruptInit()
{
         BCLR(SREG,7);                                       // Disable Global Interrupts

         BCLR(EIMSK,INT0);                                  // Disable INT0
         BCLR(PCICR,PCIE0);                                 // Disable PinChangeInterrupt0

        // Set External Interrupt Control Register A to trigger on both edges
         BCLR(EICRA,ISC01);                                 // ISCn1 = 0
         BSET(EICRA,ISC00);                                 // ISCn0 = 1
        
        // Enable Pin Change Interrupts
         BSET(PCICR,PCIE0);
         BSET(PCMSK0,PCINT0);

         BCLR(EIFR,INTF0);                                  // Clear INTF0 Flag
         BSET(EIMSK,INT0);                                  // Enable external interrupt INT0

         BSET(SREG,7);                                       // Enable Global Interrupt

} // InterruptInit()


//---------------------------
// External Interrupt handler
//---------------------------
ISR(INT0_vect)
{
        // Detect were interrupt came from (PA4 or PA5)
        ...
}

              \\|//
             /_"""_\
            |(O) (O)|
 --------oOOO--(_)--OOOo---------
|                                |
|   Per-Tore Aasestrand          |
|   E-mail: address@hidden        |
|   Tel   : +47 55 32 32 35      |
|   Mobile: +47 920 444 76       |
|   PO Box 1708 Nordnes          |
|   N-5816 BERGEN                |
|   Norway                       |
|                                |
 --------------------------------

Only recycled bits have been
used in this email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]