Chip_Clock_IsUSBPLLLocked hangs when IRC is turned off

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Chip_Clock_IsUSBPLLLocked hangs when IRC is turned off

Jump to solution
710 Views
A_L
Contributor I

We use external 16MHz crystal oscillator for LPC11U68JBD48E clock:

unsigned int j;
SystemCoreClockUpdate();
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);

// start SYSOSC
Chip_IOCON_PinMuxSet(LPC_IOCON, 2, 0, (IOCON_FUNC1 | IOCON_MODE_INACT)); // PIO2_0 = XTALIN
Chip_IOCON_PinMuxSet(LPC_IOCON, 2, 1, (IOCON_FUNC1 | IOCON_MODE_INACT)); // PIO2_1 = XTALOUT
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_SYSOSC_PD);
Chip_Clock_SetPLLBypass(false, false);
for (j = 0; j < 0x400; ++j); // 500us delay is needed after SYSOSC is powered up

// MAINCLK = 64MHz, from PLL
Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_IRC);
Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_SYSPLL_PD);
Chip_Clock_SetSystemPLLSource(SYSCTL_PLLCLKSRC_MAINOSC);
Chip_Clock_SetupSystemPLL(3, 1); // FCLKIN = 16, FCLKOUT = 64, FCCO = 256MHz
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_SYSPLL_PD);
while (!Chip_Clock_IsSystemPLLLocked());
Chip_Clock_SetSysClockDiv(2); // system clock at 32Mhz
Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_PLLOUT);
SystemCoreClockUpdate();

// so far so good, turning off IRC:
Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_IRC_PD);
Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_IRCOUT_PD);

// now lets try set up USB clock:
Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_USBPLL_PD);
Chip_Clock_SetUSBPLLSource(SYSCTL_USBPLLCLKSRC_MAINOSC);
Chip_Clock_SetupUSBPLL(2, 1); // FCLKIN = 16, FCLKOUT = 48, FCCO = 192MHz
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_USBPLL_PD);
while (!Chip_Clock_IsUSBPLLLocked()); // hangs here indefinitely

// and this code is not reached ...
Chip_Clock_SetUSBClockSource(SYSCTL_USBCLKSRC_PLLOUT, 1);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_USB);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_USBRAM);
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_USBPAD_PD);

So, could USB PLL be used when IRC is turned off?

0 Kudos
Reply
1 Solution
686 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Alexei,

It appears that you do not set up the USB PLL Clock source register, pls check.

Hope it can help you

BR

XiangJun Rong

 

xiangjun_rong_0-1618191586471.png

 

xiangjun_rong_1-1618191722703.png

 

View solution in original post

0 Kudos
Reply
2 Replies
687 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Alexei,

It appears that you do not set up the USB PLL Clock source register, pls check.

Hope it can help you

BR

XiangJun Rong

 

xiangjun_rong_0-1618191586471.png

 

xiangjun_rong_1-1618191722703.png

 

0 Kudos
Reply
678 Views
A_L
Contributor I

Hi, xiangjun_rong

Thanks, it appears I missed the line in manual: When switching clock sources, both clocks must be running.

When IRC is turned off after USB PLL setup, everything runs ok.

0 Kudos
Reply