Other Parts Discussed in Thread: TM4C123GH6PM, TMS570LS1224
Hi all,
I'm fairly new to CAN protocol and I'm having a hard time implementing a CAN network and would appreciate all the help I can get with my project My objective is to setup/configure 3 nodes of a CAN network. My nodes are as follows:
1) Node 1 = A TMS570LS1227 with a standard ID of 0x1, MSG_OBJ1 used for Transmitting, MSG_OBJ2 & MSG_OBJ3 used for Receiving
2) Node 2 = A TMS570LS1227 with a standard ID of 0x2, MSG_OBJ1 used for Transmitting, MSG_OBJ2 & MSG_OBJ3 used for Receiving
3) Node 3 = A TM4C123GH6PM with a standard ID of 0x3, MSG_OBJ1 used for Transmitting, MSG_OBJ2 & MSG_OBJ3 used for Receiving
I've done my research on how CAN protocol works and I'm aware of how the Message Box priority and Message Identifier priority works. Each Node is using its Message Box Object 1 to transmit and using Message Box Objects 2 and 3 to receive messages from the other two.
I'm using interrupts to indicate TX & RX messages on each Node from the other nodes. I've also set up the filtering mask with 0x07FF to use the 11-bits to filter messages from the CAN bus, for each node's receiving message box object.
Based on my understanding and setup above, when I initialize & configure each node on the network, I'm expecting Node 1 to win the arbitration process first and transmit its message, while Node 2 and 3 receive the message. Next, I expect Node 2 to win the arbitration against Node 3, while Node 1 and Node 3 receive. Finally, Node 3 transmits and the other nodes listen and receive.
The following are the issues I've faced with the settings I've described above:
1) The communication is not consistent, i.e. I don't always have all the expected messages in each Node's receive Message Object. What I mean by that: Sometimes Node 3 will have the transmitted message of Node 2 but will not have the message transmitted by Node 1, Node 2 will have the message transmitted by Node 3, but not the message transmitted by Node 1, and Node 2 will have Node 1's message, but not Node 3's transmitted message - IDK why this is happening. Any ideas?
2) When I look at the CAN bus on the Logic Analyzer, I get errors stating there is bit-stuffing and ACK errors. How do you fix the Acknowledgment Error? i.e. How do I configure my receiving Node's to acknowledge that they have received the transmitted message? And I thought Bit-stuffing is taken care of by the CAN controller? Or am I misinformed? Please advise.
3) My current code works with any two of the Nodes in the network, but as soon as I have all 3 nodes in the network, the behavior of the bus is unpredictable.
I've read through the forum and tried to find a similar problem to mine and couldn't find anything useful, anywhere. As I mentioned above, this my first time working on CAN and would appreciate any help that I can get and I'm happy to share my code for each node with you. Looking forward to all your replies. Thank you for your time.
Cheers.