2 // xtal_freq = 12000000;
5 scs = (int *)0x400fc1a0;
6 // enable main oscillator
9 // wait for oscillator to get ready
10 while ((*scs & (1<<6)) == 0);
12 volatile int *cclkcfg;
13 cclkcfg = (int *)0x400FC104;
14 // set clockdivider to 1/4x
17 // peripheral clocks (all set to 1/4x cclk)
18 volatile int *pclksel0, *pclksel1;
19 pclksel0=(int *)0x400FC1A8;
21 pclksel1=(int *)0x400FC1AC;
24 // main clock set (pll0)
25 volatile int *clksrcsel;
26 clksrcsel = (int *)0x400FC10C;
29 volatile int *pll0con, *pll0stat, *pll0feed, *pll0cfg;
30 pll0con=(int*)0x400FC080;
31 pll0stat=(int *)0x400FC088;
32 // pll0feed : feed 0xAA followed by 0x55 to feed
33 pll0feed=(int *)0x400FC08C;
34 pll0cfg=(int *)0x400FC084;
36 // FORMULA = FCCO = (2 * M * FIN) / N
37 // as Xtal (FIN) is 12MHz, N = 6 , M = 25 gives 100 MHz
38 // as both msel and nsel stores "N-1" store 24 and 5
39 *pll0cfg = 24 | (5 << 16);
52 while (!(*pll0stat & (1<<26)));
60 while (!(*pll0stat & ((1<<25) | (1<<24))));
62 volatile int *pll1con, *pll1cfg, *pll1stat, *pll1feed;
63 pll1con=(int *)0x400FC0A0;
64 pll1cfg=(int *)0x400FC0A4;
65 pll1stat=(int *)0x400FC0A8;
66 pll1feed=(int *)0x400FC0AC;
68 // setup pll1 (multiplier 4, divider 6)
69 *pll1cfg = 3 | (0x01 << 5);
75 while (!(*pll1stat & (1<<10)));
81 while (!(*pll1stat & ((1<< 9) | (1<< 8))));