Hi...
I want to implement stop mode in my application. please provide the simple "c" code for implementing the stop-3 mode and waking stop-3 using RTC with 1KHz clock source .
it is very urgent, i have to include in my application.
Hello Shiva,
You will need to use inline assembly to implement the STOP instruction using C, i.e __asm stop;
Possibly you might create a macro to do this.
#define enter_stop __asm stop
Prior to entering stop mode, you would also need to enable the RTC interrupt. The ISR for the RTC module should clear the flag, and maybe disable further RTC interrupts.
During MCU initialisation, you will also need to configure for stop3 mode, and enable the STOP instruction, per the datasheet..
When stop3 mode is exited, the ISR code will be executed, and the operation will then continue immediately following the STOP instruction.
Regards,
Mac
Hi...
thank yu for the reply....
i'm using RTC for waking the stop-3 mode. and i'm using MC9S08SH8 8-bit microcontroller in my application.
and the initialisations are:
#define x 0x01
#define y 0xFE
main()
{
for( ; ; )
{
RTCSC = 0x1F; //1sec 1khz clock source is enabled.with RTIE enabled
if( Z & x) //refer above for x
{
Z = Z & y; //refer above for y
_Stop;
}
__RESET_WATCHDOG(); /* feeds the dog */
}
}
void interrupt VectorNumber_Vtpm1ovf timerPWM(void) //timer interrpt for 0.1sec
{
TPM1SC_TOF=0;
PTAD_PTAD2 = ~ PTAD_PTAD2; //for checking purpose
Z = 0x01;
}
void interrupt VectorNumber_Vrtc realtimeinterrupt(void)
{
RTCSC_RTIF = 1; //for clearing RTIF flag.
RTCSC_RTIE = 0;
}
In the above case, RTC not waking properly, and the two ISR's are not working exactly. so, please ttell me where the problem is occuring.i.e, when the stop instruction in the for loop is seen, it enter into stop and after one sec, RTC interrupt comes, because i uased 1KHz clock source. and the RTC interrupt flag clear , and after that bus_clock everything has to work normally but it is not going to timer PWM ISR immediately it is taking large time to go to timer interrupt. so, im thinking some wrong i'm making in the initialisation.
In case of enabling the RTC , initialisation is sufficient or anything has to be done. and 1KHz source can be used for RTC to wake from STOP-3 mode. and please provide the solution for the above problem as early as possible.
Hello Shiva,
I am not sure I completely understand your problem. However keep in mind the following factors:
Regards,
Mac