Setting Clock Speeds


Robster

Dodgy hardware mod maker
Joined
Jul 8, 2003
Messages
439
Location
New Zealand
Website
www.cobbleware.com
The clock manager in the MMSP2 is a fairly powerful beastie! 3 independent PLLs with separate prescalers for everything plus most peripheral blocks can connect to any of the PLL sources.

Unfortunately, the datasheet gives no indication of how to determine the numbers but the names of the values (Mdiv, Pdiv, Sdiv) indicates that it's a standard ARM PLL setup... and it is :). That is,
Code:
Fpll = (m * Fin) / (p * s)
where
Fin is the crystal frequency, 7372800Hz
m = Mdiv + 8
p = Pdiv + 2
s = 2 to the power of Sdiv
Under U-Boot, the three main PLLs are set like this:
Code:
Fpll:   Mdiv = 0x49, Pdiv = 0x01, Sdiv = 0x00   F = 199065600Hz
Upll:   Mdiv = 0x60, Pdiv = 0x00, Sdiv = 0x02   F =  95846400Hz
Apll:   Mdiv = 0x98, Pdiv = 0x00, Sdiv = 0x02   F = 147456000Hz
Fpll is used as the 920T and 940T clocks, and is divided by 2 to give the memory clock.
Upll isn't used, but I suspect that at approximately 96MHz it's to be divided by 2 or something for the USB peripheral.
Apll is used for the serial port, with an initial divider of 10, a fixed divider of 16, and a programmable divider of 8 to give the final 115200bps speed.

I've trivially modified the trusty old "pllset" program to give Mdiv, Pdiv, Sdiv values for the MMSP2, I'm going to try changing the operating frequency soon and if it works I'll (really, really, really) write all this up properly.

It's a pity that MagicEyes haven't given us any idea what the maximum allowed VCO frequency is for the PLLs, but I'll do some experiments and we might get some sort of idea.
 
Robster posted on Oct 26 2005 at 09:16 AM said:
It's a pity that MagicEyes haven't given us any idea what the maximum allowed VCO frequency is for the PLLs, but I'll do some experiments and we might get some sort of idea.

I await the pop and dead dev board with intererest.

Seirously, setting the clock on a per-app basis is going to be a godsend.
 
Last edited by a moderator:
Setting the VCO to something it can't achieve won't pop the CPU, it'll just run slower than you expect. For example, those people who say they've got 220MHz GP32s are running the VCO at 440MHz, when it's documented that the maximum for the S3C2400 is 330MHz. So they're really running at around 166MHz, I just haven't had the energy to pop their bubbles :)

Anyway, for the APLL in the standard GP2X setup the VCO frequency is a shade under 600MHz, so we can assume the MMSP2 maximum is somewhere above that.

Here is pllset for the MMSP2, it should compile on anything. The 3 PLLs are all the same.

I've changed the "recommendations" at the bottom. For some reason the S3C2400 recommends Mdiv should be no higher than 0x4C or something, the standard GP2X setup has Mdiv for APLL at 0x98, so I guess that's OK too :). In general, take the settings from a line where OK == 1.
 
I always find quite annoying to look for the best values, so I've slighty modified pllset.c to show some suggested values, like this example:

Code:
13:04 28/10/2005 [3.4.2][WIN32_GCC] M:\tools\gp2x>pllset 200000000
     +---------------------------------------+
     | PLL VALUE CALCULATOR  Ver 1.something |
     | Fixed for MMSP2                       |
     +---------------------------------------+
Input XTAL0 Freq:7372800
Output MCLK Freq:200000000
 M  , P , S  | MCLK      | fvco | fi/P+2 | PAR1 < PAR2 < PAR3 | OK | PAR4 |
 D1h, 0h, 2h | 199987200 | 799M |   3.7M |  0.1 |  0.1 |  0.4 | 0  |  0.4 |
 65h, 0h, 1h | 200908800 | 401M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.6 |
 9Bh, 1h, 1h | 200294400 | 400M |   2.5M |  0.1 |  0.1 |  0.2 | 1  |  0.5 |
 D1h, 2h, 1h | 199987200 | 399M |   1.8M |  0.1 |  0.1 |  0.2 | 0  |  0.4 |
 2Eh, 0h, 0h | 199065600 | 199M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 49h, 1h, 0h | 199065600 | 199M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 65h, 2h, 0h | 200908800 | 200M |   1.8M |  0.1 |  0.2 |  0.2 | 1  |  0.6 |
 80h, 3h, 0h | 200540160 | 200M |   1.5M |  0.1 |  0.1 |  0.1 | 1  |  0.6 |
 9Bh, 4h, 0h | 200294400 | 200M |   1.2M |  0.0 |  0.1 |  0.1 | 1  |  0.5 |
 B6h, 5h, 0h | 200118857 | 200M |   1.1M |  0.0 |  0.1 |  0.1 | 0  |  0.5 |
 D1h, 6h, 0h | 199987200 | 199M |   0.9M |  0.0 |  0.1 |  0.1 | 0  |  0.4 |
 ECh, 7h, 0h | 199884800 | 199M |   0.8M |  0.0 |  0.1 |  0.1 | 0  |  0.4 |

Selection Guide: choose the nearest one to this guide
 1) large SDIV value
 2) OK == 1
 3) 0.7 < PAR4 < 1.8
 4) fvco < 750M

