lpc-clk, a clock calculation tool
[LPC2xxx related tools running on the host]

LPC2xxx PLL and UART calculator tool. More...

LPC2xxx PLL and UART calculator tool.

This program can calculate the PLL settings for a given clock source and desired CPU clock frequency. In addition, it can calculate the UART's division parameters (integer and fractional) for a given set of baud rates.

Usage

lpc-clk options list_of_baud_rates

The output of the program is in the format of a valid C header file, so you can incorporate it in your sources and use the generated values without actually typing them from the screen. If you start the program without any command line switches, it will print a usage message that details all options. If you supply the required parameters on the command line, then the program calculates the PLL and UART settings, formats them so that they can be included in your C source and prints the result on the standard output, which you can redirect to a file.
The following will be #define -d (not including the UART related definitions):

CLOCK_XTAL       is the crystal frequency, in Hz
CLOCK_CCLK       is the (achieved) CPU frequency, in Hz
CLOCK_PLL_M      is the 'M' value setting for the PLL
CLOCK_PLL_N      is the 'N' value setting for the PLL
CLOCK_CPU_DIV    is the CPU clock division value
CLOCK_USB_DIV    is the USB clock division value
CLOCK_MAM_TIM    is the minimum MAM time value
UART_CDIV        is the ratio between CCLK and the UART's PCLK

In case of an error, an error message is sent to stderr.

Options

List of baud rates

It is an optional list of integers, separated by space. Each number is a baud rate for which the divisor values should be calculated. For example, the list
9600 38400 115200
will make the tool calculate the divisor values for three common baud rates.

Exit code

0 : success
1 : command line format error or illegal parameter value
2 : the requirements could not be satisfied