We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello! We're trying to use the fast external interrupt inputs EX1IN and EX2IN. We read the manual over and over and still we must be doing something wrong because the interrupt service routine never fires using the corresponding CAPCOM interrupt vectors. We would be grateful for any help. Here's the code: void EX1IN(void) interrupt 0x19 { // Never gets to here! } void main(void) { DP2_P9 = 0; // P2.9 as input (EX1IN) DP2_P10 = 0; // P2.10 as input (EX2IN) // CAPCOM MOD9 & MOD10 to capture // on rising edge. CC1_M2 = 0x0110; // Enable interrupt inputs P2.9 & P2.10. CC1_CC9IC_IE = 1; CC1_CC10IC_IE = 1; // EX1IN & EX2IN interrupt on rising edge. EXICON = 0x0014; // Select external interrupt inputs. EXISEL0 = 0x0000; PSW_IEN = 1; // Global interrupt enable. while(1) ; }
I think you should leave the capture/compare mode to disabled.
You forget to initialize port pins as inputs: P2_P9 = 1; P2_P10 = 1; before DP2_P9 = 0; // P2.9 as input (EX1IN) DP2_P10 = 0; // P2.10 as input (EX2IN)
Thanks so much guys! We were setting P2.9 and P2.10 as inputs elsewhere. CAPCOM needs to be in capture mode. It's working now - there were a couple of problems. I learned that no interrupts within a group can have the same priority. Also a priority of zero didn't seem to work.
I learned that no interrupts within a group can have the same priority. As the manual clearly says:
Note: All interrupt request sources that are enabled and programmed to the same interrupt priority level (ILVL) must have different group priority levels. Otherwise, an incorrect interrupt vector will be generated.
An action request will be accepted by the CPU if the requesting source has a higher priority than the current CPU priority level and interrupts are globally enabled. If the requesting source has a lower (or equal) interrupt level priority than the current CPU task, it remains pending.