Skip to content

barisCanCoskun/stm32-canbus-node-communication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— stm32-canbus-node-communication

CAN Bus Communication Between Two STM32 Boards (Node-to-Node)

This project demonstrates CAN communication between two STM32 MCUs using the HAL library.
Node 1 periodically sends and requests data, while Node 2 responds and blinks LEDs based on received commands.
The setup closely follows the concept shown below, adapted to different hardware and extended with additional debugging tools.

project-overview

πŸ–ΌοΈ Project Overview

Node Board Role
Node 1 NUCLEO-L476RG CAN Master – sends and request data
Node 2 STM32F4-Discovery CAN Slave – responds, blinks LEDs

πŸ› οΈ Features

  • CAN initialization with HAL library
  • Node 1 sends LED number every 1 s via Data Frame
  • Node 2 toggles the corresponding LED on reception
  • Node 1 sends Remote Frame every 4 s requesting 2 bytes of data
  • Node 2 responds to Remote Frame with Data Frame
  • Fully interrupt-driven code (TX/RX callbacks)
  • UART debug output for monitoring CAN activity
  • Optional logic analyzer capture to verify timing

πŸ“‘ CAN Frame Format

Frame Type CAN ID DLC Direction Payload Example Purpose
LED Command 0x65D 1 Node1 ➜ Node2 02 Turns on LED #2 on Node2
Remote Request 0x651 2 (RTR) Node1 ➜ Node2 – Asks for 2 bytes of data
Remote Reply 0x651 2 Node2 ➜ Node1 01 2C Replies with 16-bit value (MSB first)

πŸ”§ Hardware Connections

Signal Node 1 Pin Node 2 Pin
CAN_RX PA11 PB8
CAN_TX PA12 PB9
GND GND GND

πŸ”§ Hardware Setup

Below is the actual setup used for this project:

can-hw-setup


About

CAN Bus Communication Between Two STM32 Boards (Node-to-Node)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages