Page 1 of 2
Nano System clock gaining time
Posted: Tue Oct 17, 2023 2:31 pm
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?
Re: Nano System clock gaining time
Posted: Tue Oct 17, 2023 3:17 pm
by TomNB
Just basic questions: have you modified the ticks per second in predef.h? Are you using 2.x or 3.x tools?
Re: Nano System clock gaining time
Posted: Tue Oct 17, 2023 3:23 pm
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.
Re: Nano System clock gaining time
Posted: Tue Oct 17, 2023 6:54 pm
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.
Re: Nano System clock gaining time
Posted: Tue Oct 17, 2023 9:22 pm
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...
Re: Nano System clock gaining time
Posted: Tue Oct 17, 2023 11:45 pm
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
Re: Nano System clock gaining time
Posted: Wed Oct 18, 2023 7:06 am
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;
}
Re: Nano System clock gaining time
Posted: Wed Oct 18, 2023 9:57 am
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.
Re: Nano System clock gaining time
Posted: Wed Oct 18, 2023 1:41 pm
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?
Re: Nano System clock gaining time
Posted: Mon Oct 23, 2023 8:11 am
by SeeCwriter
The fix works. Should this change be added to the other 5441X modules?