STM32 CAN Bus Guide: TJA1050, SN65HVD230 and Vehicle Networks

STM32 CAN bus guide for TJA1050 and SN65HVD230: Blue Pill bxCAN, wiring, 120-ohm termination, bit timing, OBD-II, vehicle networks and troubleshooting.

CAN bus is one of the most useful interfaces available on STM32 microcontrollers for automotive, industrial and distributed-control projects. But a working CAN node needs two separate pieces of hardware: a CAN protocol controller inside or outside the MCU, and a physical-layer CAN transceiver connected to CANH and CANL.

This distinction matters immediately with the popular STM32 development boards. The STM32F103C8 Blue Pill includes an on-chip bxCAN controller. The common STM32F401 and STM32F411 Black Pill MCUs do not include a CAN controller. A TJA1050 or SN65HVD230 is only a transceiver, so connecting one to an F411 does not magically add CAN.

This guide explains the controller/transceiver split, compares the 5 V TJA1050 with the 3.3 V SN65HVD230, shows termination and wiring, covers STM32F103 bxCAN configuration and explains what changes when you connect to a real vehicle network.

CAN Controller vs CAN Transceiver

Part of systemWhat it doesExample
CAN controllerFrames, identifiers, CRC, arbitration, filtering, ACK, errorsSTM32F103 bxCAN
CAN transceiverConverts TX/RX logic into differential CANH/CANL electrical levelsTJA1050, SN65HVD230
Bus wiringCarries differential signal between nodesTwisted CANH/CANL pair

A microcontroller with bxCAN still cannot connect CAN_TX and CAN_RX directly to vehicle wiring. It needs a transceiver.

Likewise, a microcontroller without a CAN controller cannot use a transceiver alone. It needs an external controller such as an SPI CAN controller, or a different MCU with CAN/FDCAN built in.

Blue Pill vs Black Pill for CAN

BoardMCUNative CAN controller?What you need
Blue PillSTM32F103C8Yes — bxCANCAN transceiver only
Black Pill F401STM32F401NoExternal CAN controller + transceiver
Black Pill F411STM32F411NoExternal CAN controller + transceiver

This is one of the unusual cases where the older Blue Pill has a peripheral that the newer F401/F411 Black Pill lacks.

If CAN is a central project requirement, do not choose a board by CPU speed alone. Peripheral selection matters more.

What STM32F103 bxCAN Supports

The STM32F103 bxCAN peripheral implements Classical CAN 2.0B. It supports both 11-bit standard identifiers and 29-bit extended identifiers in hardware.

The controller provides transmit mailboxes, receive FIFOs, configurable acceptance filters, error handling and automatic arbitration.

Classical CAN data frames carry up to 8 data bytes. This is not CAN FD.

Default CAN Pins on STM32F103

For the STM32F103, the normal bxCAN mapping uses:

SignalDefault STM32F103 pin
CAN_RXPA11
CAN_TXPA12

The F103 alternate-function remap system can move CAN to other pins on supported packages, including PB8/PB9 on common configurations. Exact remap availability depends on the package/device, so check the STM32F103 datasheet and AFIO configuration rather than copying a random example.

PA11/PA12 are also USB D−/D+ pins, so using CAN on the default mapping conflicts with native USB on those pins.

The Basic Blue Pill CAN Connection

STM32F103 Blue Pill          CAN transceiver

PA12  CAN_TX  ─────────────►  TXD
PA11  CAN_RX  ◄─────────────  RXD
3.3 V / 5 V  ──────────────►  VCC as required
GND          ───────────────►  GND

                               CANH ─────────── bus CANH
                               CANL ─────────── bus CANL

The transceiver supply depends on the device. That difference is central to choosing between TJA1050 and SN65HVD230.

TJA1050 vs SN65HVD230

FeatureTJA1050SN65HVD230
Supply voltage5 V3.3 V
Maximum Classical CAN rateUp to 1 Mbit/sUp to 1 Mbit/s
ISO 11898 high-speed CANYesYes
3.3 V MCU interfaceTXD accepts 3.3 V HIGH; RXD requires pin-level checkDesigned for 3.3 V controllers
Low-power/slope featuresSilent mode / legacy featuresStandby and adjustable slope via Rs
Natural fitLegacy 5 V CAN nodes3.3 V MCU projects

