Hello,
I'm using KEA-128, and I want to read all the CAN mesages in the CAN bus, I need to extract the id and the data frame of the CAN mesages. If I'm using the attached program that I download from this discussion
https://community.nxp.com/thread/381639#comments , How can I do it?
Regards,
Emilio Moyers
Original Attachment has been moved to: MSCAN_KEA128.rar
Solved! Go to Solution.
Hi Emillio,
If you want to read all the CAN messages, you don't need to add the identifier mask, this will receive all the ID data.
For detials, please refer to my attached code, this code can receive all the CAN message, and will printf the received CAN ID, lengh, and data frame.
The following picture is the configuration of receiving all the MSCAN data:
After receive the data, you can get the data from structure sRxFrameInfo.
My test result is:
Running the TRK-KEA128 CAN_Node1_demo project.
receive a frame data!
ID is 0x8!
Data length is 8
0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,
receive a frame data!
ID is 0x108!
Data length is 8
0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,
receive a frame data!
ID is 0x18!
Data length is 4
0x11,0x22,0x33,0x44,
You can find all the receive information is printf out.
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!
-----------------------------------------------------------------------------------------------------------------------
Hi Jingjing,
A few questions,
Where I can see what the printf command is writting?, I tried usisng the COM where the KEA128 was connected to the computer al 9600 bauds but nothing appear.
How can cofigure the speed ? I'm using 500 kbits/s but I don't know if the program using the same transmition rate.
To change the id when i send a CAN message, do I only need to change the value of sCANTxItemInfo.ID_Type.ID = NODE_ID1;?
Those questions I because nothing happen with the program, only one led is blinking every second because of the RTC task
Regards,
Emilio
Hi Emillio,
You need to use a serial assistant tool, eg, Hypertrm.
The COM baud rate is 115200 bps, not 9600, so you can't get the data.
About the CAN baudrate, the sample code is using 100Kbps.
If you want to change the ID, just change :
#define NODE_ID1 0X801
You can't get it work, because you use the wrong CAN baud rate and the wrong Com baud rate.
Please try again.
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Jingjing,
If I want to change for 100kbps to 500kbps, which variable do I have to change and with which values?
Regards,
Emilio
Hi Emillio,
If you want to change the MSCAN baud to 500Kbps, just modify the mscan.h, BAUD_RATE_BPR data is ok.
#define BAUD_RATE_BRP 3.
You can find how to calculate the MSCAN baud rate in the KEA128 reference manual, chpater 32.4.5.2 Clock system.
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jingjing,
Thanks for answering all my other questions, it really helps.
I have one last question, I hope, to read an specific id for example 0x54, what do I need to put in the IDAR0, IDAR1, IDMR0, IDMR1? Or do I need only to change the Node_id's?
Can you give me an example whatever Id? I have read the sections 32.3.17 to 32.3.20, but I don't understood very hoy the mask of IDAR0, IDAR1, IDMR0, IDMR1 works. Do you have an example of what do they do step by step?
Kind regards,
Emilio
Hi Emillio,
If you want to read all the CAN messages, you don't need to add the identifier mask, this will receive all the ID data.
For detials, please refer to my attached code, this code can receive all the CAN message, and will printf the received CAN ID, lengh, and data frame.
The following picture is the configuration of receiving all the MSCAN data:
After receive the data, you can get the data from structure sRxFrameInfo.
My test result is:
Running the TRK-KEA128 CAN_Node1_demo project.
receive a frame data!
ID is 0x8!
Data length is 8
0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,
receive a frame data!
ID is 0x108!
Data length is 8
0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,
receive a frame data!
ID is 0x18!
Data length is 4
0x11,0x22,0x33,0x44,
You can find all the receive information is printf out.
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!
-----------------------------------------------------------------------------------------------------------------------