P0SEL |= 0x03; P0 |= 0x3f; P0DIR |= 0x3f;
the interrpt configration codes are the following:
P0IF =0; P0IFG = 0x00; PICTL |= PICTL_P0ICON; //fall edge PICTL |= PICTL_P0IENH;
INT_ENABLE(INUM_P0INT, INT_ON);
and the interrupt routine are the following:
#pragma vector = P0INT_VECTOR__interrupt void KEY_ISR(void){ INT_ENABLE(INUM_P0INT, INT_OFF); if (P0IFG & BIT7) { //key P0IFG &= ~BIT7; // Clear status flag for pin f_keyint = 1; } else if (P0IFG & BIT6) P0IFG &= ~BIT6;
else if (P0IFG & BIT5) P0IFG &= ~BIT5; else if (P0IFG & BIT4) P0IFG &= ~BIT4; P0IF =0; // Clear CPU interrupt status flag INT_ENABLE(INUM_P0INT, INT_ON); }
at this time, a unusual phenomenon presented : before I press the button , external interrupt occoured frequently . the interrupt source is P0_5 or P0_4 .
what does the phenomenon mean?
any ideas? thanks a lot !
What are pins P0.5 and P0.6 connected to on your board? Do you see any noise on these pins?
From what I see, your code looks ok. However, the CC1110 datasheet states in section 12.4.4 that you should always clear the IO module's interrupt flags (P0IFG register) prior to clearing the CPU's interrupt flag (IRCON.P0IF). Another tip, you should implement some kind of software debounce on your button to be sure a single button click doesn't trigger multiple interrupts.
Br,ABO
--If this post answered your question, thank you for clicking Verify Answer
thank you for your reply!
now the phenomenon presented enen when I connect nothing at all I/O ports. (all pins are impending ). It seems that pressing key is not needed that the external interrupt occoured over and over. It looks like it works by itself .
Regards:
bob hong
Hi
For Port 0 and port 2 you can only enable/disable interrupts for 4 and 4 pins at the time. That means that is interrupt is enabled for let's say port0 pin 4 - 7 any activity on either of these pins will cause an interrupt, even if the pin is configures as an output.
If you use port1 instead you can enable/disable interrupts for each and every pin.
Br
Siri
thank you ! I think this is not very convenient for a designer. I have to change my design again!