NewbeeAVR
Junior Member level 2
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.
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?
View attachment CANTest.zip
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?
View attachment CANTest.zip