Both devices are high-speed Classical CAN transceivers, not CAN controllers.

SN65HVD230: The Cleaner Match for 3.3 V STM32

Texas Instruments specifies the SN65HVD230 for a single 3.3 V supply and for operation with 3.3 V microcontrollers or DSPs that already contain a CAN controller.

Blue Pill 3.3 V ─────────► SN65HVD230 VCC
PA12 CAN_TX ──────────────► D / TXD
PA11 CAN_RX ◄────────────── R / RXD
GND ──────────────────────► GND
CANH/CANL ────────────────► bus

The SN65HVD230 supports signaling rates up to 1 Mbit/s and is compatible with the ISO 11898 high-speed physical layer.

SN65HVD230 Rs Pin

The SN65HVD230 Rs pin controls operating mode and edge rate. Depending on how it is wired, it can select high-speed operation, slope control or standby.

For a ready-made module, inspect the schematic rather than assuming the resistor network is correct for 500 kbit/s or 1 Mbit/s operation.

TJA1050: 5 V Transceiver with a 3.3 V MCU

The TJA1050 operates from a nominal 5 V supply. Its TXD HIGH threshold is low enough for a 3.3 V STM32 output to drive the transmitter.

The receive direction deserves more attention. RXD is a 5 V-domain output, so verify that the chosen STM32 input is 5 V tolerant or use level conditioning.

On STM32F103 devices, PA11 is documented as an FT — 5 V-tolerant — I/O. That makes the common PA11 CAN_RX mapping practical with a TJA1050, but do not generalize this to every MCU or every pin.

For a new 3.3 V design, a transceiver designed around a 3.3 V logic interface or a modern 5 V transceiver with a dedicated VIO pin is usually cleaner.

Do Not Power a TJA1050 from 3.3 V

The TJA1050 supply specification is around 5 V. Running a 5 V transceiver from 3.3 V because the MCU is 3.3 V is not the correct fix for logic-level compatibility.

Use the required transceiver supply and handle logic levels correctly.

Modern Alternative: Transceiver with VIO

For new automotive designs, a modern transceiver with a dedicated logic-supply pin is often a better solution.

Devices such as VIO-equipped TJA1051 variants let the bus driver run from 5 V while TXD/RXD logic levels follow the MCU’s 3.3 V supply.

The older TJA1050 remains useful in legacy modules and inexpensive boards, but it should not automatically be the first choice for a new 3.3 V PCB.

CAN Bus Termination

A high-speed CAN bus is normally a linear trunk terminated with 120 Ω at each physical end.

120 Ω                                         120 Ω
CANH ──/\/\/───===========================───/\/\/── CANH
CANL ──/\/\/───===========================───/\/\/── CANL

             nodes tap onto the trunk

The two 120 Ω resistors are electrically in parallel as seen across the bus, so with the bus powered off you often measure roughly 60 Ω between CANH and CANL on a correctly terminated network.

Do Not Put 120 Ω on Every Node

CAN termination belongs at the ends of the main bus, not on every ECU or development board.

Many cheap CAN modules include a soldered 120 Ω resistor by default. That is convenient for a two-node bench test and wrong when you tap into an existing vehicle bus that is already terminated.

Before connecting, check whether the module has termination fitted and whether it can be removed with a jumper or resistor.

Bench CAN Network

Node A                              Node B

STM32F103                          USB-CAN / STM32
   │                                   │
transceiver                         transceiver
   │                                   │
CANH ================================ CANH
CANL ================================ CANL
   │                                   │
 120 Ω                               120 Ω

Common reference ground also connected

For a short two-node bench network, one 120 Ω terminator at each end is the simplest arrangement.

Why a Ground Reference Still Matters

CANH/CANL carry a differential signal, but the transceiver receiver still has a limited common-mode range. Two nodes with wildly different ground potential can exceed that range.

On a bench, connect grounds between nodes unless the interface is galvanically isolated.

In a vehicle, use the intended chassis/ECU ground reference and avoid creating unsafe ground loops through test equipment.

CANH and CANL Voltage

On a typical high-speed Classical CAN bus, recessive state places CANH and CANL near the same common-mode voltage. During a dominant bit, CANH rises while CANL falls.

Recessive:
CANH ≈ 2.5 V
CANL ≈ 2.5 V
difference ≈ 0 V

