Using SYSCTL_PLLCLKSRC_RTC32K to set clock to 32KHz

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

Using SYSCTL_PLLCLKSRC_RTC32K to set clock to 32KHz

Jump to solution
1,221 Views
safarmer
Contributor II


Hi All,

I am currently looking at using the RTC 32KHz oscillator on an LPC11u68 to run the main clock and when I switch the system PLL source to SYSCTL_PLLCLKSRC_RTC32K the system hangs and I need to use ISP reset to clear the device to reconnect. I have initially got the system running off an external oscillator (also works from IRC oscillator) and then when I try to switch to the slow clock things break.

 

I am using the LPCOpen library with the following code to switch the main clock:

Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_RTC); Chip_Clock_EnableRTCOsc(); Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_PLLIN); Chip_Clock_SetSystemPLLSource(SYSCTL_PLLCLKSRC_RTC32K);

 

I am using the call to void Chip_SetupXtalClocking(void) to set the initial clock (that seems to work fine).

Is there something I am missing? According to the datasheet, this is all I need to do to use the RTC 32 KHz oscillator for the system clock.

 

Cheers,

Shane

Labels (2)
Tags (1)
0 Kudos
1 Solution
895 Views
isaacavila
NXP Employee
NXP Employee

Hello Shane,

What board are you using? It should be working with those lines that you added. I took periph_clkout example from LPCOpen (LPCXpresso 11u68 Board Rev C) and made next modifications on main function:

SystemCoreClockUpdate();

    Board_Init();

    Board_LED_Set(0, false);

    /* Enable clock for RTC */

    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_RTC);

    Chip_Clock_EnableRTCOsc();

    Chip_Clock_SetSystemPLLSource(SYSCTL_PLLCLKSRC_RTC32K);

    Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_PLLIN);

    /* Enable and setup SysTick Timer at a 100Hz rate */

    SysTick_Config(SystemCoreClock / 100);

    /* WDT oscillator freq = 0.6MHz divided by 64 = 9.375khz */

    Chip_Clock_SetWDTOSC(WDTLFO_OSC_0_60, 64);

    /* Enable the power to the WDT */

    Chip_SYSCTL_PowerUp(SYSCTL_SLPWAKE_WDTOSC_PD);

    /* Configure PIN0.1 for CLKOUT */

    Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 1, IOCON_FUNC1);

    /* Setup CLKOUT pin for specific clock with a divider of 1 */

    Chip_Clock_SetCLKOUTSource(SYSCTL_CLKOUTSRC_MAINSYSCLK, 1);

    while (1) {

    }

Then, I was able to measure the 32.768 kHz on P0.1 pin:

2016-08-03_15-40-00.jpg

So you can give a try to do same modifications on periph_clkout example.

Hope it helps!

Regards,

Isaac

View solution in original post

1 Reply
896 Views
isaacavila
NXP Employee
NXP Employee

Hello Shane,

What board are you using? It should be working with those lines that you added. I took periph_clkout example from LPCOpen (LPCXpresso 11u68 Board Rev C) and made next modifications on main function:

SystemCoreClockUpdate();

    Board_Init();

    Board_LED_Set(0, false);

    /* Enable clock for RTC */

    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_RTC);

    Chip_Clock_EnableRTCOsc();

    Chip_Clock_SetSystemPLLSource(SYSCTL_PLLCLKSRC_RTC32K);

    Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_PLLIN);

    /* Enable and setup SysTick Timer at a 100Hz rate */

    SysTick_Config(SystemCoreClock / 100);

    /* WDT oscillator freq = 0.6MHz divided by 64 = 9.375khz */

    Chip_Clock_SetWDTOSC(WDTLFO_OSC_0_60, 64);

    /* Enable the power to the WDT */

    Chip_SYSCTL_PowerUp(SYSCTL_SLPWAKE_WDTOSC_PD);

    /* Configure PIN0.1 for CLKOUT */

    Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 1, IOCON_FUNC1);

    /* Setup CLKOUT pin for specific clock with a divider of 1 */

    Chip_Clock_SetCLKOUTSource(SYSCTL_CLKOUTSRC_MAINSYSCLK, 1);

    while (1) {

    }

Then, I was able to measure the 32.768 kHz on P0.1 pin:

2016-08-03_15-40-00.jpg

So you can give a try to do same modifications on periph_clkout example.

Hope it helps!

Regards,

Isaac