Brennan Dayberry

Interrupt handler looping infinitely, need help (9S08DZ60)

Discussion created by Brennan Dayberry on Feb 22, 2008
Latest reply on Feb 23, 2008 by Brennan Dayberry
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