CANopen Slave Documentation
Version 7.00.00
Loading...
Searching...
No Matches
STM32L476G-EVAL board

The CANopen FD Slave protocol stack for the STM32L476G-EVAL runs on a bit-rate of 500 kBit/s on interface CAN1. Please make sure that:

  • the CAN cable is connected to CN5
  • jumper JP4 is on position 1-2 (default setting), CAN high-speed mode active
  • jumper JP6 is set (termination resistor fitted)

For display of the CANopen network state the example uses the LEDs LD1 (green) and LD4 (red), the symbol COS_LED_SUPPORT is configured to 1.

Board STM32L476G-EVAL

The example uses Classical CANopen configuration (COS_FD_SUPPORT = 0).

Prerequisites

The example project can be built if the following programs are installed:

Please make sure that the value of WIN_TOOLCHAIN_PATH (for Windows) or UNIX_TOOLCHAIN_PATH (for macOS / Linux) inside the cmake/toolchain-gcc-<version>.cmake file is equal to the install path of the GNU Arm Embedded Toolchain.

#-----------------------------------------------------------------------------------------------------------------------
# set paths to the desired toolchains of corresponding OS
#
set(WIN_TOOLCHAIN_PATH "D:/devtools/GNU_ARM/13.2 Rel1" CACHE PATH "Windows toolchain for GNU ARM")
set(UNIX_TOOLCHAIN_PATH "/Applications/ArmGNUToolchain/13.2.Rel1/arm-none-eabi" CACHE PATH "Unix toolchain for GNU ARM")

How to build

Create a local build directory and start the build process within this directory. Make sure to pass the correct toolchain (i.e. GNU Arm Embedded Toolchain) to the CMake process via the parameter -DCMAKE_TOOLCHAIN_FILE. The following examples assume a GNU Arm Embedded Toolchain version 10.2.1.

Debug build

mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../../../../../../cmake/module/toolchain-gcc-13.2.1.cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .

Under Windows, you may have to add the parameter -G"Unix Makefiles" to the CMake configuration:

cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=./../../../../../cmake/module/toolchain-gcc-13.2.1.cmake -DCMAKE_BUILD_TYPE=Debug ..

Release build

mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../../../../../../cmake/module/toolchain-gcc-13.2.1.cmake ..
cmake --build .

Under Windows, you may have to add the parameter -G"Unix Makefiles" to the CMake configuration:

cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=./../../../../../cmake/module/toolchain-gcc-13.2.1.cmake ..

Testing with a CAN monitor tool

Upon reset, the example will transmit a boot-up message using the identifier 70Bh, representing the configured node-ID 11d.

Time-stamp ID Format DLC Data Comment
----------- ---- ------ --- ------------------------ ----------------------------
95151.24441 70B CBFF 1 00 Boot-up, node-ID 11

Writing a value of 100 ms to the heartbeat producer object (1017:00h) shall result in a cycle heartbeat transmission of the device.

Time-stamp ID Format DLC Data Comment
----------- ---- ------ --- ------------------------ ----------------------------
95155.73732 60B CBFF 8 22 17 10 00 64 00 00 00 Set 1017:00h (heartbeat) to 100 ms
95155.74072 58B CBFF 8 60 17 10 00 00 00 00 00 SDO response: OK
95155.84134 70B CBFF 1 7F heartbeat, node-ID 11, pre-operational
95155.94341 70B CBFF 1 7F heartbeat, node-ID 11, pre-operational
95156.04559 70B CBFF 1 7F heartbeat, node-ID 11, pre-operational