Dear All,
I am a newbie. I am using dsPIC30F3011 interrupts. Problem is, say I have activated the ISR of int0 only, but that ISR of int0 always gets activated if I input (no matter 0 or 1) something in any other interrupts pins or some other pins of the MCU which has no relation with interrupt. Even the ISR is called if I touch those pins with any metal in stead of any 1/0 input.
This is the code I am using-
Code:
void InitINT(void)
{
INTCON2=0x0001; //the result is same whether I set 1 or 0 here
//External Interrupt 0
IEC0bits.INT0IE=1; //enable INT0 ISR
IFS0bits.INT0IF=0; //clear INT0 interrupt flag
IPC0bits.INT0IP = 4; // interrupt priority
return;
}
void __attribute__((interrupt, no_auto_psv)) _INT0Interrupt(void)
{
SendData('e'); // Send this to PC
IFS0bits.INT0IF=0; //clear INT0 interrupt flag
}
Please tell me all the possible reasons (in both firmware and hardware parts) behind it so that I can troubleshoot
I have not used dsPIC but some general ideas that might help you:
- check if you enabled only the interrupt you want triggered
- check if you set the interrupt to trigger on the proper edge (rising or falling)
- be sure to use pull up/down on the interrupt pin and not leave it floating
The behaviour you experienced (touch pins with any metal ..) lead me to believe that the floating pin is the problem ... pull the input pin up with 10K resistor and short to ground in order to trigger the interrupt or push down with 10K resistor and short to vcc to trigger the interrupt...
lol a intterupt generates on EDGE not on 1 or 0 really. You have to check your self if its high or low. You can trigger it on FALLING or RISING edge . A Logical 1 can be anything remember a HIGH Voltage or a Long one. A zero can be a Low Voltage or a HIGH short pulse.
atom, he obviously set the pin for input as he gets his interrupt routine triggered ... I'd say it is hw prob as "Even the ISR is called if I touch those pins with any metal" ... that's pretty much showing that input pin is floating