Dominant, typical:
CANH ≈ 3.5 V
CANL ≈ 1.5 V
difference ≈ 2 V

Exact values depend on the transceiver and loading, so use these as oscilloscope expectations rather than calibration limits.

Twisted Pair and Stub Length

CANH and CANL should run as a twisted pair. Twisting helps both conductors pick up external interference similarly so the differential receiver rejects much of the common-mode noise.

CAN also works best as a linear bus. Long star branches create reflections and become increasingly problematic as bit rate rises. At 1 Mbit/s, keep node stubs very short.

Bit Rate Must Match Exactly

Every node on one CAN segment must use the same nominal bit rate.

  • 1 Mbit/s.
  • 500 kbit/s.
  • 250 kbit/s.
  • 125 kbit/s.

A node configured for 250 kbit/s cannot decode a 500 kbit/s network. It will see errors, not half-speed messages.

CAN Bit Timing Is More Than Baud Rate

The controller derives each CAN bit from the peripheral clock using a prescaler and time segments.

CAN bit time =
Sync segment
+ Time Segment 1
+ Time Segment 2

bit rate =
CAN peripheral clock
--------------------
prescaler × total time quanta

The sample point, propagation delay and oscillator tolerance matter as well as the final numerical bit rate. For production or long-bus designs, calculate timing properly rather than relying on the first combination that yields 500000.

STM32CubeMX Makes bxCAN Setup Easier

For an STM32F103 CubeIDE project, CubeMX can configure the CAN peripheral clock, prescaler, synchronization jump width, bit segments, CAN RX/TX pins and NVIC interrupts.

Use a known-good CAN bit-timing calculator or validated CubeMX values for the actual APB clock.

Basic STM32 HAL CAN Initialization

HAL_CAN_Start(&hcan);

HAL_CAN_ActivateNotification(
    &hcan,
    CAN_IT_RX_FIFO0_MSG_PENDING
);

If HAL_CAN_Start() fails, inspect the HAL error code and verify that the peripheral clock, GPIO mapping and CAN state are correct before blaming the transceiver.

Acceptance Filter Example

For initial testing, accepting all identifiers is useful.

CAN_FilterTypeDef filter = {0};

filter.FilterBank = 0;
filter.FilterMode = CAN_FILTERMODE_IDMASK;
filter.FilterScale = CAN_FILTERSCALE_32BIT;
filter.FilterIdHigh = 0x0000;
filter.FilterIdLow = 0x0000;
filter.FilterMaskIdHigh = 0x0000;
filter.FilterMaskIdLow = 0x0000;
filter.FilterFIFOAssignment = CAN_RX_FIFO0;
filter.FilterActivation = ENABLE;

HAL_CAN_ConfigFilter(&hcan, &filter);

Once the network works, tighten the filter to the identifiers the application actually needs.

Transmit a Standard CAN Frame with HAL

CAN_TxHeaderTypeDef txHeader = {0};
uint8_t data[8] = {0x12, 0x34, 0x56, 0x78, 0, 0, 0, 0};
uint32_t mailbox;

txHeader.StdId = 0x123;
txHeader.IDE = CAN_ID_STD;
txHeader.RTR = CAN_RTR_DATA;
txHeader.DLC = 8;

HAL_CAN_AddTxMessage(
    &hcan,
    &txHeader,
    data,
    &mailbox
);

The identifier 0x123 is only an example. On a vehicle network, do not transmit arbitrary frames until you understand the bus and the consequences.

Receive a Frame

CAN_RxHeaderTypeDef rxHeader;
uint8_t rxData[8];

HAL_CAN_GetRxMessage(
    &hcan,
    CAN_RX_FIFO0,
    &rxHeader,
    rxData
);

In a real project this is usually called from a receive interrupt/callback or task rather than continuously polling without structure.

Arduino IDE on Blue Pill

The official STM32 Arduino core supports the Blue Pill board, but CAN APIs are less universal than Arduino’s Wire or SPI interfaces.

Some projects use STM32-specific CAN libraries while others call the underlying STM32 HAL directly from an Arduino build.

The reliable architectural rule is the same: the STM32F103 hardware contains bxCAN, and the software must configure that peripheral correctly. Installing the STM32 board package does not automatically create a generic cross-platform CAN object.

Black Pill F411: Why a Transceiver Alone Does Not Work

WRONG for F411:

