Hi,
I'm using an m32c-87 that works in stop mode; I use this code to put the mcu in stop mode:
---------------------------------------------------------------------------------------------------------------------------------------
rlvl |= 0x07;//RLVL -> Livello 7
int3ic &= 0xF8;
ifsr3 = 0;//one edge
int3ic &= 0xCF;//Edge sensitive (falling edge)
ir_int3ic = 0;
int3ic |= 0x01;//Interrupt INT3 abilitato;
int5ic &= 0xF8;
ifsr5 = 0;//one edge
int5ic &= 0xCF;//Edge sensitive (falling edge)
ir_int5ic = 0;
int5ic |= 0x02;//Interrupt INT5 abilitato;
while(1){
//STOP MODE
asm("fclr i");
int3ic |= 0x07;//Interrupt uscita stop mode
int5ic |= 0x07;//Interrupt uscita stop mode
//Settare, se presenti, i livelli degli interrupt non usati per l'uscita dallo stop mode a livello 0
asm("ldipl #2");//IPL -> Livello 2
rlvl &= 0xFA;//RLVL -> Livello 2
asm("fset i");
prc0 = 1;
cm10 = 1;
apiDelay(1, Timer4msecDelay, 0x66);//routine that performs a delay oa about 100 msec
};
---------------------------------------------------------------------------------------------------------------------------------------
where I use two interrupts (INT3 and INT5) with two differents routines to exit of stop mode, doing some instructions, and coming back to the stop mode.
First of all I resolved to use only one interrupt (INT5) to exit the mcu of the stop mode, setting the INT3 interrupt pin to an high level (with a pull-up resistor).
Both the interrupt routines starts with:
---------------------------------------------------------------------------------------------------------------------------------------
asm("nop");
asm("nop");
asm("nop");
asm("nop");
prc0 = 0;
rlvl |= 0x07;//RLVL -> Livello 7
asm("fclr i");
prc0 = 1;
mcd &= 0xE0;
prc0 = 0;
index = 0;
while(index<1000){index++;}
prc0 = 1;
mcd |= 0x12;
prc0 = 0;
index = 0;
while(index<1000){index++;}
prc0 = 1;
cm04 = 1;
prc0 = 0;
index = 0;
while(index<1000){index++;}
---------------------------------------------------------------------------------------------------------------------------------------
but when the INT3 routine ends I note the ir_int5ic bit goes high also if it has been cleared when the routine started; for this reason the routine started again and only after two times, the routine stops and the mcu comes back in stop mode. I decided to manually clear this bit to the end of the routine to solve the problem, but I really don't understand where is the mistake; I have also used interrupt routines but I never have seen nothing like this...
Colud anyone help me ?
Kind regards
Davide Urbano