Hello,
First of all, I'd like to say that I'm a new computer engineer and just started to learn about ARM development, so I'm sorry if these questions are so basic, but I already read the Reference Manual and search the forum and didn't find how to fix it.
Now, my problem:
I am using a Kinetis KwikStik module with a K40 processor and I'm trying to communicate via UART5 with my PC via COM1.
I've made a project based on some IAR examples (pdb_adc_demo). My application is a simple echo: the K40 receive a character and send it back.
I want a baudrate of 115200bps, so I made the following calculation (clk is 48000 khz):
sbr = ((clk*1000)/(115200 * 16));
sbr = 26 (1A)
My config registers are like this:
MCG_C1 = 0x18 (FRDIV=3)
MCG_C2 = 0x2C (EREFS, HGO, RANGE=2)
UART5_BDH = 0x00
UART5_BDL = 0x1A
Then I connected the module and configure the COM1 to use 115200 and it doesn't works. But if I change the COM1 baudrate to 57600 it works like a charm.
Am I doing something wrong? Maybe the MCG configuration is not ok... I don't know
Thank you,
Leandro Rondon
Hi Leandro
UARTs 0 and 1 are clocked from the system clock (presumably 48MHz in your case).
The other UARTs are clocked from the bus clock. If you have the bus clock divide (set in SIM_CLKDIV1) to divide by 2 it will mean that the the bus clock is running at half the speed of the system clock and so UART5 will have half the (expected) speed if the system clock is used for the calculation.
This means that, when using UARTs other than 0 and 1, the calculation of the divider must use the bus clock speed and not the system clock speed.
Regards
Mark
Mark, you're right.
Thank you!
Leandro