Hi tyson,
Can you send your actual source code instead of pseudo code for this Port G edge interrupt service routine?
I think your most likely using a read-modify-write instruction like BSET when clearing the respective flag in the Port G flag register. If you do this, you can accidently clear flags for other Port G pins that are pending interrupt. Therefore, you will not see all the interrupts you expected.
For some flag clearning rules, please read application note AN2554.
Just a snippet of my cheat sheet for flag clearing:
For Assembly Language:
The bits in the CRGFLG register are "write 1 to clear". To clear specific bits you must use the instruction sequence:
Method 1:
LDAA bitmask
STAA CRGFLG
(Of course B could be used)
Or
Method 2:
BCLR CRGFLG, ~bitmask
Could be used.
You cannot use:
Wrong Method:
BSET CRGFLG, bitmask
On this register, because BSET is a "read-modify-write" instruction: all set bits will be cleared.
**************************************************************************************
For C Language:
Assuming CRGFLG is defined as
volatile unsigned char CRGFLG @ (0x37 + REG_BASE);
Then,
Method 1 – Flag Register:
CRGFLG = 0x80; /* clear RTIF */
Will translate to LDAA/B STAA/B and clear RTIF and nothing else.
To make this easier, define bitmasks for the register:
#define RTIF 0x80
#define PORF 0x40
Etc.
Then write,
CRGFLG = RTIF; /* clear RTIF */
Or
CRGFLG = RTIF + PORF; /* clear RTIF and PORF */
Method 2 – Flag Register:
To get the BCLR CRGFLG, $7F instruction, you need to use
CRGFLG &= 0x80; /* clear RTIF */
Or
CRGFLG &= RTIF; /* clear RTIF */