I'm working on writing board initialization code and I'm running into an issue where the PLL value won't take effect. My init code is based on code from a GEL file and the PLL documentation. I've posted my code below.
/*
* PLL1 initialization function
* CLKIN1 = 50MHz
* CLKIN2 = 25MHz
* AECLKIN = 160MHz - EMIF CLK
*
* PLLOUT = 1200MHz
* SYSCLK2 = 400MHz
* SYSCLK3 = 200MHz
* SYSCLK4 = 150MHz
* SYSCLK5 = 300MHz
*/
void init_pll(void)
{
int i;
volatile int tmp;
for(i=0 ; i<5000 ; i++)
tmp = i;
/* In PLLCTL, write PLLEN = 0 (bypass mode).*/
PLLCTL_1 &= ~(0x00000001);
/* Wait 4 cycles of the slowest of PLLOUT or reference clock source (CLKIN).*/
for (i=0 ; i<100 ; i++)
tmp = i;
/*In PLLCTL, write PLLRST = 1 (PLL is reset).*/
PLLCTL_1 |= 0x00000008;
/*If necessary, program PREDIV and PLLM.*/
PLLM_1 = 24-1;
PREDIV_1 = 0x00008000;
/* Wait for PLL to properly reset.(128 CLKIN1 cycles).*/
for (i=0 ; i<1000 ; i++)
tmp = i;
/* In PLLCTL, write PLLRST = 0 to bring PLL out of reset.*/
PLLCTL_1 &= ~(0x00000008);
/* Wait for PLL to lock (2000 CLKIN1 cycles). */
for (i=0 ; i<4000 ; i++)
tmp = i;
/* In PLLCTL, write PLLEN = 1 to enable PLL mode. */
PLLCTL_1 |= (0x00000001);
}
After this is run the chip is still running at 50MHz. This is running on a custom board. Is there another method to init the pll when running directly on the chip? Any help is greatly appreciated.
Thanks, Andrew