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
I disable all peripherals before entering stop mode, only RTI and external oscillator stays enabled. The power consumption is about 9uA, but I noticed that if the processor stays too long in stop mode (IRQ low), the power consumption drops to 2uA and putting IRQ high does not wake the processor or ILAD reset occurs.
IRQ is edge triggered.
Regards,
Marigold
In accordance with Your advices I gave up reentering STOP mode during interrupt and moved STOP instruction to the loop in the main function. Everything is working fine now (at least it seems to do ).
Thank You for help,
Marigold