LPC17xx Fractional Baud Rate Calculator

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC17xx Fractional Baud Rate Calculator

2,955 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by toby on Tue Sep 04 07:30:59 MST 2012
Hey there. :)  First time poster but I've been lurking for a while.  I've gotten some helpful insight and tips here just from reading answers to other people's questions, so I figured it was as good a time as ever to give something back.

I've been toying with picking the best fractional rates with my EA LPC1769 board for my given clock rates and desired baud rates.  Unless you're running a clock that divides cleanly, you're stuck with fractional rates to get as close as possible.  After trying to figure out the numbers by hand, I said screw it and made a Google Docs spreadsheet to do the heavy lifting for me.

Here's what you do:

- specify your core clock
- specify your desired baud rate
- it calculates the potential peripheral clocks you could achieve (based on available dividers)
- for each peripheral clock, it generates the appropriate estimated FRs within the range of 1.1 to 1.9 (replicates the flowchart process, essentially)
- for all the given FRs, it creates a row for each where it shows the resulting baud rate and error %

All the possible FR combinations are already pumped in so once you've given it a core clock and baud rate, it will auto-update its tables and show you all the possible combinations and their error %.  The error % is highlighted anywhere from red all the way to green to indicate how close of a match to your target baud rate it is.

It will give you the DivAddVal, MulVal and DL so you can pump the values right into your code and be up and running in no time.

Here it is: https://docs.google.com/spreadsheet/ccc?key=0Atbyhsv78i49dHlocklLLWtFbThrVmUxTzZ5SnJPbHc

You can see where I've been trying to find this best core clock to yield super low error rates for 115200, 10400 and 9600 baud rates.  If you're logged into a Google account, you can go to File -> Make a Copy to copy it to your Google Docs and configure your own rates, etc.

Let me know if you have any questions... I hope somebody besides me finds this useful. :)
0 Kudos
5 Replies

1,524 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Fri Sep 14 16:37:50 MST 2012

Quote: toby
I'm not sure if their sheet is wrong or if mine is wrong.


I've attached a copy of the source code, LPC1769 executable hex file and screenshot of a demonstration program [I]CalcBaudRate[/I] that we ship with our Astrobe for Cortex-M3 development system. You could use this to check your results. CalcBaudRate writes its output to a terminal emulator on your PC running at 38,400 Baud connected to UART0 of the LPC1769.

CalcBaudRate calculates and displays the [I]optimum[/I] values of the parameters for a range of crystal frequency and baud rate combinations.

The [I]Calculate[/I] function included in the example was designed to be efficient enough to be extracted and included in your application if you want to generate the values dynamically. It is less than 500 bytes in size and takes about 16ms to execute.

The source code was written using the 2011 revision of the Oberon Programming Language. It is less than 30 lines of code so it would be a fairly easy exercise to translate it to C or some other language if required.
0 Kudos

1,524 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by toby on Thu Sep 13 05:22:29 MST 2012
Nice find!

I played around with the spreadsheet very briefly.  Some of their numbers don't seem to line up with mine.  I'm not sure if their sheet is wrong or if mine is wrong.

I also realized that my approach of using their table of acceptable FRs is a suboptimal approach.  Since you can pick whatever fractional divider components you want, I should simply be trying all combinations and seeing which one yields the best accuracy rather than assume that only the FR combinations listed in the user manual are correct. :)
0 Kudos

1,524 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Tue Sep 11 22:17:21 MST 2012
[SIZE=2][FONT=Tahoma]Thanks for the clarification.
For whomsoever is interested, I found the following Excel spreadsheet on the NXP site.

[/FONT][/SIZE][FONT=Tahoma][SIZE=1]http://ics.nxp.com/support/documents/microcontrollers/xls/lpc2000.uart.baudrate.calculator.xls[/SIZE][/FONT][SIZE=2][FONT=Tahoma][SIZE=1]
[/SIZE]
It says LPC2000, but it is also applicable to the LPC1700, etc. CPU's.
Enjoy.

[/FONT][/SIZE]
0 Kudos

1,524 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by toby on Mon Sep 10 18:51:35 MST 2012

Quote: MikeSimmonds
[FONT=Tahoma][SIZE=2]Any chance of releasing this as an Excel (97) file?[/SIZE][/FONT]



Unfortunately, the spreadsheet relies on some Google script functions behind the scenes so it'd require actual Excel programming time to replicate it.  I might be able to replace some of that, but not quickly.  I'll definitely post any updates I make to this thread. :)
0 Kudos

1,524 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Mon Sep 10 00:36:01 MST 2012
[FONT=Tahoma][SIZE=2]Any chance of releasing this as an Excel (97) file?[/SIZE][/FONT]
0 Kudos