GP32 Keeping Real Time


pea

developer
Joined
Oct 3, 2004
Messages
1,089
Age
46
Location
New Zealand
Website
www.projectitis.com
Hi all,

I need to keep accurate time at better resolution than 1/64 second (available with RTC). Perhaps up to 1/200 of a second. Any ideas?

Cheers,
Peter
 
pea posted on Oct 21 2005 at 04:02 AM said:
Hi all,

I need to keep accurate time at better resolution than 1/64 second (available with RTC). Perhaps up to 1/200 of a second. Any ideas?

Cheers,
Peter

use a timer (cf s3c2400 Refernce Manual)
 
Last edited by a moderator:
With GPSDK, you can solve the bugs with GpClockSpeedChange(). Then you can use GpTickCountGet() accurately to get milliseconds:

void gpClockSpeedChange(int freq, int magic, int div)
{
#define rTCFG0 (*(volatile unsigned *)0x15100000)
#define rTCFG1 (*(volatile unsigned *)0x15100004)
#define rTCNTB4 (*(volatile unsigned *)0x1510003c)
unsigned int pclk;
unsigned int prescaler0;

/* Change CPU Speed */
GpClockSpeedChange(freq, magic, div);
pclk = GpPClkGet();

/* Repair SDK timer - it forgets to set prescaler */
prescaler0 = (pclk/(8000*40))-1;
rTCFG0 = (rTCFG0&0xFFFFFF00)|prescaler0;
rTCFG1 = 0x30033;

/* Repair GpTickCountGet */
rTCNTB4 = pclk/1600;
}
 
Basically they're saying to count CPU ticks/cycles rather than use the RTC.
Arrghh, I don't like low-level stuff, thats why I like SDL.
 
Back
Top