MC9S08QG8 Stop Mode 2, Exit with RTI -> How?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S08QG8 Stop Mode 2, Exit with RTI -> How?

2,196 Views
chumpykid
Contributor I
Being new to this processor, I'm having trouble finding the correct way to enter/exit Stop Mode 2 from RTI.  Enter stop mode in main, then somehow exit in the RTI.  Below is minimal code to use to show an example....  I've enabled stop2 in SPMSC2= 0x03 and STOPE in SOPT1.  Any help would be appreciated.
 
void main(void)
{
   // Initialization
   MCU_init();
   
   // Enable Interrupts
   EnableInterrupts;
 
   // Background Loop
   while (1)
   {
           // Feed the dog
           __RESET_WATCHDOG();
       
           // check inputs
           CheckInputs(); 
 
           // Put into Stop Mode
           asm stop;    
   }
}
 
// RTI interrupt for Real Time Clock
void interrupt 23 RTI_Isr (void)
{
   // Acknowledges RTI Flag
   SRTISC_RTIACK = 1; 
  
   // Exit Stop Mode 2 here?
 
 
   // Time Keeping here
 
}
 
Labels (1)
0 Kudos
Reply
1 Reply

560 Views
chumpykid
Contributor I
After some painful tech support...  I can almost answer my own question..
 
Apparently if you have an "asm stop" in a while loop, it doesn't even bother to do the RTI.  If in stop mode 1 or stop mode 2, it does a POR, so you do not need to keep this in a loop, although the syntax is correct.
 
Stop Mode 3, I have yet to get it working correctly.  Stop Mode 3 does not do the POR, so you must keep it in some sort of loop.  I do see an overall drop in current, but not the results I would expect.
0 Kudos
Reply