1
\$\begingroup\$

I have a STM32F103C8T6 (later I want to more to STM32F407VET6). Both have support for CAN. But what does this mean?

I bought (not received yet) an MCP2551 CAN Controller. Do I need this or is this functionality already built in my STM?

And I think I also need a CAN transceiver like TJA1050?

According to this Example circuit both are used and the input of the MCP2551 but that has a SPI as input and the STM has RX/TX as CAN input/output which is similar as the 'connectors' for MCP2551. But I think this example circuit is not meant for STM32 (since SPI is not used for CAN on STM32).

(I want to make a CAN bus of a few meters, just two, later maybe 3 devices, with preferably 1 mbps speed).

\$\endgroup\$
  • \$\begingroup\$ Do you want the bus electrically isolated from the MCU? \$\endgroup\$ – Dirk Bruere Aug 18 '17 at 14:12
  • \$\begingroup\$ @DirkBruere I don't think so .. I only connect it to 'known' devices (namely another CAN supported STM32 I want to use). On the other hand, if the MCP2551 is needed for electrical isolation ... I bought it already so if it has an advantage (like electric isolation) I am going to use it. \$\endgroup\$ – Michel Keijzers Aug 18 '17 at 14:14
2
\$\begingroup\$

You should have at least two nodes and a twisted pair with 120 ohm terminations at each end. Identifiers must be unique. Read up on the various formats (11/29 bit) and CAN-FD vs. CAN. I suggest starting with 11 bits. The lower numbered identifier is the higher priority.

Typically when a microcontroller supports CAN it means that the 2nd network layer (data link) is supported by a CAN MAC. Usually you have to supply a transceiver (the physical layer). CAN has (electrically) demanding requirements for maximum voltage tolerance that would typically be incompatible with low-cost monolithic processes that support microcontroller complexity. You can also buy chips with serial interfaces that implement the MAC, which you can connect to almost any microcontroller with (eg.) SPI.

There are various high level protocols that can go above the 2 layers specified by CAN, or for a simple application you can implement your own. CAN messages are essentially broadcast and can be used or discarded by each node- like multicast or broadcast.

A CAN protocol analyzer can be helpful- you can buy them for the value of an hour or two debugging.

\$\endgroup\$
  • \$\begingroup\$ Thanks for your detailed answer. I already discussed with another member here that RJ45 cables/connectors would be good (enough). I read a lot about CAN last days (during free time, it's a hobby). 29 bits is something I want, but indeed, I start better with 11 bits. I wish I could use CAN-FD but it seems not to be supported by STM32. I probably will make my own protocol since my requirements are quite simple. But still I'm not sure, you say I need a transceiver... so I guess I need the TJA1050? Not sure about the MCP2551. \$\endgroup\$ – Michel Keijzers Aug 18 '17 at 14:24
  • \$\begingroup\$ I have a logic/protocol analyzer, not checked yet if it supports CAN (it's a simple 5 euro or so device). \$\endgroup\$ – Michel Keijzers Aug 18 '17 at 14:24
  • \$\begingroup\$ @MichelKeijzers The MCP2551 and TJA1050 look like different parts from different suppliers that do essentially the same thing (CAN transceiver). There might be some subtle differences. $5? Interesting. \$\endgroup\$ – Spehro Pefhany Aug 18 '17 at 14:34
  • 1
    \$\begingroup\$ Hey, shouldn't you be in a class? The one I went to just now was pretty brain-dead, so that's why I'm here checking SE. \$\endgroup\$ – Olin Lathrop Aug 18 '17 at 16:17
  • 1
    \$\begingroup\$ @OlinLathrop Yes, doing the hands-on ARM LwIP/RTOS .. and multitasking myself. \$\endgroup\$ – Spehro Pefhany Aug 18 '17 at 16:42
1
\$\begingroup\$

This works, and is taken from a working design. it provides electrical isolation.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ That ADM is that similar as TJA1050? Since I cannot find the first on aliexpress. \$\endgroup\$ – Michel Keijzers Aug 18 '17 at 14:27
  • 1
    \$\begingroup\$ @MichelKeijzers The ADM provides isolation. The TJA1050 is likely cheaper \$\endgroup\$ – Dirk Bruere Aug 18 '17 at 14:59
  • \$\begingroup\$ Ok clear ... since my project (more a learning project) is probably not going to run into issues I try a TJA1050 first. \$\endgroup\$ – Michel Keijzers Aug 18 '17 at 15:09

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.