This is in reference to STM32 HAL_CAN_Transmit always returns TIMEOUT (HAL_CAN_STATE_TIMEOUT)

We are in the process of setting up a similar environment, and at first draft, facing the same timeout-issue while sending CAN-packet, and thus landed on the above page.

As a first question, are 2 (CAN) controllers always needed in the STM32F0 ecosystem for CAN-transmit to work? If yes, is it the CAN-standard, or just the way STM32F0-ecosystem works?

Sorry if I am being too noob.
Would be grateful for insights from experts :)


closed as too broad by Olin Lathrop, RoyC, uint128_t, Sparky256, Bimpelrekkie Feb 20 '18 at 10:00

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    \$\begingroup\$ "If yes, is it the CAN-standard" You have no business designing a CAN system without knowing the answer to the above. Go back and do your homework, which includes reading the CAN standard at least to the point of understanding how basic signaling works. That will cut down on bumping around in the dark, and asking dumb questions here. \$\endgroup\$ – Olin Lathrop Feb 13 '18 at 12:10

Yes, the CAN bus is a bus - there is no bus with only one node.

When a node transmits a packet, any other node on the bus can/should acknowledge (acknowledgment is made with a single bit "interrupting" the master packet, much like i2c bus). This way, the transmitting node knows that, at least, its packet has reached the bus.

The fact that any node should acknowledge is because CAN packets have no destination address, they are instead meant to reach every node on the bus, like broadcast messages. The listening nodes can even discard a message they are not interested in, but they must acknowledge it anyway. So, if you have a single node, its transmissions will always timeout (timeout is not exactly correct - the sending node knows immediately that no one received the packet); if you have at least two nodes, their transmissions will always be acknowledged, even if the packet gets discarded (ignored).

  • \$\begingroup\$ Thanks linuxfan for the reply. So this ACK-requirement is a must for STM32F0-based controllers, right? If so, will "HAL_CAN_Receive" (at receiving-node) take care of ACK automatically, so that "HAL_CAN_Transmit" is successful at transmitting-node? \$\endgroup\$ – Ajay Garg Feb 13 '18 at 6:34
  • 1
    \$\begingroup\$ Yes. The ACK-requirement is not a must for STMxxx, is a must for any CAN device. I suppose that, once the STMxxx is correctly set up, the ACK will be automatic, even if the receiving node does not call HAL_CAN_Receive. But I don't know those processors. \$\endgroup\$ – linuxfan Feb 13 '18 at 6:39

Standard CAN requires two nodes so that ACKs will be sent. Nodes don't ACK themselves. If you only have one node, you can get a CAN adapter for a PC to act as a second node. Kvaser makes some (relatively) cheap ones.

  • \$\begingroup\$ Thanks Adam for the reply. So, if the first node-controller is only transmitting a packet, does the second node-controller have to be in receiving mode, or is it ok if the second node-controller has only the CAN-bus etc. initialized (but is not receiving any packet)? \$\endgroup\$ – Ajay Garg Feb 13 '18 at 6:23
  • \$\begingroup\$ @AjayGarg: there is no concept of transmitting/receiving state in CAN, at least, not at high level. One node can start to transmit, and can get interrupted by another node with a higher priority message. The interesting thing is that, even in case of interruption, the interrupting packet is not lost. And: the transmitting node which gets interrupted, even receives correctly the interrupting packet. After that, it will try again to transmit its original packet, the one which was interrupted. \$\endgroup\$ – linuxfan Feb 13 '18 at 6:32
  • \$\begingroup\$ Right. Every node on the bus should ACK every packet, regardless of the acceptance mask. \$\endgroup\$ – Adam Haun Feb 13 '18 at 15:25

As a first question, are 2 (CAN) controllers always needed in the STM32F0 ecosystem for CAN-transmit to work?

Yes. Another node is needed to acknowledge that a valid CAN message has been sent.

If yes, is it the CAN-standard


Because of this, CAN controllers often have a "loopback" feature which can be used in the development stage, to "talk with yourself" before you have 2 working boards with proper CAN transceivers.


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