Reply by Daniel White February 16, 20052005-02-16
I think you'll learn a lot more once you clear port b inside your idle for
loop.

for(;;) {PORTB=0;} /* wait forever */

Just rembemer that it will return to the point that was interrupted which
will be inside your for loop. -----Original Message-----
From: Adnan [mailto:]
Sent: Wednesday, February 16, 2005 10:18 AM
To:
Subject: [68HC12] Interrupts on MC9S12C32

I have been trying to drive an encoder but my interrupt routine
doesn't work. It goes into the ISR but then there is nothing. I have
written a simple program to make all the LEDS high on PORTB as soon
as it goes into the interruot service routine and they should go low
when it returns to the main function. Now the problem is that it is
not returning to the main function. I am a beginner at this so here
is the code. any help wpuld be appreciated. I am using CODEWARRIOR
to compile this code thanks #include <hidef.h> /* common defines and macros */
#include <mc9s12c32.h> /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12c32"
#pragma TRAP_PROC
void interrupt 1 IRQ_ISR(void){
PORTB=0xFF;
}

#pragma TRAP_PROC
void interrupt 2 RTI_ISR(void) {

/* clear RTIF bit */
CRGFLG = 0x80;
}

#pragma TRAP_PROC
static void RTIInit(void) {
/* setup of the RTI interrupt frequency */
/* adjusted to get 1 millisecond (1.024 ms) with 16 MHz oscillator
*/
RTICTL = 0x1F; /* set RTI prescaler */
CRGINT = 0x80; /* enable RTI interrupts */
} void main(void) {
RTIInit();
CRGFLG=0x80;
DDRB=0xFF;
PORTB=0;
INTCR_IRQEN=1;
INTCR_IRQE=0;
EnableInterrupts;
for(;;) {} /* wait forever */
}

Yahoo! Groups Links



Reply by Adnan February 16, 20052005-02-16

I have been trying to drive an encoder but my interrupt routine
doesn't work. It goes into the ISR but then there is nothing. I have
written a simple program to make all the LEDS high on PORTB as soon
as it goes into the interruot service routine and they should go low
when it returns to the main function. Now the problem is that it is
not returning to the main function. I am a beginner at this so here
is the code. any help wpuld be appreciated. I am using CODEWARRIOR
to compile this code thanks #include <hidef.h> /* common defines and macros */
#include <mc9s12c32.h> /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12c32"
#pragma TRAP_PROC
void interrupt 1 IRQ_ISR(void){
PORTB=0xFF;
}

#pragma TRAP_PROC
void interrupt 2 RTI_ISR(void) {

/* clear RTIF bit */
CRGFLG = 0x80;
}

#pragma TRAP_PROC
static void RTIInit(void) {
/* setup of the RTI interrupt frequency */
/* adjusted to get 1 millisecond (1.024 ms) with 16 MHz oscillator
*/
RTICTL = 0x1F; /* set RTI prescaler */
CRGINT = 0x80; /* enable RTI interrupts */
} void main(void) {
RTIInit();
CRGFLG=0x80;
DDRB=0xFF;
PORTB=0;
INTCR_IRQEN=1;
INTCR_IRQE=0;
EnableInterrupts;
for(;;) {} /* wait forever */
}