LPC824_Xpresso board testing system oscillator using XTALIN and XTALOUT

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

LPC824_Xpresso board testing system oscillator using XTALIN and XTALOUT

182 Views
topspin
Contributor II

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.

topspin_0-1709640001876.png

Firstly I moved the SJ3 and SJ4 to pin 1

topspin_1-1709640033748.png

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

topspin_2-1709640290688.png

 

Look forward to your suggestions

 

best regards

 

0 Kudos
3 Replies

172 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @topspin 

 

How about use Configure tool inside MCUXpresso IDE to config the system oscillator and pins.

Then generated code.

Alice_Yang_1-1709711231460.png

 

Alice_Yang_0-1709711182509.png

 

BR

Alice

0 Kudos

168 Views
topspin
Contributor II

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

0 Kudos

160 Views
topspin
Contributor II

Hi @Alice_Yang 

I solved the problem. There was an issue in the IOCON configuration 

0 Kudos