problem i execting the  stop3 using RTC in MC9S08SH8

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

problem i execting the  stop3 using RTC in MC9S08SH8

1,012 Views
ellendula
Contributor I

Hi...

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.

Labels (1)
0 Kudos
3 Replies

501 Views
PatrickW
Contributor III

Disclaimer:  I'm an amateur at best.

 

In your ISR, you have:

RTCSC_RTIF = 1;

RTCSC_RTIE = 0;

 

Both of these are wrong I believe.  Instead you should use simply:

RTCSC_RTIACK=1;   //Clears the RTIF bit and clears the interrupt request

 

(You do not need the second line at all, unless you want to actually turn off the RTI altogether (ie. trigger no further interrupts).  

 

In your code somewhere (not in the ISR) you have to have 

RTCSC_RTIE = 1;  //Enable the RTI to begin with

 

Hope this helps, not sure if I'm missing something here.

 

 

 

0 Kudos

501 Views
peg
Senior Contributor IV

Hello Patrick,

 

While other S08 devices have an RTIACK bit to acknowledge and clear the RTIF flag, this one does not.

Writing a 1 to RTIF is the correct method for clearing the RTIF flag here.

RTFM!

 

0 Kudos

501 Views
PatrickW
Contributor III

Ah, see this is why I included disclaimers at the top and bottom divulging my non-professionalism!

 

OP:  Sorry if that caused you additional confusion.  I only hazarded my attempt at assistance because nobody had responded to your question for awhile... this will teach me to leave advice-giving to the experts!

 

Patrick

0 Kudos