Hi all,
I have a LPC824_Xpresso board OM13071 and I would like to output on P0_27 (blue led on the board) the clock produced by the system oscillator.
Firstly I moved the SJ3 and SJ4 to pin 1
Since I would like to understand properly how the registers work, I wrote this function
void output_XTAL(void){
/* power IOCON*/
SYSCON->SYSAHBCLKCTRL|=((0x1<<7) | (0x1<<18));
/* Crystal Oscillator (SYSOSC) setup */
IOCON->PIO[8]&= ~(1<<3)|(1<<4); // remove pullup and pulldown resistor
IOCON->PIO[9]&= ~(1<<3)|(1<<4);
SWM0->PINENABLE0&=~(1<<6)|(1<<7); // XTALIN XTALOUT pin enabled
SYSCON->SYSAHBCLKCTRL&=~((0x1<<7)|(0x1<<18));
SYSCON->SYSOSCCTRL=0x0; // disable the bypass bit
SYSCON->PDRUNCFG &= ~(1<<5); // power on SYSOSC
for(volatile uint32_t i=0; i<200; i++) __NOP(); /* wait */
/* Clockout setup */
SYSCON->CLKOUTSEL=0x1;
SYSCON->CLKOUTDIV=100;
SYSCON->CLKOUTUEN=0;
SYSCON->CLKOUTUEN=1;
/* assign clockout pin */
SYSCON->SYSAHBCLKCTRL|=(1<<7); // Enable SWM clock
SWM0->PINASSIGN_DATA[11]&=~(0xFF<<16); // clear register
SWM0->PINASSIGN_DATA[11]|=(0x1B<<16); // assign CLOCK to pin PIO_27
SYSCON->SYSAHBCLKCTRL&=~(1<<7); // Disable SWM clock
}
However I do not get the SYSOSC clock on PIO_27. If I try to have the IRC oscillator on the same output pin simply changing this SYSCON->CLKOUTSEL=0x0; ....it works.
Do you know why? I am basically doing the operations described below when setting up the SYSOSC
Look forward to your suggestions
best regards
Hello @topspin
How about use Configure tool inside MCUXpresso IDE to config the system oscillator and pins.
Then generated code.
BR
Alice
Dear @Alice_Yang
I would like to write a brand new function to have the the system oscillator on the CLOCKOUT pin.
I do no want to use the code generated by the config tools.
Do you think the function I wrote is correct?
Thanks in advance
Hi @Alice_Yang
I solved the problem. There was an issue in the IOCON configuration