Regarding Sleep interval in Stop3 mode-MC9S08GB60

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

Regarding Sleep interval in Stop3 mode-MC9S08GB60

Jump to solution
3,447 Views
mou
Contributor III
Hi,
 
The MCU(MC9S08GB60) in Stop3 mode can be exited using the RTI, where the RTIS can provide a sleep for only 1.024 sec by setting the bits RTIS0:RTIS1:RTIS2 to1:1:1.Can anyone suggest me a way to increase this sleep timing?
Is there any other way to exit stop3 mode without using external interrupts so that we can customize the sleeping interval?
I am using Maxstream XBee modules with MC13193 and MC9S08GT60.
Please help me in this regard.
 
Regards,
Mou
Labels (1)
0 Kudos
Reply
1 Solution
1,260 Views
mou
Contributor III
Hi bigmac,
I am facing problem whenever I set the value of MAX_RTI_COUNT>130(approx), which gives me around 2mins sleep time.
But I had declared the global variable RTI_count as an int.
Can you please let me know the approx value of MAX_RTI_COUNT that can provide me with the maximum sleep time and what should I declare the RTI_count as?
 
Thanks and Regards,
Mou

View solution in original post

0 Kudos
Reply
10 Replies
1,260 Views
mou
Contributor III
Wiresim,
 
Can you please provide me with your piece of sample code for the ISR (RTI) so that I can have an idea about the solution you are suggesting. Can I implement a cyclic sleep process in this way?( its like, the chip will remain active for a certain interval of time, then go to sleep for a certain interval and again wake up and continues in this way.)If yes, please let me know.
 
Thanks and Regards,
Mou
0 Kudos
Reply
1,260 Views
wiresim
Contributor I
Mou,

The ISR I implemented as follows (I think it is the working version!!) :

Code:
void interrupt RTI_Interrupt_Routine(void){
       
   
    RTI_count++;
   
    if(RTI_count >= MAX_RTI_COUNT){
       
        RTI_count    = 0;                     //Reset counter
        SRTISC       = RTI_OFF_1s;            //Turn off RTI
        Normal_Mode  = 1;                     //Resume normal operation
    }
    else{
       
        Sleep_Mode   = 1;                     //Otherwise, sleep
    }
}  

Explanation:

RTI_count is the variable to imcrment periodically upon interrupt. MAX_RTI_COUNT is the time in seconds   you want to sleep for.

SRTISC is the RTI control register and RTI_OFF_1s = 0x07. Turn off RTI so it doesn't keep interrupting your program when you don't want it to.

Normal_Mode and Sleep_Mode are flags that are used by the main program to put the device back to sleep or wake it up (other peripherals). You could try putting the command directly into the ISR for sleep or wake up.

The MCU is periodically sleeping and then waking up on RTI. To minimise power consumption during this brief ON time from the check in the ISR turn off anything that may consume power, other peripherals, internal settings etc. Because you are performing a simple check in the ISR, the ON time will be very small compared to the SLEEP time so power consumption should be not much more than in SLEEP operation. You could work out the current and hence power consumption from the electrical characterisitcs in the data sheet and also by knowing the time taken to complete the check and then go back to sleep.

Hope this helps,

Wiresim.
0 Kudos
Reply
1,260 Views
wiresim
Contributor I
Mou,

I notcied that in the code I gave you, I haven't included a command to clear the interrupt flag in the SRTISC register. If you don't clear the flag, you will re-enter the ISR as soon as you exit from the previous interrupt. To clear the flag, write a 1 to the RTIACK bit in the SRTISC register.

Regards,

Wiresim.
0 Kudos
Reply
1,260 Views
mou
Contributor III
Hi Wiresim,

The code you have provided is not working, when I want the module to sleep for more than 3mins. But, I need to make the module sleep for hours.Infact, the value of the counter in the loop works for a maximum value of about 120-180.If the value is more than what corresponds to 3mins, the module remains in Sleep and never wakes up. Can you please help me out with this and suggest me a way to make the module sleep for hours?
I need this information very urgently.
Thanks for your help amd support.
Waiting for your response,

Best Regards,
Mou
0 Kudos
Reply
1,260 Views
bigmac
Specialist III
Hello Mou,
 
What is the value of MAX_RTI_COUNT that you use?  The global variable RTI_count will need to be of
sufficient size to accommodate this value.  For unsigned int, you should be able to achieve about 18
hours.
 
When you compile the code, do you get any warnings associated with the ISR code?
 
Regards,
Mac
 


Message Edited by bigmac on 2008-04-08 01:26 AM
0 Kudos
Reply
1,261 Views
mou
Contributor III
Hi bigmac,
I am facing problem whenever I set the value of MAX_RTI_COUNT>130(approx), which gives me around 2mins sleep time.
But I had declared the global variable RTI_count as an int.
Can you please let me know the approx value of MAX_RTI_COUNT that can provide me with the maximum sleep time and what should I declare the RTI_count as?
 
Thanks and Regards,
Mou
0 Kudos
Reply
1,260 Views
bigmac
Specialist III
Hello Mou,
 
If an 18 hour period is sufficient, declare the variable as unsigned int.  If you need more than this,
use an unsigned long variable.
 
Is the code you are using exactly the same as Wiresim provided, using a flag to indicate that stop mode should be re-entered?
 
If you happened to be re-entering stop mode from within the ISR, there would be a definite problem, as I  Indicated earlier.  In this case, the ISR code would be called recursively on each wakeup (since there would not be an exit from the previous ISR call), and eventually the stack would overflow.  I wonder if this might be your problem.
 
It is necessary to exit the ISR before re-entering stop mode.
 
Regards,
Mac
 


Message Edited by bigmac on 2008-04-08 09:10 AM
0 Kudos
Reply
1,260 Views
mou
Contributor III
Wiresim,
 
Thanks for your concern. I had already cleared the flag in my earlier code. Your code is also working fine.
Thanking You,
 
Regards,
Mou
0 Kudos
Reply
1,260 Views
wiresim
Contributor I
Mou,

I had a similar problem. The way I solved it was to simply wake up every 1.024 sec and incremet a counter inside the interrupt service routine. The counter was then checked against a maximum counter value, 30 for example (representing approx. 30 seconds). If the max counter was not reached then go back to sleep, else stay awake.

However, this may be overkill and there may be a much simpler way to do it, so if anyone else knows I would also be interested. In the meantime, I suggest you try this Mou.

Wiresim.
0 Kudos
Reply
1,260 Views
bigmac
Specialist III
Hello,
 
Using multiple wake-ups, as Wiresim has suggested, should have a negligible effect on average power consumption.  However, when stop mode is re-entered, make sure that the STOP instruction is outside of any ISR code.  This is to avoid the problems associated with the presence of nested interrupts.
 
Regards,
Mac
 
0 Kudos
Reply