# PIC18F25K80 can transmit over CAN but can't receive

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

• If you can see the CANRX pin getting wiggled, then this is obviously a firmware problem. This is a problem with using canned libraries, especially if the source code is not available. You might get away with it when everything works, but when there's a problem you're screwed, as you have apparently discovered. There is no substitute for knowing what is going on in your code. I have not had good experiences using canned Microchip firmware. You can see my CAN driver code in the PIC Development release at embedinc.com/pic/dload.htm Jul 9 '13 at 15:51
• Your self-extracting executables are setting off my antivirus, and I can't get around it because I'm not the admin of this machine. Any alternative way to get the release? Jul 9 '13 at 16:14
• We are aware that some virus software gets a false positive on our stuff. Apparently since a rebuild last fall something matches whatever pattern it is looking for. If people don't trust us or run bad anti-virus software, oh well. We're not going to go out or our way to distribute are free stuff. Jul 9 '13 at 17:04
• Did you ever get this solved? I would be interested to know the answer.
– user41388
May 5 '14 at 15:10
• For anyone that is curious, the problem was in the termination resistor in my circuit. I don't recall the exact problem, but I believe the termination was shorted. Nov 14 '14 at 22:06

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.

• I've enabled CAN capture, but PORTB was already set to 0xFF (all inputs). Didn't seem to do the trick. =\ Thanks, though. Jul 10 '13 at 14:31