STM32F411 TX pin ─► SN65HVD230 ─► CANH/CANL
STM32F411 RX pin ◄─ SN65HVD230

The STM32F411 has no bxCAN or FDCAN peripheral. UART, SPI and GPIO cannot substitute for a hardware CAN controller simply by changing software.

How to Add CAN to an F401/F411 Black Pill

Use an external CAN controller connected over SPI, plus a CAN transceiver.

STM32F411
   │ SPI
   ▼
external CAN controller
   │ TX/RX
   ▼
CAN transceiver
   │
 CANH / CANL

The classic MCP2515 is one example of an external Classical CAN controller, though newer controllers may offer more performance or CAN FD support.

If CAN is a primary requirement, it may be simpler to choose an STM32 MCU that already includes bxCAN or FDCAN.

TJA1050 vs SN65HVD230 for a Vehicle

For a hobby bench node connected to a Blue Pill, the SN65HVD230 is attractive because the entire logic side runs at 3.3 V.

For a real vehicle module, transceiver selection should also consider automotive qualification, bus fault-voltage tolerance, ESD rating, transient protection, standby/sleep requirements, wake-up behaviour, EMC performance and logic-supply compatibility.

A breakout module that works on a desk is not automatically suitable for permanent installation in a vehicle electrical environment.

Connecting to an Existing Vehicle CAN Bus

  • Do not add another 120 Ω termination resistor unless you are replacing an existing endpoint.
  • Confirm the bus voltage and bit rate.
  • Use listen-only/silent mode initially.
  • Keep the stub short.
  • Share the correct ground reference or use isolation.
  • Protect the node against automotive transients.

Start as a passive listener. Transmitting unknown frames can trigger actuators, faults, diagnostic sessions or unexpected vehicle behaviour.

OBD-II CAN Pins

On vehicles using ISO 15765-4 CAN diagnostics through the standard 16-pin OBD-II connector, the normal CAN pins are:

OBD-II pinFunction
6CAN High
14CAN Low
4/5Ground references
16Battery positive

Do not power an unprotected 3.3 V development board directly from OBD pin 16. Vehicle battery supply requires proper regulation, reverse-polarity protection and transient protection.

Listen-Only / Silent Mode

When reverse-engineering or observing a vehicle network, use a controller/transceiver mode that prevents your node from driving dominant bits where possible.

This reduces the risk of your development board interfering with arbitration or transmitting error frames.

CAN Is Not the Same as OBD-II

CAN is the network transport and physical technology. OBD-II is a diagnostic system that can use CAN as one of its transports.

Seeing raw CAN frames on pins 6 and 14 does not mean every frame is an OBD PID response. Vehicle ECUs exchange large amounts of manufacturer-specific traffic unrelated to OBD-II diagnostics.

Standard vs Extended IDs

FormatIdentifier widthRange
Standard CAN11 bit0x000–0x7FF
Extended CAN29 bit0x00000000–0x1FFFFFFF

bxCAN supports both identifier types.

Why You Need an ACK

CAN transmitters expect another active node on the bus to acknowledge a valid frame.

A single CAN node connected to a correctly terminated cable but with no second active receiver may repeatedly retry transmission and accumulate errors because nobody asserts the ACK bit.

For a transmit bench test, use at least two active CAN nodes or a CAN adapter that acknowledges frames.

Error Counters and Bus-Off

CAN controllers maintain transmit and receive error counters. Repeated faults can move a node through error-active, error-passive and eventually bus-off states.

If a node suddenly stops transmitting after repeated wiring or bit-rate errors, inspect the CAN error state rather than only restarting application code.

Common Problem: No Frames at All

  • CAN controller not started.
  • Wrong RX/TX pins or remap.
  • Transceiver unpowered.
  • CANH/CANL swapped.
  • Wrong bit rate.
  • No common ground/reference.
  • Acceptance filter rejects everything.
  • Bus not active.

First verify electrical activity with an oscilloscope or CAN analyzer, then inspect controller configuration.

Common Problem: Only Errors, No Valid Frames

  • Wrong bit rate.
  • Wrong bit timing/sample point.
  • Termination incorrect.
  • CANH/CANL reversed.
  • Excessive stub length or reflections.
  • Faulty transceiver.
  • Ground/common-mode problem.

A wrong bitrate is the first thing to check when the bus visibly toggles but every decoder reports errors.

