So, this post is quite old, but people can look at it again like this: firstly, the Can bus is not a convenient protocol at all, such as USART or IC2, so you have to be very accurate about your bit, there are tools for this but I suggest you calculate them manually. For the microcontroller, I would suggest the STM32 and, in my opinion, would be far from the PIC series. If it is only CAN-BUS without higher level protocols such as SAE J1939, the steps are quite simple and straightforward:
1) You can initialize
2) Put CAN in setup mode and remember that you can set the baud rate, mask and filters only in setup mode!
3) Set the bit rate registers.
4) Install the mask and filters. If you need to receive all messages, just set the mask to 0x00. Then the filter will not care.
5) Set CAN to normal mode or reverse loop mode. (Reverse looping mode is mainly used for debugging purposes.)
Some of the wonderful things that people are trying to realize may be missed at first: *** For a successful transfer, you need at least 2 working CAN nodes. (of course, with an appropriate data rate). Therefore, if you want to send some data via CAN with 1 node, this will not be successful. Because your transmitter will not receive ACK.
*** Most likely, you will need a CAN transceiver. Remember to install a 100 ohm resistor or similar between the transceiver's Tx and Rx pins.
source share