GP32 Old Question: How Many Ticks Are 1 Second ?


ConsoleTom

Member
Joined
Dec 4, 2003
Messages
106
Age
48
Location
Germany
Website
Visit site
Hi !

Can anyone tell me, how many ticks are 1 second ?

I need it for the speed of 133 mhz,100 mhz and 66 mhz.

Could you also tell me the values that are needed for GpClockSpeedChange ?

Greetingx

Tobias

PS. Perhaps this question or the correct answers should be pinned ?
 
you get 1000 ticks in a second on the default clock speed, just re-calculate that accordingly for higher clock speeds.
 
Pirotic posted on Oct 19 2004 at 08:42 PM said:
you get 1000 ticks in a second on the default clock speed, just re-calculate that accordingly for higher clock speeds.

What is the default speed ? 40 or 66 ?

Recalculate ? For example Clockspeed x 2 -> Ticks x 2 ?

Tobias
 
Last edited by a moderator:
ConsoleTom posted on Oct 19 2004 at 10:35 PM said:
What is the default speed ? 40 or 66 ?

67.8MHz.. but you really can't count on that without setting it in your
own program.
 
Last edited by a moderator:
Not sure if this code is of any help... its the main loop timer i use in my projects:

Code:
void GpMain(void *arg)
{
  Engine_Init(); //start up and load first map

   //Work out the speedup
   speed_up = ((1 * clock_speed) / clock_speed_default);

  double last_draw;
  int interval;
  interval = (1000 * speed_up) / FRAMELOCK; // take into account overclocking
  last_draw = GpTickCountGet();

  while(1)
	{
  //if its time for next frame.. (tab this out for unrestricted)
  if (GpTickCountGet() - last_draw >= interval) {
	
  	//next step
  	last_draw = GpTickCountGet();
  	Engine_MainLoop(); //Draw a frame!
  }
	}

GpAppExit();
 
This is what I do to change clock speed. Then all the timers/etc seem to work as usual. Course I'm told that this is a bad idea by Spiv, but doesn't anyone have anything better?

Code:
	int freq=0;
	int magic=0;
	int div=0;
	
	if (clock == gp32ClockEnum)
  return;
	clock &= 0x7f;
	gp32ClockEnum = clock;
	if (clock > gp32ClockEnumMax)
  gp32ClockEnumMax = clock;

	switch(clock)
	{
//	case GPMHZ_40: GpClockSpeedChange (40000000, 0x48013, 1); break;
//	case GPMHZ_59: GpClockSpeedChange (59250000, 0x47022, 1); break;
	case GPMHZ_67: freq=67500000; magic=0x25002; div=1; break; 
	case GPMHZ_80: freq=80000000; magic=0x48012; div=1; break;
	case GPMHZ_99: freq=99000000; magic=0x3a002; div=2; break;
	case GPMHZ_115: freq=115500000; magic=0x45021; div=2; break; 
	case GPMHZ_132: freq=132000000; magic=0x24001; div=2; break;
	case GPMHZ_156: freq=156000000; magic=0x2c001; div=3; break;
	case GPMHZ_165: freq=165000000; magic=0x2f001; div=3; break;
	case GPMHZ_180: freq=180000000; magic=0x34001; div=3; break;
	default:exit(0);
	}

	GpClockSpeedChange(freq, magic, div);
	Aprint("Clock M:%d H:%d P:%d\n", GpMClkGet(), GpHClkGet(), GpPClkGet());
	unsigned int pclk = GpPClkGet();

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

	// Repair GpTickCountGet
	// pclk/(100x) = 16
	// x = pclk/1600
	rTCNTB4 = pclk/1600;
 //	rTCON  = (0x1<<22) | (0x1<<20);

	// Repair display - driven off hclk
	// HMM - looks like the sdk doesn't tweak clkval and I can't find anything else. Worst case we'll get < 2x lcd framerate (49.. vs 80 hck)

	// Repair sound
#ifdef STEREO
	GpPcmInit(PCM_S22, PCM_8BIT);
#else
	GpPcmInit(PCM_M22, PCM_8BIT);
#endif

	// Repair chatboard
	preInitKbd(9600, GpPClkGet());
 
Back
Top