Cheap & simple MCP2551/MCP2515 CAN BUS set up

coryjfowler:
Try the library here: https://github.com/coryjfowler/MCP2515_lib

I have fixed a lot of the issues I encountered with the Seeedstudio library and the examples. It has been working pretty well at this point even hooked up to highly utilized CAN Buses. I also have the intention to add support for multiple MCP2515 ICs, error support, and a better interrupt handling method.

Also, using the MCP2515 in "listen" mode causes it to NOT acknowledge any messages it receives. It is in a purely ears-only mode. If you use this mode on a CAN bus with only one other active CAN transceiver, you will find messages are sent infinitely till its controller errors out and shuts down.

Hi cory,
Your library for MCP2515 is the best one I've tried so far. Thank you very much. I also found a bug in sendMsg() function, which I guess you might want to be informed of.

I think the code: res1 = mcp2515_readRegister(txbuf_n) should be changed to: res1 = mcp2515_readRegister(txbuf_n - 1) to get TXBnCTRL correctly. I check the library, txbuf_n is the address of SIDH returned by mcp2515_getNextFreeTXBuf(&txbuf_n). If bit3 in SIDH happen to be 1, the bit will never be cleared even the CAN message has been sent successful, and sendMsg() will be stuck in the while loop until the set TIMEOUTVALUE is reached.