Hello people.
How do I start CAN module and how do I send and receive mensgens.
The project already uses MKE06.
Can be at Processor Expert.
Already read all the documentation but it's very complex.
Thank you.
Solved! Go to Solution.
Hi Eliezer Oliveira Cardoso,
Actually, the baud rate relate register is MSCAN_CANBTR0 and MSCAN_CANBTR1.
These codes:
sMSCANConfig.sBaudRateSetting.SJW = BAUD_RATE_SJW;
sMSCANConfig.sBaudRateSetting.BRP = BAUD_RATE_BRP;
sMSCANConfig.sBaudRateSetting.SAMP = BAUD_RATE_SAMP;
sMSCANConfig.sBaudRateSetting.TSEG1 = BAUD_RATE_TSEG1;
sMSCANConfig.sBaudRateSetting.TSEG2 = BAUD_RATE_TSEG2;
is just configure register MSCAN_CANBTR0 and MSCAN_CANBTR1.
CAN_SendItemToBuffer function will send your CAN data, if you test the code on your KE06, you will find it.
The sample code is based on FRDM-KE06, you can test it and combine the KE06 reference manual to understand it.
Wish it helps you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Eliezer Oliveira Cardoso,
Actually the MSCAN in KE06 is not complex, you can refer to our KE06 sample code and the KE06 reference manual, it is not complicated to understand.
The attachment is the MSCAN sample code for FRDM KE06, you can refer to it. This sample code is the none PE project.
Please refer to it at first, if you have some points don't understand, you can tell me!
If you want the PE project, I also attached the CW PE MSCAN project for KE06, the name is:KE06_CAN.zip
Wish it help you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello, Jingjing.
First thanks for your help.
I made changes to my hardware and I'm having sign in CAN_TX and CAN_RX. I could not change the BAUD_RATE actually I did not understand how fuciona this calculation.
I need to work at the speed of 150 kbit / s.
#define BAUD_RATE_SJW SJW_3TQ
#define BAUD_RATE_BRP 0
#define BAUD_RATE_SAMP 0
#define BAUD_RATE_TSEG1 TSEG_10
#define BAUD_RATE_TSEG2 TSEG_7
#define BAUD_RATE_CLOCK 8000000L
#define Baud_RATE BAUD_RATE_CLOCK/(BAUD_RATE_BRP+1)/\ (BAUD_RATE_SJW+1)/(3+BAUD_RATE_TSEG1+\
BAUD_RATE_TSEG2)
Hi Eliezer Oliveira Cardoso,
Actually, in the reference manual, there have the calculation formula, if you want to get 150Kbit/s, and use 8Mhz as the clock source, you should follow this formula:
Bit time= (1+ Time Segment1 + Time Segment2)(1+BRP)/8Mhz
Take care: 8<= (1+ Time Segment1 + Time Segment2)<=25
So, you can configure it like this:
BPR=2
TSEG1= 9
TSEG2=8
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank Jingjing.
I will use your example.
Hi Eliezer Oliveira Cardoso,
You are welcome!
If your question is solved, could you click the Correct Answer button? Thank you!
Best Regards,
Jingjing
Hello Jingjing.
Sorry to bother you again, it is the first time working with CAN communication.
I'm having trouble understanding the way the code was written.
To which register I should spend the calculation value of BAUD_RATE?
At startup of CAN have the following code:
sMSCANConfig.sBaudRateSetting.SJW = BAUD_RATE_SJW;
sMSCANConfig.sBaudRateSetting.BRP = BAUD_RATE_BRP;
sMSCANConfig.sBaudRateSetting.SAMP = BAUD_RATE_SAMP;
sMSCANConfig.sBaudRateSetting.TSEG1 = BAUD_RATE_TSEG1;
sMSCANConfig.sBaudRateSetting.TSEG2 = BAUD_RATE_TSEG2;
To send a messages exist, simply call the CAN_SendItemToBuffer function (mscan, & sCANTxItemInfo, & sCAN_TxBuff); ?
My message I carry for & sCANTxItemInfo?
Thank you?
each start time and change the value displayed.
Hello Jingjing.
I managed to set the baud rate, the cam is sending data.
I would like to help me find where I set the device ID and in which I write variable values from my sensor to send by CAN.
Thank you.
Hi Eliezer Oliveira Cardoso,
Actually, the baud rate relate register is MSCAN_CANBTR0 and MSCAN_CANBTR1.
These codes:
sMSCANConfig.sBaudRateSetting.SJW = BAUD_RATE_SJW;
sMSCANConfig.sBaudRateSetting.BRP = BAUD_RATE_BRP;
sMSCANConfig.sBaudRateSetting.SAMP = BAUD_RATE_SAMP;
sMSCANConfig.sBaudRateSetting.TSEG1 = BAUD_RATE_TSEG1;
sMSCANConfig.sBaudRateSetting.TSEG2 = BAUD_RATE_TSEG2;
is just configure register MSCAN_CANBTR0 and MSCAN_CANBTR1.
CAN_SendItemToBuffer function will send your CAN data, if you test the code on your KE06, you will find it.
The sample code is based on FRDM-KE06, you can test it and combine the KE06 reference manual to understand it.
Wish it helps you!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Ok, I will study the example of KE06.
Thank you.