I've recently compiled and executed the sci2can example for both the K60 and the K40. My next step was to disable the internal loopback mode so I could connect the two boards to run the external loopback demo.
Prior to connecting the two boards together I hooked each one to a scope to make sure the CAN bus activity was what I expected. What I noticed in both cases is that the same frame is continuously repeated which is not what I expected since the number of transmits specified to the FlexCAN_Write function is 1. Digging a little deeper I can see that the FlexCAN_PrepareAndStartTransmit function sets the CODE field of the message buffer to 0xC, SRR is 0, IDE is 0, RTR is 0 and DLC is 1.
Based on the description of the message buffer code for Tx buffers a CODE of 0xC and RTR of 0 should result in "Transmit data frame unconditionally once. After transmission, the MB automatically returns to INACTIVE state".
If I stop the debugger and manually set the CODE field of the MB to inactive, and then let the code continue execution the frame is no longer transmitted.
So my question is why is it that transmission doesn't terminate on it's own?
Thanks
已解决! 转到解答。
CAN messages need to be acknowledged by another CAN module. The controller continues to send the message out until either the message is ack'ed or the it goes into a bus fault. You need a second CAN node on the bus to ack the message and you must have the bus terminated correctly. This is standard CAN bus protocol for a single module with no other modules awake on the bus. It's one of the things that adds reliability to the CAN protocol.
Norm Davies
I couldn't edit my previous response...
I never did connect 2 twr boards specifically, but I did do it with 1 TWR-K60D100M and 1 Freedom K64 board with additional circuitry. I did get that to work successfully. The document Robert Boys put together was very useful, but unfortunately I don't remember the details of getting it to work. Because of a system architecture change, CAN wasn't going to be a suitable solution, which is why I stopped any further development. Sorry I can't be of more assistance.
Hi,
Is there any sample code to refer me for testing the two CAN module communication? Here i have already tested both CAN0 & CAN1 module in TWR-K60F120M using loopback mode and its working fine. Now i am trying to test communication between these two CAN module ie, like CAN0 is used for transmitting data and CAN1 going to receive that data. Please help me for finding a solution.
best regards,
sruthy uk
Hi friend,
While testing CAN in TWR-K60F120M using the sci2can demo,the code gets stuck at PE_DEBUGHALT() in cpu.c file during debugging.What may be the reason behind this?? How can i solve this problem??
Here am using CAN0 (PTC13/12 for FlexCAN0) by connecting TXD & RXD pins for loopback testing.
CAN messages need to be acknowledged by another CAN module. The controller continues to send the message out until either the message is ack'ed or the it goes into a bus fault. You need a second CAN node on the bus to ack the message and you must have the bus terminated correctly. This is standard CAN bus protocol for a single module with no other modules awake on the bus. It's one of the things that adds reliability to the CAN protocol.
Norm Davies
"P17 corresponds to a generally accepted standard for CAN on DB9 connectors. P17 Pin 7 is the CAN Hi bus line and
pin 6 is CAN Lo." I think you've inadvertently used the pin numbers from the chip there rather than the connector in your text.
Your comments about grounds between nodes are almost correct. The principal reason for using grounds on ALL CAN networks is to ensure that the common mode voltage between ground and the CAN pins aren't exceeded. A high common mode spike relative to two separate grounds can toast your CAN transceiver chip. You'd never even see why. It would just fail or become sporadic.
Larry
You can also take a look at the following video which shows how CAN can be used with the Kinetis (single or dual), the bus monitored with a CAN bus analyser and it also show how a simulated Kinetis device can be connected to a real CAN bus for development/test work.
https://www.youtube.com/watch?v=Ha8cv_XEvco
There is a CAN document top go with it concentrating on the SW interface: http://www.utasker.com/docs/uTasker/uTaskerCAN.PDF
Regards
Mark