I'm porting code from an LPC1768 to an LPC1817 and have a problem that the UART is running at the wrong speed. All the old code looks sane and from what I can read in the documentation the registers in the 18xx should be pretty much directly compatible with the 17xx.
So to figure out what's going on I wrote some raw C testcode that access the registers directly just to verify that the MCU and I are on the same page, but apparently we're not. This is the raw testcode:
*((volatile uint32_t *) 0x40086100) = 0xf1; // Set up P2_0
*((volatile uint32_t *) 0x40086104) = 0xf1; // Set up P2_1
*((volatile uint32_t *) 0x40051508) = 0x07; // Enable UART0 clock (should already be enabled)
*((volatile uint32_t *) 0x4008100C) = 0x83; // Set DLAB in LCR
*((volatile uint32_t *) 0x40081000) = 6; // Set low byte divider
*((volatile uint32_t *) 0x40081004) = 7; // Set high byte divider
*((volatile uint32_t *) 0x40081028) = 0x10; // Set fraction divider
volatile uint32_t uart0_lcr = *((volatile uint32_t *) 0x4008100C);
volatile uint32_t uart0_dll = *((volatile uint32_t *) 0x40081000);
volatile uint32_t uart0_dlm = *((volatile uint32_t *) 0x40081004);
volatile uint32_t ccu1_pm = *((volatile uint32_t *) 0x40051000);
volatile uint32_t ccu1_base_stat = *((volatile uint32_t *) 0x40051004);
volatile uint32_t ccu1_usart0_cfg = *((volatile uint32_t *) 0x40051508);
volatile uint32_t ccu1_usart0_stat = *((volatile uint32_t *) 0x4005150c);
volatile uint32_t ccu2_pm = *((volatile uint32_t *) 0x40052000);
volatile uint32_t ccu2_base_stat = *((volatile uint32_t *) 0x40052004);
volatile uint32_t ccu2_usart0_cfg = *((volatile uint32_t *) 0x40052500);
volatile uint32_t ccu2_usart0_stat = *((volatile uint32_t *) 0x40052504);
Aaaand it doesn't work. When I check the values they all look sane, except for dll and dlm that still have their reset values of 1 versus 0. Clearly I'm missing something that probably is very obvious when you see it, but I've been trying to figure out what for a few days and I'm pretty much stuck. And the UART still run at the wrong speed and changing the dividers make no difference (verified with oscilloscope).
So if anyone could throw a quick look at this and tell me what I'm missing I'd be very grateful.
Regards
/M