UART not working when external oscillator is removed

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

UART not working when external oscillator is removed

1,547 Views
athmesh_n
Contributor IV

I'm working on LPC1517 custom board. It worked when crystal oscillator was present on the board. After removing the crystal oscillator and selecting IRC as main clock for board, the UART is not working, 

NOTE: The main clock now after debug is 72 MHz.

             BRG value obtained for 115200 bauds is 39. 

             Used main clock rate as base for UART baud rate divider  

What modifications must be done in UART, for its working?

IDE : MCUXpresso

Controller : LPC1517

Thanks and Regards,

Athmesh Nandakumar

lpc1517‌uart clock‌ external oscillator‌

Labels (3)
7 Replies

1,299 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi ATHMESH NANDAKUMAR,

    Do you test the main clock after you select the IRC as the clock source?

    You can configure these register to output the main clock and test it at first:

   pastedImage_1.png

pastedImage_2.png

Just make sure the main clock is really 72Mhz .

If it is really 72Mhz, then you can refer to the LPCopen uart_rb project, which can be downloaded from this link:

 LPCOpen Software for LPC15XX|NXP 

pastedImage_4.png

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,299 Views
athmesh_n
Contributor IV

Hi Kerry, 

I checked as you said. There's no 72MHz out on the clock. 

0 Kudos
Reply

1,299 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi ATHMESH NANDAKUMAR,

     What the clockout code you have wrote? Maybe your clkout code also have problems.

     Please check following code, my system clock is 72Mhz, and I use PIO1_0 pin to output the system clock.

   

          Chip_SWM_Init();
     Chip_GPIO_Init(LPC_GPIO);

     /* Setup pin as CLKOUT */
     Chip_SWM_MovablePortPinAssign(SWM_CLK_OUT_O, 1, 0);

     /* Configure as a digital pin with no pullups/pulldowns */
     Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 0, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));                          
        LPC_SYSCTL->CLKOUTSEL[0] = 3;
     LPC_SYSCTL->CLKOUTSEL[1] = 0;
        LPC_SYSCTL->CLKOUTDIV = 1;‍‍‍‍‍‍‍‍‍‍‍

Then this is the test result:

pastedImage_1.png

You can find it is about 72Mhz.

So, please double check your clock out code again, I test it based on the lpcopen code, actually, the lpcopen code also have a periph project named as clkout, you also can refer to it.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,299 Views
athmesh_n
Contributor IV

Hi kerryzhou‌,

Thank you for the code snippet. 

I got the following output with frequency 72.29MHz.

DSO00002.png

0 Kudos
Reply

1,299 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi ATHMESH NANDAKUMARK,

    That's good, it means your main clock works OK with 72Mhz, now, please refer to the lpcopen uart_rb code to configure your UART, then test it again.

    If you still have problems, please let me know, and tell me what the UART module and the pins you want to use.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,299 Views
athmesh_n
Contributor IV

Thank You kerryzhou

0 Kudos
Reply

1,299 Views
athmesh_n
Contributor IV

Hi Kerry,

during startup, the code is initalized to irc.  This is the startup code:

void Chip_SetupIrcClocking(void)
{
 volatile int i;
 /* Powerup main IRC (likely already powered up) */
 Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_IRC_PD);
 Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_IRCOUT_PD);
 /* Set system PLL input to IRC */
 Chip_Clock_SetSystemPLLSource(SYSCTL_PLLCLKSRC_IRC);
 /* Power down PLL to change the PLL divider ratio */
 Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_SYSPLL_PD);
 /* Setup PLL for main oscillator rate (FCLKIN = 12MHz) * 6 = 72MHz
    MSEL = 5 (this is pre-decremented), PSEL = 1 (for P = 2)
    FCLKOUT = FCLKIN * (MSEL + 1) = 12MHz * 6 = 72MHz
    FCCO = FCLKOUT * 2 * P = 72MHz * 2 * 2 = 288MHz (within FCCO range) */
 Chip_Clock_SetupSystemPLL(5, 2);
 /* Powerup system PLL */
 Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_SYSPLL_PD);
 /* Wait for PLL to lock */
 while (!Chip_Clock_IsSystemPLLLocked()) {}
 /* Set system clock divider to 1 */
 Chip_Clock_SetSysClockDiv(1);
 /* Setup FLASH access timing for 72MHz */
 Chip_FMC_SetFLASHAccess(SYSCTL_FLASHTIM_72MHZ_CPU);
 /* Set main clock source to the system PLL. This will drive 72MHz
    for the main clock */
 Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_SYSPLLOUT);
}
So basically PLL is used with IRC as source. Systick is working without any problem. UART and other peripherals are not responding.

pastedImage_2.png

Should pinassign be done for IRC clock?

0 Kudos
Reply