Ewa Wojno-Tomaszewska

MC9S08GT16: stop instruction in interrupt subroutine

Discussion created by Ewa Wojno-Tomaszewska on Jul 9, 2007
Latest reply on Jul 11, 2007 by Ewa Wojno-Tomaszewska

Hi!

I’m using IRQ interrupt to put MC9S08GT16 stop 3 mode. The RTI interrupt periodically (every second) wakes up the processor. In RTI interrupt processor checks the state of the IRQ  pin and either enters stop mode again (IRQ low) or continues normal work (IRQ high). This is my code of RTI interrupt subroutine:

__interrupt void isrVrti(void)

{            

SRTISC |= 0x40;

if (FLAGI.SLEEP){

            IRQSC_IRQPE=1;

            asm {  

                                   NOP              

                                   BIH IRQ_HIGH           

            IRQ_LOW:     BCLR 4,0x14   

                                   STOP            

            IRQ_HIGH:    NOP

            }                     

            /* exit STOP */

     IRQSC_IRQACK=1;

     IRQSC_IRQIE=1;

     IRQSC_IRQPE=1;

     FLAGI.SLEEP=0;

     ...

} 

The problem is when I try to exit RTI interrupt subroutine when IRQ is high – the processor repeats instructions from: IRQ HIGH several times. On the other hand when processor stays too long in stop mode (IRQ is low for couple of minutes) reset occurs, caused by ILAD (attempt to access an illegal address). I guess I should take care of a stackpointer, but I don’t know how?

Thanks for any help,

Marigold

Outcomes