Generate baudrate for TWR-K60N512

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

Generate baudrate for TWR-K60N512

599 Views
rflmota
Contributor II

Hello,

I'm seeking from help on trying to set the baudrate dor UART5 on MK60DN512ZVMD10 on my TWR-K60N512. I'm trying to follow this formula, according to the datasheet of the micro-controller:

  • UART baud rate = UART module clock / (16 × (SBR[12:0] + BRFD))

I've checked in the same datasheet that the "UART module clock" is sourced by bus clock on micro-controller, and I was thinking of using the default values for bus clock on micro-controller for my board, checking section 5.5.1 Clock divider values after reset of the datasheet:

Capture.PNG.png

From my understanding, the micro-controller defaults to a bus clock of "divide by 8", my question is, relative to which clock value?

Is it needed to configure all the registers and components of the MCG and SIM modules to generate a bus clock before attempting to set the UART baudrate, like the following diagram suggests?

Capture.PNG.png

I really appreciate your help and share of knowledge and ask for some patience cause i'm really still a beginner trying to get into the world of ARM micro-controllers.

Many thanks in advance. :smileywink:

Labels (1)
4 Replies

405 Views
rflmota
Contributor II

Thank you chrisbrown and mjbcswitzerland, your two replies were very useful and I think I'll manage to configure the baud-rate more properly from your explanations, and it also allowed me to get a better understanding of the overall clocking system of K60 micro-controllers... BTW mjbcswitzerland, the other thread that you mention, wasn't from me, but from another Ricardo, but it was useful too, thank you for pointing that out, i think I've not searched well enough the forum..

Thank you very much, really appreciate your help!

P.S.: Just for an unrelated question to the topic, can you tell which IDE you're using from the screenshot you took of the register values mjbcswitzerland? My guess would be Kinetis Studio, I'm using CodeWarrior for now which not seems to have a "simulator"... Would Kinetis Studio be more suited to those kinds of boards? Sorry about the off-topic, maybe I should open another thread...

0 Kudos

405 Views
mjbcswitzerland
Specialist V

Hi Ricardo

Sorry for confusing you with the other poster - the questions were so similar I just wanted to avoid typing in the same answer again.

The screen shots are from VisualStudio; I use VS for editing, simulation, debugging and testing because I find it very efficient. It uses GCC for cross compiling (as does KDS and CW and various other methods) but I do also build with CW, KDS, etc. in case I need to do any specific target debugging (whichever one has the most practial debugging support for the particula device in question) [I ensure that the project is always compatible with all IDEs]

There is a list of IDEs that are used here: µTasker Kinetis support

All can be used/work so it is more a question of which one you prefer.

As noted above my preference is always VS since it is very powerful and allows development times to be greatly reduced when used in combination with simulation techniques.

Regards

Mark

Kinetis: µTasker Kinetis support

K60: µTasker Kinetis TWR-K60N512 support / µTasker Kinetis TWR-K60D100M support / µTasker Kinetis TWR-K60F120M support

UARTs/PUARTs: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market


0 Kudos

405 Views
mjbcswitzerland
Specialist V

Ricardo

If you do not configuration the MCG, MCGOUTCLK defauts to about 22.5MHz (32kHz IRC [35156 Hz middle value] * FLL multiplacation of 640).

This means that you will have a system clock of 22.5MHz (typical) and bus clock of the same if you have the LPBOOT configuration set to 1. If you have the LBOOT set to 0 it will be about 2.8MHz for each.

Even if you don't configure the MCG in anyway you can still modifiy the system and bus clocks as you want by simply writing to SIM_CLKDIV1 (doesn't need to wait for anything to lock but make sure that the bus speed is never set higher than the system speed and that the flash clock is not set higher than 25MHz).

UARTs 0 and 1 are clocked from the core clock and the others are clocked from the bus clock.

For UART 5 (bus clock) you can set a baud with the values given in your other thread: Re: I need help with UART5 on TWR-K60N512

Note that with the default clock setting it is neither possible to work with USB nor Ethernet.

Below is a screen shot of the TWR-K60N512 running in the uTasker Kinetis simulator with default LPBOOT = 1 clock setting, showing the speeds involved as well as a Baud of 115200 on UART5 (the 32kHz IRC is assumed to have its typical vaue, which however has some tolerance):

Ricardo

If you do not configuration the MCG, MCGOUTCLK defauts to about 22.5MHz (32kHz IRC [35156 Hz middle value] * FLL multiplacation of 640).

This means that you will have a system clock of 22.5MHz (typical) and bus clock of the same if you have the LPBOOT configuration set to 1. If you have the LBOOT set to 0 it will be about 2.8MHz for each.

Even if you don't configure the MCG in anyway you can still modifiy the system and bus clocks as you want by simply writing to SIM_CLKDIV1 (doesn't need to wait for anything to lock but make sure that the bus speed is never set higher than the system speed and that the flash clock is not set higher than 25MHz).

UARTs 0 and 1 are clocked from the core clock and the others are clocked from the bus clock.

For UART 5 (bus clock) you can set a baud with the values given in your other thread: Re: I need help with UART5 on TWR-K60N512

Note that with the default clock setting it is neither possible to work with USB nor Ethernet.

Below is a screen shot of the TWR-K60N512 running in the uTasker Kinetis simulator with default LPBOOT = 1 clock setting, showing the speeds involved as well as a Baud of 115200 on UART5 (the 32kHz IRC is assumed to have its typical vaue, which however has some tolerance):

pastedImage_0.png

The UART5 registers (showing Baud settings in UART_BDH, UART_BDL and UART_C4 are as shown in the simulator's peripheral register display:

pastedImage_3.png

Regards

Mark

Kinetis: µTasker Kinetis support

K60: µTasker Kinetis TWR-K60N512 support / µTasker Kinetis TWR-K60D100M support / µTasker Kinetis TWR-K60F120M support

UARTs/PUARTs: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market


405 Views
chris_brown
NXP Employee
NXP Employee

Hi Ricardo,

The divide value is relative to the MCGOUTCLK. It is essentially the OUTDIV2 value that is shown in the block diagram (and the CG block downstream of that is just an enable that is automatically controlled). 

However, I did want to point out that the divide value is only 8 if you are using low power boot (LPBOOT).  By default the device will not be using LPBOOT unless you have programmed the flash that way.  So I think it should be a divide by 1.

Hope this information helps,

Chris