Nano System clock gaining time

Discussion to talk about software related topics only.
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Nano System clock gaining time

Post by SeeCwriter »

We have several units using the NANO and the system clock gains about 5-minutes every 12-hours. Is there anything to be done?
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: Nano System clock gaining time

Post by TomNB »

Just basic questions: have you modified the ticks per second in predef.h? Are you using 2.x or 3.x tools?
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: Nano System clock gaining time

Post by TomNB »

The NANO uses a 25ppm oscillator, so that should not be happening. Can you confirm you are not talking about a real time clock, and as you say are describing the system secs value over a 12 hour period with no system file changes? It might be worth while to make a very simple app, like simplehtml, and add the ability to print out the secs value to verify it is not something in the application.
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Re: Nano System clock gaining time

Post by SeeCwriter »

I'm using v2.9.5 tools. I wouldn't think that would make a difference. The ticks per second has not been changed.
Not sure what is meant by the distinction of real-time clock vs system clock. It's the clock we get the date and time from.
User avatar
pbreed
Posts: 1081
Joined: Thu Apr 24, 2008 3:58 pm

Re: Nano System clock gaining time

Post by pbreed »

How EXACTLY are you getting the time from the unit.
how are you setting the time...

Give the precise CODE you are using...
User avatar
pbreed
Posts: 1081
Joined: Thu Apr 24, 2008 3:58 pm

Re: Nano System clock gaining time

Post by pbreed »

In the 3.X branch I find:
Fixing tick count multiple interrupt trip issues in 5441X, was causing clock to run fast
It has to do with the time keeping interrupts on all 5441X platforms. (Nano includee)

I'll see what it takes to back port this to 2.9.5
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Re: Nano System clock gaining time

Post by SeeCwriter »

On bootup, RTCSetSystemFromRTCTime() is called to restore time from an external real-time clock, PFC8563.
When queried for the current time, this function is used:

Code: Select all

//Formats 16 bytes time into "string" as 1999/12/31,23:59
void FormatDateTime( char *string, bool add_sec )
  {
  time_t t;
  time( &t );
  struct tm *ptime = localtime( &t );
  if ( !ptime )
    {
    string[0] = 0;
    return;
    }
  siprintf( string, "%04d/%02d/%02d,%02d:%02d:%02d",  ptime->tm_year + 1900, 
                                                      ptime->tm_mon + 1, 
                                                      ptime->tm_mday, 
                                                      ptime->tm_hour, 
                                                      ptime->tm_min, 
                                                      ptime->tm_sec );

  if ( !add_sec ) string[16] = NUL;

  }
User avatar
pbreed
Posts: 1081
Joined: Thu Apr 24, 2008 3:58 pm

Re: Nano System clock gaining time

Post by pbreed »

Please try the following change:

In nburn\nano54415\system\bsp.cpp

Find the xTick....
void xTick()
{
asm(".global Tick5441X");
asm(".extern OSTickISR");
asm(".extern write_pcsr");
asm("Tick5441X:");
asm(" move.w #0x2700,%sr"); //Add this line....
asm(" move.l %d0,-(%a7)");
asm(" move.b #0x0F,%d0");
asm(" move.b %d0,0xFC080001");
asm(" move.l (%a7)+,%d0");
asm(" jmp OSTickISR");
}

Remember you need to rebuild the platform after this change.
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Re: Nano System clock gaining time

Post by SeeCwriter »

I made the change and built the system and my app. I loaded it into a Nano, and am running it. I'll know tomorrow if it worked. If it works, should the MOD5541X get the same change?
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Re: Nano System clock gaining time

Post by SeeCwriter »

The fix works. Should this change be added to the other 5441X modules?
Post Reply