Suggested values:

 M  , P , S  | MCLK      | fvco | fi/P+2 | PAR1 < PAR2 < PAR3 | OK | PAR4 |
 2Eh, 0h, 0h | 199065600 | 199M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 49h, 1h, 0h | 199065600 | 199M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |


Here you have my pllset.c and pllset.exe

Kudos to spiv & rob :)
 
btw, got bored & started modifing my pllset once again to include ranges

here you have a nice list to cheat someday with it :)

notice that all these values are probably valid and fully working unless the system crashes due to the high speed, obviously :)

Code:
13:34 29/10/2005 [3.4.2][WIN32_GCC] M:\tools\gp2x>pllset 200000000 800000000
     +---------------------------------------+
     | PLL VALUE CALCULATOR  Ver 1.something |
     | Fixed for MMSP2                       |
     +---------------------------------------+

Suggested values:

 M  , P , S  | MCLK      | fvco | fi/P+2 | PAR1 < PAR2 < PAR3 | OK | PAR4 |
 2Eh, 0h, 0h | 199065600 | 199M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 49h, 1h, 0h | 199065600 | 199M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 4Ah, 1h, 0h | 201523200 | 201M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 2Fh, 0h, 0h | 202752000 | 202M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 4Ah, 1h, 0h | 201523200 | 201M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 2Fh, 0h, 0h | 202752000 | 202M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 4Bh, 1h, 0h | 203980800 | 203M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 4Bh, 1h, 0h | 203980800 | 203M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 30h, 0h, 0h | 206438400 | 206M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 4Ch, 1h, 0h | 206438400 | 206M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 30h, 0h, 0h | 206438400 | 206M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 4Ch, 1h, 0h | 206438400 | 206M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 4Dh, 1h, 0h | 208896000 | 208M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 4Dh, 1h, 0h | 208896000 | 208M |   2.5M |  0.1 |  0.2 |  0.2 | 1  |  0.7 |
 31h, 0h, 0h | 210124800 | 210M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 31h, 0h, 0h | 210124800 | 210M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 32h, 0h, 0h | 213811200 | 213M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 32h, 0h, 0h | 213811200 | 213M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.9 |
 33h, 0h, 0h | 217497600 | 217M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 33h, 0h, 0h | 217497600 | 217M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 34h, 0h, 0h | 221184000 | 221M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 34h, 0h, 0h | 221184000 | 221M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 35h, 0h, 0h | 224870400 | 224M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 35h, 0h, 0h | 224870400 | 224M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 36h, 0h, 0h | 228556800 | 228M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 36h, 0h, 0h | 228556800 | 228M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 37h, 0h, 0h | 232243200 | 232M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 37h, 0h, 0h | 232243200 | 232M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 38h, 0h, 0h | 235929600 | 235M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 38h, 0h, 0h | 235929600 | 235M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 39h, 0h, 0h | 239616000 | 239M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 39h, 0h, 0h | 239616000 | 239M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 3Ah, 0h, 0h | 243302400 | 243M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 3Ah, 0h, 0h | 243302400 | 243M |   3.7M |  0.1 |  0.3 |  0.4 | 1  |  0.8 |
 3Bh, 0h, 0h | 246988800 | 246M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 3Bh, 0h, 0h | 246988800 | 246M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 3Ch, 0h, 0h | 250675200 | 250M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 3Ch, 0h, 0h | 250675200 | 250M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 3Dh, 0h, 0h | 254361600 | 254M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 3Dh, 0h, 0h | 254361600 | 254M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 3Eh, 0h, 0h | 258048000 | 258M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 3Eh, 0h, 0h | 258048000 | 258M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 3Fh, 0h, 0h | 261734400 | 261M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 3Fh, 0h, 0h | 261734400 | 261M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 40h, 0h, 0h | 265420800 | 265M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 40h, 0h, 0h | 265420800 | 265M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 41h, 0h, 0h | 269107200 | 269M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 41h, 0h, 0h | 269107200 | 269M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 42h, 0h, 0h | 272793600 | 272M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 42h, 0h, 0h | 272793600 | 272M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.8 |
 43h, 0h, 0h | 276480000 | 276M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 43h, 0h, 0h | 276480000 | 276M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 44h, 0h, 0h | 280166400 | 280M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 44h, 0h, 0h | 280166400 | 280M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 45h, 0h, 0h | 283852800 | 283M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 45h, 0h, 0h | 283852800 | 283M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 46h, 0h, 0h | 287539200 | 287M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 46h, 0h, 0h | 287539200 | 287M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 47h, 0h, 0h | 291225600 | 291M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 47h, 0h, 0h | 291225600 | 291M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 48h, 0h, 0h | 294912000 | 294M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 48h, 0h, 0h | 294912000 | 294M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 49h, 0h, 0h | 298598400 | 298M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 49h, 0h, 0h | 298598400 | 298M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 4Ah, 0h, 0h | 302284800 | 302M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 4Ah, 0h, 0h | 302284800 | 302M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 4Bh, 0h, 0h | 305971200 | 305M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 4Bh, 0h, 0h | 305971200 | 305M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 4Ch, 0h, 0h | 309657600 | 309M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 4Ch, 0h, 0h | 309657600 | 309M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 4Dh, 0h, 0h | 313344000 | 313M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 4Dh, 0h, 0h | 313344000 | 313M |   3.7M |  0.1 |  0.2 |  0.4 | 1  |  0.7 |
 
Back
Top