Stephane Ethier

How to get Interrupts working on MC9S08GB60

Discussion created by Stephane Ethier on Sep 16, 2011
Latest reply on Sep 17, 2011 by bigmac

Hello,

 

I am using MC9S08GB60  and I am attempting to locate some good documentation or even examples that will show me how to use the IRQ interrupt pin (and potentially other sources of interrupts). I am using CW08 V3.1 and I want to be able to program the interrupts using C.

 

I have a basic program written so far for me to test the interrupt and when I enable the IRQ interrupt I don't seem to reach my main program anymore and I don't reach my interrupt subroutine either. However when I disable the interrupt I reach the main and output to the LEDs OK.

 

Here is what I have so far:

Main program:

void main(void)

{

...

IRQSC = 0b0011110;

...

<code that outputs to LEDs to see if I am in the main program>

...

while(1); // infinite loop

}

 

In my Cpu.c file (created by Processor Expert) I have:

#pragma CODE_SEG __SHORT_SEG NON_BANKED
__interrupt void IRQ_Interrupt(void)
{
...

<code that outputs to LEDs to see if I reach the interrupt>

...

while(1); // infinite loop

}
#pragma CODE_SEG DEFAULT

 

In my Cpu.h file (also reacted by Processor Expert) I have:

 

...

__interrupt void IRQ_Interrupt(void);

...

 

and I modified Vectors.c to the following:

void (* const _vect[])() @0xFFCC = {   // Interrupt table
           Cpu_Interrupt,        /* Vector 25 */
           Cpu_Interrupt,        /* Vector 24 */
           Cpu_Interrupt,        /* Vector 23 */
           Cpu_Interrupt,        /* Vector 22 */
           Cpu_Interrupt,        /* Vector 21 */
           Cpu_Interrupt,        /* Vector 20 */
           Cpu_Interrupt,        /* Vector 19 */
           Cpu_Interrupt,        /* Vector 18 */
           Cpu_Interrupt,        /* Vector 17 */
           Cpu_Interrupt,        /* Vector 16 */
           Cpu_Interrupt,        /* Vector 15 */
           Cpu_Interrupt,        /* Vector 14 */
           Cpu_Interrupt,        /* Vector 13 */
           Cpu_Interrupt,        /* Vector 12 */
           Cpu_Interrupt,        /* Vector 11 */
           Cpu_Interrupt,        /* Vector 10 */
           Cpu_Interrupt,        /* Vector 09 */
           Cpu_Interrupt,        /* Vector 08 */
           Cpu_Interrupt,        /* Vector 07 */
           Cpu_Interrupt,        /* Vector 06 */
           Cpu_Interrupt,        /* Vector 05 */
           Cpu_OnClockMonitorInt,        /* Vector 04 */
           Cpu_Interrupt,        /* Vector 03 */
           IRQ_Interrupt,        /* Vector 02 */
           Cpu_SWIInterrupt,/* Vector 01 */
           _EntryPoint            /* Vector 00 */
   };

Outcomes