Interrupt handler looping infinitely, need help (9S08DZ60)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interrupt handler looping infinitely, need help (9S08DZ60)

1,224 Views
bdayberr
Contributor I
On the dev board I am working on (DEMO9S08DZ60) there are two push-button switches tied to a few of the port b pins on the MC, and I am trying to use one to cause an interrupt. I am following the general outline in AN2616 which describes how to use C and codewarrior. There is a portion of the guide that shows how to have an interrupt on SW1, which is very similar, if not identical, to what I am trying to do. By following the advanced data for my MCU and this guide, I have the following code for this interrupt:

(In a header file)
#define VNswitch 22

(in the main.c file, at the top)
interrupt VNswitch void intSW1(){
  LED1 = SW1;
  PTBSC_PTBACK = 1;   /*ACK interrupt*/
}

(just above the infinite program for loop, initializing interrupt)
  PTBSC_PTBIE = 0; /*mask interrupts*/
  PTBES_PTBES6 = 1;/*edge select*/
  PTBPE_PTBPE6 = 1;/*pullup pin*/
  PTBPS_PTBPS6 = 1;/*select pin*/
  PTBSC_PTBACK = 1;/*clear false ints*/
  PTBSC_PTBIE = 1;/*enable interrupts*/


When I run the program, I know for a fact the interrupt does make it to the CPU, because I can have the debugger running, step through initializations, then press SW1 and the debugger hangs for a second, then shows no program in the C code, but about 3 dozen BRSET commands in assembly, with a CMP thrown in somewhere. I continue to step through, and eventually get to the RTI instruction, step, the debugger hangs for a sec again, then goes right back to beginning of the interrupt code, with a program counter of 0. This process continues infinitely until I perform a target reset. Does anyone know why my interrupt handling goes on forever once the interrupt has occured? Intuitively I feel it has something to do with the interrupt acknowledgement not occuring, or something regarding the interrupt flag not properly being cleared. Any ideas? I am just trying to get a simple interrupt working for a pushbutton switch, it can't be that hard.


Message Edited by bdayberr on 2008-02-22 10:53 PM
Labels (1)
0 Kudos
1 Reply

257 Views
bdayberr
Contributor I
I was able to fix this issue for anyone that may see this thread in the future.

I am using the device initialization to create an MCU_init() which happens to initialize the vector table and interrupt service routines. by editing the vector table and declaring the interrupt handler in MCU_init.c, I was able to fix the problem. What was happening before was the MCU_init.c had just declared all ISRs as UNASSIGNED_ISR, which just made the interrupt execute meaningless code somewhere in memory.
0 Kudos