Common Problem: Works with Two Nodes but Fails in the Car

  • Extra termination resistor left enabled.
  • Long untwisted stub.
  • 5 V/3.3 V logic mismatch.
  • Automotive transients resetting the board.
  • Wrong vehicle bus selected.
  • Different bitrate than expected.
  • Ground offset.

Measure before rewriting software.

Common Problem: Bus Measures 40 Ω

Three 120 Ω termination resistors in parallel produce about 40 Ω.

That often happens when a development CAN module with onboard 120 Ω termination is connected to an already terminated vehicle network.

Remove the development-board terminator unless the node is genuinely replacing one physical bus endpoint.

Common Problem: Bus Measures 120 Ω

A powered-off network measuring around 120 Ω between CANH and CANL often indicates only one terminator is present or one end is disconnected.

A normal two-ended high-speed CAN network is commonly close to 60 Ω.

Common Problem: TJA1050 Module Works on Arduino Uno but Not STM32

Check logic levels. The TJA1050 uses a 5 V supply. Its TXD input can recognize a 3.3 V HIGH, but the RXD path is referenced to the 5 V transceiver domain.

Verify the STM32 CAN_RX pin is 5 V tolerant or add appropriate level conditioning. Do not assume every 3.3 V MCU input is safe.

Common Problem: SN65HVD230 Module Is Unstable at High Speed

  • Rs pin configured for excessive slope limiting.
  • Long stubs.
  • Poor termination.
  • Breadboard capacitance/inductance.
  • Untwisted wiring.
  • Bad 3.3 V supply decoupling.

A solderless breadboard is fine for initial low-speed experiments but is not a good model of a robust 1 Mbit/s automotive node.

Decoupling and Protection

Place local decoupling at the transceiver supply pins according to the datasheet. For permanent vehicle hardware, consider TVS protection, reverse-battery protection, transient-rated power supply design, EMC components and an automotive-qualified transceiver.

The exact protection network depends on required standards and environment; copying a hobby breakout is not sufficient engineering for production automotive electronics.

Isolation

Galvanically isolated CAN can be valuable between equipment with different ground domains, on industrial systems or when connecting expensive test hardware.

Isolation requires both signal isolation and an isolated power strategy for the bus-side transceiver. A standard TJA1050/SN65HVD230 module does not provide galvanic isolation.

Choosing the Right STM32 for CAN

NeedGood direction
Cheap Classical CAN boardSTM32F103 Blue Pill + transceiver
F411 performance + CANExternal CAN controller, or choose another STM32
Multiple CAN channelsSelect MCU with required CAN/FDCAN instances
CAN FDChoose STM32 with FDCAN + CAN-FD-capable transceiver
Automotive production nodeAutomotive-qualified MCU/transceiver/protection design

Recommended Bench-Test Sequence

  • Verify the MCU actually has a CAN controller.
  • Choose a transceiver compatible with MCU logic voltage.
  • Connect CAN_TX/CAN_RX to the correct controller pins.
  • Use a twisted CANH/CANL pair.
  • Install one 120 Ω terminator at each end.
  • Connect ground/reference between non-isolated nodes.
  • Configure a known bitrate such as 500 kbit/s.
  • Use an accept-all filter initially.
  • Connect a second CAN node or USB-CAN adapter.
  • Transmit one known standard frame.
  • Confirm ACK and receive traffic.
  • Only then connect to a real vehicle bus.

Final Recommendation

For a simple STM32 Classical CAN project, the STM32F103 Blue Pill remains an excellent choice because bxCAN is built into the MCU. Pair it with a suitable transceiver and the hardware architecture is straightforward.

Between the two transceivers in this guide, the SN65HVD230 is the cleaner electrical match for a 3.3 V STM32. The TJA1050 is a proven 5 V high-speed CAN transceiver, but its logic-voltage interface needs more care.

For real vehicle work, focus on the whole system rather than the breakout board: correct termination, short stubs, proper grounding, listen-only commissioning, automotive power protection and a transceiver whose fault/ESD ratings match the environment.

And remember the most important Black Pill warning: an STM32F401/F411 plus a CAN transceiver is not a complete CAN node. Those MCUs need an external CAN controller or a different STM32 with CAN/FDCAN built in.

Related STM32 Guides

Official Resources

Share your love