GP32 Gpclockspeedchange During App


foft

Certified Guru
Joined
Mar 14, 2004
Messages
480
Location
London, UK
Website
www.scrameta.net
I'm trying to add a menu to change clock speed in the atari800 port. However...

It seems that GpClockSpeedChange does not update the timers or sound properly. I have found some partial fixes to these, but I'm obviously still missing some important parts... BTW I do know about the RTC, but its just not accurate enough and does not solve all the issues:)

Timers:
These all seem to be driven off one central hardware timer. The sdk only seems to have a different prescaler when started with different clocks. I adjusted the prescaler as follows following the call to GpClockSpeedChange:
unsigned int prescaler0 = (pclk/(8000*40))-1;
rTCFG0 = (rTCFG0&0xFFFFFF00)|prescaler0;
This seems to work when I start in 166 and go to any mode. However if I start in 156 it is off by a factor of two. Does anyone know where the additional multiplier comes from?

The SDK also seems to set up rTCNTB4 as follows. In my notes I say this is for GpTickCountGet, however I'm not sure if the above change already fixed that...
rTCNTB4 = pclk/1600;

Anyway with both these changes (+chatboard reinit) the emulator then runs at the correct speed.

Sound:
This sounds horrible after changing clock speed - wrong frequency and continual short gaps. It seems this is not handled by the main processor chip itself, but is controlled by the IIS? I found that making the following changes made the sound correct, but there is masses of interference. Presumably something else needs setting up? Anyone know what and how?
if (clock==GPMHZ_165)
{
rIISMOD=0x8d;
rIISPSR=0x84;
}
if (clock==GPMHZ_132)
{
rIISMOD=0x89;
rIISPSR=0x16b;
}

Any help gratefully appreciated!

Thanks,

Mark
 
foft posted on Sep 12 2004 at 05:01 PM said:
I'm trying to add a menu to change clock speed in the atari800 port. However...

[snip-sanp]

The SDK also seems to set up rTCNTB4 as follows. In my notes I say this is for

[snip-snap]


If you are using SDK for sound, timers & display and so I wouldn't recommend poking around hardware regs to fix situations like this. Just reinit sound, display and timers using initializing functions provided by the SDK. And depending on the chatboard driver you use, reinit it "somehow" ;)

After changing clockspeed also PCLK & HCLK change -- in most cases. Sound, timers & serial depend on the PCLK. Display depends on the HCLK.

One way out of this is to use such clockspeed settings that do not change HCLK or PCLK but it might be a quite limiting.
 
Last edited by a moderator:
If you are using SDK for sound, timers & display and so I wouldn't recommend poking around hardware regs to fix situations like this. Just reinit sound, display and timers using initializing functions provided by the SDK.
Is there another SDK function to do this? Setting timer opts again and restarting them does not work. Nor does stopping and restarting sound. I tried _gp_init_sdk again but that froze iirc.

Obviously it would all be much easier if there is just an SDK function :D

And depending on the chatboard driver you use, reinit it "somehow" ;)
I think its your "example" driver :) Looks like its simple to reinit, though I've not tried it yet.

After changing clockspeed also PCLK & HCLK change -- in most cases. Sound, timers & serial depend on the PCLK. Display depends on the HCLK.
I managed to get sound working again by re-initting the 1330 again, as per your code in Mirko's sdk. I hadn't though about display though since it just worked. Maybe the SDK fixes that properly anyway - I'll have to take a look. I could be driving it at some scary frequencies.

With the clock settings I'm using PCLK varies by up to 60%. Not checked HCLK yet.

Thanks for the help,

Mark
 
Back
Top