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.
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.
-x xtal-c cclk-h max_clock-l min_clock-u max_error-p n-i string_LPC_CLOCK_TOOL.-aUART_I_XXXX is the UART's integer divider for baud rate XXXXUART_M_XXXX is the UART's fractional divider's 'M' valueUART_A_XXXX is the UART's fractional divider's 'A' valueUART_CLOCK_TABLE_INIT and can be used like this: // Structure to store the baud rate parameters typedef struct { unsigned int b; // Baud rate unsigned short i; // Integer divisor unsigned char m; // Fractional divider M value unsigned char a; // Fractional divider A value } BAUDS; // Table holding the baud rates static const BAUDS brate_table[] = { UART_CLOCK_TABLE_INIT };
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.
0 : success
1 : command line format error or illegal parameter value
2 : the requirements could not be satisfied
1.7.1