2
\$\begingroup\$

I'm trying to get acquainted with ARMs on example of LPC1110 device. And there is some confusion about selecting baud rate for UART.

I suppose it is running at 12MHz after reset. The LPC111x manual (pdf) says that I should set UARTCLKDIV first (as I understand, it is pre-divisor for UART clock). I set it to 1. So I think UART_PCLK = 12MHz

Now I need to load divisor to 16-bit latch U0DLM:U0DLL. Manual says that

baud rate = UART_PCLK / (16 * divisor)

There is also fractional divisor adjuster, but I think I do not use it.

So the code looks like this:

int divisor = 12000000 / (16 * 9600);
UARTCLKDIV = 1;
U0LCR = 0x83; // enable divisor loading
U0DLM = divisor >> 8; // divisor high byte
U0DLL = divisor & 0xFF; // divisor low byte
U0LCR = 0x03; // disable divisor loading
U0FCR = 0x07;

And wonderfully this do not work, i.e. I see the mess in terminal. After some googling and experiments I've found that it will work all right if I change the first line to 48MHz:

int divisor = 48000000 / (16 * 9600);

So I supposed PLL could be enabled - but as I read the manual I came to conclusion it is not. After reset main clock should work directly from internal RC oscillator. And I use value 12000000 MHz when burning firmware with mxli tool.

What may I miss here?

P.S. Code example #3 from here do not use 16-bit divisor, instead loading 0x9B (155) to UARTCLKDIV. They say this gets 19200 baud rate which means they also run at about 47.6 MHz (as I understand).

\$\endgroup\$
1
\$\begingroup\$

I'm sorry, that was my mistake. After debugging control addresses values I've found PLL is on. After some more research I've found it was turned on in initialization module I've attached to my project. I turned it off and all works with just as expected.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.