UART Clock divider

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

UART Clock divider

1,797 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Muis on Mon Jan 21 09:53:47 MST 2013
My system is running at 12Mhz, and to get 115200 baud I use the following code:

int dlEest = 4;
int mulVal = 8;
int ClockVal = 1;
int divAddVal = 5;

LPC_SYSCON->UARTCLKDIV = ClockVal;

LPC_USART->DLM = dlEest / 256;
LPC_USART->DLL = dlEest % 256;
LPC_USART->FDR = (mulVal<<4)|divAddVal;


And this works perfectly. Now to save power I want to make the clock divider higher. So I change ClockVal tot 4 and calculated that dlEest becomes 1. However UART stops functioning with that. What am Im doing wrong?
0 Kudos
Reply
4 Replies

1,613 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Muis on Tue Jan 22 00:31:53 MST 2013

Quote: MikeSimmonds
[FONT=Tahoma][SIZE=1]
You don't say what device you are using, but I can tell that it is not the same as mine.
[/SIZE][/FONT]



It's a LPC11U35, and aside for the difference that the UART register is called LPC_USART it's UART should be very similar to your LPC1768.


Quote: MikeSimmonds
[FONT=Tahoma][SIZE=1]
Are you running on the internal RC oscillator, they are not always 100% accurate.
[/SIZE][/FONT]



Yes. But its accuracy (1%) should be enough for UART, and as long as I dont use the clock divider, everything is fine.


Quote: MikeSimmonds
[FONT=Tahoma][SIZE=1]
Do you have to change other dividers (peripheral clock).
[/SIZE][/FONT]



I believe the LPC11xx series dont have a dedicated peripheral clock. You can specify dividers for individual peripherals, but there is not global divider as far as I know.
0 Kudos
Reply

1,613 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Mon Jan 21 15:45:40 MST 2013
[FONT=Tahoma][SIZE=1]Sorry, I missed the fact that the numbers were the same.
You don't say what device you are using, but I can tell that it is not the same as mine.

Are you running on the internal RC oscillator, they are not always 100% accurate.

Do you have a scope, and can you set (and enable the pin) for clk out to measure it.

Do you have to change other dividers (peripheral clock).

These are just rambling as I am not familiar with non 1700 devices.

Regards, Mike

[/SIZE][/FONT]
0 Kudos
Reply

1,613 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Muis on Mon Jan 21 12:22:01 MST 2013
Hi Mike,

That are exactly the same numbers I got when changing dllEst into 1 in the above example. But for some reason UART doesnt work anymore with those values. I recall that I read somewhere that the clock gets less accurate when using the CLKDIV divider, which would explain the problem. But maybe someone can confirm/debunk that.
0 Kudos
Reply

1,613 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Mon Jan 21 11:31:22 MST 2013
[FONT=Tahoma][SIZE=1]Since your clock into the Uart[/SIZE][/FONT][FONT=Tahoma][SIZE=1] is now effectivly 3MHz [12/4] you need
new numbers for DLM/DLL/FDR.

Try
UDLM [dec]         0
UDLL [dec]          1
DivAddVal [dec]   5
MulVal [dec]        8

I got these numbers from an Excel sheet on the NXP site

[/SIZE][/FONT][FONT=Tahoma][SIZE=1]http://ics.nxp.com/support/documents/microcontrollers/xls/lpc2000.uart.baudrate.calculator.xls[/SIZE][/FONT][FONT=Tahoma][SIZE=1]

It says LPC2000, but it is good for any MCU with the same uart type :)

Hope this will help you

Mike

[/SIZE][/FONT][FONT=Tahoma][SIZE=1]
[/SIZE][/FONT]
0 Kudos
Reply