AnsweredAssumed Answered

Confused about RTC!

Question asked by davage on Mar 18, 2010
Latest reply on Mar 18, 2010 by PrasanthR

Hey Guys,

 

I am trying to time how long it takes for my main program to execute.  I’m using the code below.  The first part of code is before my main program and the second part of code is after my main program.  In the first part, I read what is in the RTC_STAT register and save the value for later.  In the second part, I read the RTC_STAT register again and subtract the saved value from the new value.  I then would take that result and divide it by the clock speed, 32.768kHz.  My thinking was that this would be the total time elapsed during the execution of my main program, but the results I get are not matching my hand held stopwatch.  I’ve also tried initialize the RTC_SWCNT register with the value 0x7FFF FFFF and then use the method below, but reading from the RTC_SWCNT register instead of the RTC_STAT register.  This didn’t work either.  The 0x7FFF FFFF value doesn’t even show up in the RTC_SWCNT register.  Do you guys have any ideas as to what I’m doing wrong?

 

/***************************

  *    Record start time  *

  ***************************/

 

p0.h = hi(RCT_STAT);           /* pointer to real-time-clock */

p0.l = lo(RCT_STAT);

 

r7 = [p0];                             /* load r7 with start time from RTC */

 

p0.h = 0x0300;                    /* pointer to saved start time */

p0.l = 0x0000;

 

[p0] = r7;                             /* store start time */

                                                .

                                                .

                                                .

                                                .

/***************************

  *    Record end time   *

  ***************************/

 

p0.h = hi(RCT_STAT);            /* pointer to real-time-clock */

p0.l = lo(RCT_STAT);

    

r5 = [p0];                              /* load r5 with end time from RTC */

 

p1.h = 0x0300;                     /* pointer to saved start time */

p1.l = 0x0000;

 

r6 = [p1];                              /* load start time */

 

r7 = r5 - r6;                           /* elapsed time */

 

Thanks,

 

Dave

Outcomes