I have an LPC-H2148 header board with the system clock running off of a 12 MHz external crystal. I’d like to recreate an LPC2138 project that is based on schematic with a 14.7456 MHz external crystal. With the exception of the external crystal and the uC, my hardware set up is exactly the same. As I understand, the LPC2148 is essentially an LPC2138 with some built in USB capabilities (which is not implemented for this project).
The only peripheral used is on UART0. I am very new to microcontrollers, and I think I only need to make changes to the parts of the project code shown below:
// OLD clock setup with 14.7456 MHz crystal
// Fosc = 14.7456 MHz, M=4 (MSEL bits = 0011), P=2(PSEL bits =01)
// CCLK = Fosc * M = 58.9824 MHz; Fcco = CCLK*2*P = 235.9296 MHz
PLLCFG=0x23;
// NEW clock setup with 12.0000 MHz crystal
// Fosc = 12.0000 MHz, M=5 (MSEL bits = 0100), P=2(PSEL bits =01)
// CCLK = Fosc * M = 60.0000 MHz; Fcco = CCLK*2*P = 240.0000 MHz
PLLCFG=0x24;
// OLD baud rate setup on UART0 with 14.7456 MHz crystal
//PCLK = 58.9824 MHz, DIVADDVAL = 0, MULVAL=1
//Baud Rate = PCLK/[16*(256*DLM + DLL)*(1 + DIVADDVAL/MULVAL)] = 9600 baud
U0DLM = 0x01; // DLM=1
U0DLL = 0x80; // DLL=128
// NEW baud rate setup on UART0 with 12.0000 MHz crystal
//PCLK = 60.0000 MHz, DIVADDVAL = 0, MULVAL=1
//Baud Rate = PCLK/[16*(256*DLM + DLL)*(1 + DIVADDVAL/MULVAL)] = 9590.792839 baud
U0DLM = 0x01; // DLM=1
U0DLL = 0x87; // DLL=135
Am I on the right track here…or way off?
Should the slight difference in the PCLK speeds (58.9824 vs 60.0000) be of concern?
Should the fractional baud rate (and/or the slightly lower baud rate) with the 12 MHz crystal be of concern?
Are there other issues I may need to address to get this project to work with the 12 MHz crystal?
Is there a better way (other than replacing the crystal) to accomplish this?
Thanks.
patrick