Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Controller Area Network (CAN) test code

Status
Not open for further replies.

NewbeeAVR

Junior Member level 2
Joined
Dec 2, 2017
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
195
I had created a simple test code for CAN using PIC18F4580. Which consists of 2 nodes sending data between each other. Uses 11-bit standard ID for communication. Node-1 is given ID of 10 and Node-2 is given ID of 20. I tried to display the registers like COMSTAT, TXB0CON, TXERRCNT, RXB0CON, RXERRCN on the LCD. A pull-up key is interfaced to RC3 on both the nodes.


  • When key is pressed it will first show the contents of COMSTAT, TXB0CON, TXERRCNT, RXB0CON, RXERRCNT on LCD in sequence.

  • Then at the end it will put the message frame with ID = XX, DLC = 3, Data = NDx on CAN Bus
  • Node-1 puts ND2 on data field D0(N), D1(D) and D2(2) with DLC is 3 and ID = 20.
  • Similarly Node-2 puts ND1 on data field D0(N), D1(D) and D2(1) with DLC is 3 and ID = 10 (Please refer the Test code given).

Both the nodes are sending and receiving data but the data is some junk than what is expected. I have attached a picture of the same. What may be the problem?

CAN test LCD.jpg
View attachment CANTest.zip
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top