I've built a prototype circuit on a solder breadboard. I've connected the PIC18F25K80
to MCP2551
as shown in the schematic for this demo board. I'm running the example code from Microchip's website for CAN Mode 0 and CAN Mode 2 on PIC18, only modified to use PORT A
rather than PORT D
, as PIC18F25K80 does not have PORT D
.
I have a 120 ohm termination resistor between CAN_H
and CAN_L
on the MCP2551
.
The system is connected to my PC via a sysWORXX CANmodul1 CAN-to-USB adapter. Using PCANView, I can receive a message on my PC when sent from my circuit. However, I can not get the microcontroller to receive a message sent from PCANview. If I scope the CAN_H
and CAN_L
pins, or the CAN_RX
pin, I can clearly see a digital signal traveling through the circuit and into CAN_RX
.
I have tried disabling filters via changing RXM1
in RXB0CON
and RXB1CON
, but it doesn't seem to help.
How can I fix this problem?
EDIT1: I've been fiddling around with it a bit more, and I've noticed that RXB1D<7:0>
holds the data I transmit after transmitting. The operational mode at the time IS normal (not loopback), so should the message ever be getting to the buffer? I currently have all filters and masks off.
Also, I'm using B0
through B4
as additional Rx buffers in Mode 2 (FIFO), and B5
as a Tx buffer with auto-RTR.
For reference, I'm using MPLAB X 1.80, C18 v3.46, and a PICkit 3 set up for in-circuit debugging.
PIC18F25K80
datasheet for reference:
http://ww1.microchip.com/downloads/en/DeviceDoc/39977f.pdf
Best Answer
According to the datasheet, the CAN module overrides the TRIS for CANTX but not for CANRX, which you must set yourself to be an input. Another flag that will prevent CAN recieve is
CIOCONbits.CANCAP
which should be 1 for enable CAN capture.