I am developing my application on Kinetis K64 with Kinetics Studio 3.2 with ProcessorExpert.
I used ProcessorExpert to generate code for CAN component.
My application has to communicate on a CAN bus, so I use the CAN_LDD embedded component.
My application needs to set the CAN bus bit-rate run time.
But in the CAN_LDD component I did not find methods to set bit rate.
I have tried to look into CAN init code for changes in register values for different baud rate (250 kbps and 500 kbps) but I did not find the specific registers related to baud rate.
What are the registers whose value need to be changed to set bit rate run time?
Solved! Go to Solution.
Hi Kirti Raje,
Yes, it is correct.
Now, after you configure it, do you meet else questions?
If you still have question, please let me know!
If your question is solved, please help to mark the correct answer to close this question.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello,
Thank you for your reply. Yes , I could change the CAN bit rate run time. I have made changes in CANx_CTRL1 register. I was looking for 250 kbps nad 500 kbps baud rate change in run time. So I have used,
for Bit rate = 250 Kbps
Ftq = (Fcan_clk / Prescalar value), Fcan_clk = 20.9715 MHz, PREDIV = 6,
Bit rate = (Ftq / No. of time quanta), Ftq = 3.49525 * E6, No. of time quanta = (Sync Seg + PROPSEG + PSEG1 +2 + PSEG2 +1) = 14,
bit rate = 249.62 kbps.
Like wise we have calculated for 500 kbps.
CAN0_CTRL1 |= CAN_CTRL1_PSEG1(0x01) |
CAN_CTRL1_PSEG2(0x01) |
CAN_CTRL1_TSYN_MASK |
CAN_CTRL1_LBUF_MASK |
CAN_CTRL1_PROPSEG(0x01); /* Setting CTRL1 register */
For changing bit rate run time, disable CAN interrupt then change the CANx_CTRL1 values, initialize CAN again and enable the interrupts.
Thanks a lot,
Kirti
Hi Kirti Raje,
Yes, it is correct.
Now, after you configure it, do you meet else questions?
If you still have question, please let me know!
If your question is solved, please help to mark the correct answer to close this question.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Kirti Raje,
If you want to change the bit rate in the CAN_LDD, you can change it in bit rate item:
About the register for bit rate, it is CANx_CTRL1. More details, you can refer to the reference manual for K64, chapter 49.4.8.4 Protocol timing.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------