Hi,
I try to use CAN_LDD in KDS 3.0 for CAN bus communication on MK20DX256VLL7, which is based on web sample : CAN_LDD usage
I have the problem to transmit message in program(see project in attached). In fact after to call the SendFrame(), I found that trig the PE_ISR(CAN_InterruptError). I have no idea to fix this problem. I think that should be the problem on setting, could you give me advise on it?
Another question is the CAN register: I found that the MCR is 0 before initial it, and change into 0xA30001 after initial, but I found it should be 0xD890000F after reset on reference manual as following picture, is it CAN component faille on the chip?
Here is the debug windows:
and terminal windows:
Thanks in advance
Best regards,
Zhong Shen
Original Attachment has been moved to: dkk20.zip
Solved! Go to Solution.
Hello Shen,
I know your meaning , your CAN have not problem, this phenomenon is normal.
And the CAN have the retransmission mechanism , when the receive have not send ACK to the sender ,
the send node will repeat send .
So about your project, you have not connect the transmitter and receiver correctly , so the trasmitter can not receive
the ACK.
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello,
you can have problem with connection to a CAN bus. Have you connected the Rx and Tx pins to a CAN transceiver? For example using TJA1050 according to the following scheme:
If the Rx and Tx of the CAN device are not properly connected to a CAN bus (by using CAN transceiver) the CAN device will not send and receive any data.
I have also attached a demo project for TWR-K60N512 that works properly on the target board (a TWR-SER and one additional TJA1050 transceiver are used for the CAN bus).
Best Regards,
Marek Neuzil
Hi Marek and Alice,
Thanks for your response.
In my case the transceiver of CAN is connected, and terminal resistor is 120Ohm.
I have changed a lot configuration for CAN_LDD, it still take place the error interruption. And I removed the CAN_LDD component and add it again, it do not take place the error interruption. And the receiver can received the frame. Maybe there is error on the creating CAN_LDD. Thanks again for you help.
I am newer for CAN bus application, I found that the transmitter will repeat send a frame if there is only one node (transmitter) on the CAN bus, as well as there is not any error interruption on the transmitter (which can not test it). That is the same case as the CAN bus cable is broken. How can I avoid this situation, or is there any flag which can show this situation?
Best Regards,
Zhong Shen
Hello Shen,
What about your project now ? Does you refer to the typical usage create your project ?
And does you connect your CAN node to the CAN bus or the CAN analysis ?
You can send your new project to me , and i check it on my side .
BR
Alice
Hi Alice,
I am still to debug the CAN component using typical CAN_LDD. I used MK20 to connect a note (MK64). And the MK20 can send the date frame to MK64 now. The attached is the project of MK20. Next I will make MK20 as receiver to receive CAN frame. As my MK20 board is damaged (that is bad), I will use KE06z to replace it and it will take more time to use KE06, because MSCAN is used in KE06. As transmitter the code is the same as MK20 to transmit frame, but as receiver, it is difference from flexcan. I am studying how to configure it to receive the frame for special ID, because I found that there is not the setting receive ID with MSCAN in CAN_LDD.
As said before, I am newer for CAN bus, I do not know the protocol in detail. In my test, if the cable is disconnected, I found that the transmitter repeat to send the frame (the transmitter sent one frame only) even if the cable is connected, but the grounds of two notes are disconnected (the receiver can receive the frame in this case). I wonder if the CAN controller will repeat to send the frame when it can not get the acknowledge from the bus? How to check this situation to close CAN controller?
Anyway, thanks for your response.
Best Regards,
Zhong Shen
Hello Shen,
- How do you check the can send and can receive when it disconnected ?
I checkecd your code , it only send once when it restart , and so i not very clearly about your words
"I found that the transmitter repeat to send the frame (the transmitter sent one frame only) even if the cable is connected, but the grounds of two notes are disconnected (the receiver can receive the frame in this case)."
- About the MSCAN module , use the register of "MSCAN_CANTBSEL" select which buffer be used to transmit And how to select , i recommend you read this section (it in the MKE06RM):
And also there is an CAN demo on KEA128, while the MSCAN is the same , you can refer to it configure your code .
I wonder how to get CAN to work with KDS's Processor Expert?
Hope it helps
Alice
Hi Alice,
Thanks. I will study the KEA128 sample.
In your test, do you connect ground between transmitter and receiver? In my case, if not connect ground, the receiver can receive same frame repeated (I can see the repeated frame signal on the scope).
And, the transmitter sent one frame on CAN bus in my code, if CAN bus is not any receiver I can see the repeated frame from transmitter on scope, that is the case of cable broken. I hope you can understand my description.
Best Regards,
Shen
Hello Shen,
I know your meaning , your CAN have not problem, this phenomenon is normal.
And the CAN have the retransmission mechanism , when the receive have not send ACK to the sender ,
the send node will repeat send .
So about your project, you have not connect the transmitter and receiver correctly , so the trasmitter can not receive
the ACK.
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Got it.
Thanks!
Hello Zhong Shen,
(1) About the register of MCR, there is no error , in the Reference Manual ,
it meaning after reset, the MCR value is 0xD890000F, we can see in the screenshot :
the value of 0xA30001 is after the initialize function: CANPtr = CAN_Init(&DataState);
this function is generated after you configure the CAN_LDD component , this is reply to how
to configure it , for example for the AEN bit of MCR register :
- after you enable the "About transimission mode" :
then generate code , then after run the initialize function , the bit of AEN will be "1"
(2) About your project , i will debug it on my side to check the problem .
Hope it helps
Alice
Hi Alice,
Thanks for you reply. It is help for me.
Agreed your opinion on MCR, actually I found the it is changed into reset value after executing SIM_SCGC6 |= SIM_SCGC6_FLEXCAN0_MASK; in CAN_init().
Hope to get the you side result.
Best regards,
Zhong Shen
Hello Zhong Shen,
I test your project , and it is hard find the problem .
I recommend you refer to the demo of "Typical Usage: " , you can find them at here :
Hope it helps
ALice