I plan to take a closer look at the STM32 family of microcontrollers, particularly its CAN Bus capabilities. I already have CAN Bus drivers for Arduino, ESP32, and Teensy for ARD1939, my SAE J1939 protocol stack for embedded systems. My goal is to bring those drivers and the new STM32 driver under one configuration file. By selecting the target platform in that file, I’ll be able to build ARD1939 with the appropriate CAN driver without changing the J1939 protocol code.
I’ll also use this CAN driver in my online book, CAN Bus Embedded Development. The examples will show how to configure the CAN controller, send and receive frames, and select the driver for the target platform in a single configuration file. I’ll then use ARD1939 to demonstrate how the same SAE J1939 application code can run on different boards.
Starting with the STM32G431
STM32 is STMicroelectronics’ family of 32-bit Arm Cortex-M microcontrollers. The devices vary in processing power, memory, and peripherals. For a CAN Bus project, the exact part number matters because it determines which CAN controller is available and what frame formats it supports.
I’ll start with the NUCLEO-G431RB development board. Its STM32G431RB microcontroller has an Arm Cortex-M4 core that runs at up to 170 MHz and an integrated FDCAN controller that supports both Classical CAN and CAN FD. I’ll add the SK Pang CAN FD shield available from Copperhill Technologies. The STM32’s built-in controller handles the CAN frames, and the shield’s Microchip MCP2562FD transceiver provides the electrical connection to the bus.
My first step will be to send and receive Classical CAN frames with 29-bit identifiers on a test network. Once that works, I’ll connect the driver to ARD1939 and test stack functions such as address claiming and PGN transmission.
A book for the groundwork
In the meantime, I want to spend some time on the technology and programming behind the STM32. This is where The STM32F103 Arm Microcontroller and Embedded Systems: Using Assembly and C, by Sepehr Naimi, Sarmad Naimi, and Muhammad Ali Mazidi, comes in handy.
The authors use the Blue Pill development board to teach Arm assembly and embedded C through practical examples. They cover topics such as GPIO, timers, interrupts, and serial interfaces, and the companion materials include source code and lab exercises. For engineers getting started with STM32, those exercises make it easier to see how firmware configures a peripheral and how the hardware signals that it has something for the software to handle.
The book’s examples use the Cortex-M3-based STM32F103. I’ll use them to brush up on peripheral programming and consult ST’s reference manual for the G431’s FDCAN configuration. That background comes in handy when debugging a driver. If a CAN frame never reaches the application, knowing how to inspect the controller’s configuration, status flags, and interrupts helps narrow down where it went missing.
I’ll document the project as it develops, from getting the first CAN frames onto the bus to running ARD1939 on the Nucleo board. The real test of the interface will come when I add another CAN controller and can run the same J1939 code on both platforms. More information…




