1
\$\begingroup\$

I am currently looking for a uC for a project of mine which needs a CAN interface. This would be my first project using CAN. Since I want to send and receive messages between the master and at least 8 slaves I was wondering about the amount of CAN ports I need.

According to this post I can send and receive messages on the same uC using only one port.

Looking at the Part selector of Microchip one of the fields says 'CAN Receivers buffer' and 'CAN transmitters buffer', which suggests otherwise.

Can I use them on the same bus or do I need a busline for sending and a separate one for transmitting?

\$\endgroup\$
3
\$\begingroup\$

The point of CAN is that you have (usually) a single controller and a single transceiver in a CAN node (some safety critical systems may have more than one bus for redundancy).

All CAN nodes talk bidirectionally over the same single wire pair.

The number of transmit and recieve buffers (and filters / masks) reduces the load on the firmware. For example if have 8 transmit buffers and you want to send 5 messages that have lower priority than the current bus traffic you can simply load all of them at once and the controller will send them whenever the bus is available. If you have only one buffer, then you can queue just one frame in the controller and the firmware needs to queue the rest.

\$\endgroup\$
  • 1
    \$\begingroup\$ keep in mind the Random behavior of CAN transmissions, with packet collision detection and hold off and re-transmit a part of the system behavior. \$\endgroup\$ – analogsystemsrf Nov 17 at 21:17
  • \$\begingroup\$ Therefore I would only need 1 CAN module on my uC and as many buffers I feel necessary. I still have a lot of reading to do regarding this bus protocol \$\endgroup\$ – v3xX Nov 18 at 6:22
  • \$\begingroup\$ In every device you only need one CAN controller (may be built into the MCU) and one CAN transceiver. The number of buffers that the controller must provide depends on your aplication and the amount of time-critical traffic. \$\endgroup\$ – filo Nov 18 at 7:25
0
\$\begingroup\$

The nature of CAN with CSMA/CA access of the bus means that all communication is done one the same lines, both sending and receiving. The tx and rx signal pins on the MCU are connected to a transceiver where they turn into one signal, which in turn is split in a differential pair CANH + CANL.

You only need more than one CAN controller on-chip if you are communicating with several different buses at once. It sounds like you only need to communicate with one bus, so you only need 1 CAN controller peripheral.

One thing to keep in mind when selecting a MCU with built-in CAN controller is that they come in two different flavours:

  • One simpler version which is only buffer-based, having one or several TX buffers, and a number of RX buffers working as RX FIFO.
  • One advanced version with "mailbox" functionality where in addition to TX/RX buffers/FIFO, you also have dedicated "mailbox" slots where a frequent message with a certain CAN id can get its own buffer.

The latter is a bit more complex, but suitable if you handle a whole lot of different CAN identifiers that need to be sent/received frequently.

\$\endgroup\$
  • \$\begingroup\$ Microchip SAMC family is an example of the latter, where the CAN controller is also utilizing a DMA-like functionality where buffers are allocated in user RAM address space and copied to/from RAM by the controller. It's a very modern CAN controller, so if you have decided to go with Microchip I'd recommend that one. Don't pick some rusty PIC or AVR. Stay away from external CAN controllers in particular (as done with Arduino), that's obsolete technology. \$\endgroup\$ – Lundin Nov 18 at 9:14
  • \$\begingroup\$ I played around with an Arduino and MCP2515, but was not very satisfied (it seemed not as stable as I was hoping to). I narrowed my search to PIC18, PIC32 and ATSAM series from Microchip \$\endgroup\$ – v3xX Nov 18 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.