This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I just made a program with a interrupt funktion in it. On my oppinion it should works but somewhere is a little error in it. I've already checked with the logic analyzer, that on the GDO0 pin is a pulse, but as I said, it does nothing in the program. Maybe anyone here can find the bug. Thanks a lot.
void Interrupt_init() {
GDO0DIR &= ~GDO0;
GDO0REN |= GDO0; // activate internal resistor
GDO0IE |= GDO0; // activate port interrupt at P2.0
GDO0IES |= GDO0;
__enable_interrupt();
}
// PORT2 interrupt service routine
#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void) {
--- code ---
GDO0IFG &= ~GDO0;
}
In what way does it not work? Do you reach a breakpoint set at the first line of Port_2()? If you Pause in the debugger, where is the program executing?
I'll mention that you're enabling the internal resistors (REN) without setting P2OUT; the value of P2OUT is unknown at startup, so this could be pulling up or down. If your pulse source is driving the wire, that probably doesn't matter much but in that case you probably shouldn't be enabling the REN anyway.
In the debug mode, it never stopped when I had a breakpoint in the interrupt methode.
If you Pause in the debugger, where is the program executing?
While you're in there, you might want to check the P2 registers ("View->Registers") to make sure they're set the way you think.
**Attention** This is a public forum