I had to set up uart with 2 modes of operation, one in 115200bps and one in higher baud rate.
When I’ve set the second mode to be 921600bps, it was working fine, but when I set it to be 3250000bps, the transmission was actually at ~900kbs instead.
Found out in file ASerialLdd2.c
in function ASerialLdd2_SelectBaudRate there
is an array holding the possible values for register UART2_C4 field BRFA and registers UART2_BDH and UART2_BDL
BD is holding the baudrate divider and BRFA is holding the fine adjustment value.
The calculation is
Baudrate = UART
device clock/(16*(BD+BRFA/32)) = 96MHz/(16*(BD+BRFA/32))
The original lines were
static const uint8_t ASerialLdd2_BaudAdjustValueSpeed0[0x02] = {0x02u,0x10u};
static const uint16_t ASerialLdd2_BaudDivisorSpeed0[0x02] = {0x34u,0x06u};
This gave ~900Kbps to mode 1
The modified lines are
static const uint8_t ASerialLdd2_BaudAdjustValueSpeed0[0x02] = {0x02u,0x1bu};
static const uint16_t ASerialLdd2_BaudDivisorSpeed0[0x02] = {0x34u,0x01u};
This gives 3250000bps to mode 1 (as intendant)
Why is that?
Thanks,
Zohar
Hi Alice.
This is the code snippet I have
I am using two different baud rates in different mode. I don't think you've setup the UART the same
Best regards,
Zohar
Hi ZOHAR,
Yes, i use the KDSv3.0 , and add the UART component , then configure it .
And maybe the version if different between us, so please send your project to me .
Or i don't know how to generate your code.
Or another method is you can use the code you changed .
BR
Alice
Hi Alice,
Device number MK20DN512VMC10
KDS version 3.0.0
Core clock 95.977472 MHz
Bus Clock 47.988736 MHz
Thank you,
Zohar
Hello Zohar,
Are you sure the code you shown is generated by PE ?
On my side , i also create one project , then add the UART component ,
while i have not find the code you side , could you send your project to me ?
On my side , it is like this :
BR
Alice
Hello Zohar,
Please tell me the part number of your chip, the version of KDS,
also the core clock an bus clock .
then i will check it on my side, thank .
BR
Alice