4.1. CMSIS-RTOS for STM32

4.1.1. Setting up and running EcMasterDemo in Keil µVision IDE

  1. Prerequisites
    • Keil µVision 5 IDE

    • STM32H747I-DISCO board

    • EtherCAT devices

  2. Connect the STM32H747I-DISCO development board to the PC according to user manual.

  3. Connect EtherCAT devices to the board.

  4. Create ENI file for EtherCAT configuration.
    xxd.exe is capable of converting ENI files to a C file as array, e.g.
    xxd.exe -i eni.xml ENI.c
    

    Replace ENI.c file with generated one. File should be manually modified to look like:

    unsigned char MasterENI_xml_data[] = {
    ...
    };
    unsigned int MasterENI_xml_data_size = ???;
    
  5. Start Keil µVision IDE and set the EcMasterDemoApp project as active.

  6. If needed, change debug project settings.

  7. Build and run EcMasterDemoApp.

4.1.2. OS Compiler settings

Besides the general settings from Compiling the EcMasterDemo the following settings are necessary to build the example application for CMSIS-RTOS (STM32).

Extra include paths
<InstallPath>/SDK/INC/CMSIS-RTOS
<InstallPath>/Examples/Common/CMSIS-RTOS_STM32
Extra source paths
<InstallPath>/Examples/Common/CMSIS-RTOS
<InstallPath>/Sources/OsLayer/CMSIS-RTOS
Extra library paths to the main EtherCAT components
<InstallPath>/SDK/LIB/CMSIS-RTOS/STM32H7
Extra libraries
EcMaster.lib
emllStm32Eth.lib
EcMasterDemo.lib

4.1.3. Setting up and running EcMasterDemo in STM32CubeIDE for STM32H747I-DISCO

  1. Prerequisites
  2. Environment variables

    In order to be able to build and run demo application the following environment variables (either system or project variables) has to be defined:

    • CMSIS_LOC, has to be set to the CMSIS package location, i.e. C:/CMSIS_5-5.7.0

    • FW_LOC, points to the firmware folder in STM32Cube repository, i.e. <PATH_TO_STM32CUBE_REPOSITORY>/STM32Cube_FW_H7_V1.8.0

    • PATH variable must contain the following paths (needed for tool chain):
      C:/ST/STM32CubeIDE_1.5.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.7-2018-q2-update.win32_1.5.0.202011040924/tools/bin
      C:/ST/STM32CubeIDE_1.5.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.make.win32_1.5.0.202011040924/tools/bin
      
    • PACKS_LOC, points to the packs location, where ARM CMSIS Drivers for external devices and STMicroelectronics STM32H7 Series Device Support and Examples were installed, i.e. C:/Users/<USER_NAME>/AppData/Local/Arm

  3. Build EcMasterDemo
    • Build the EcMasterDemo project

    • Create EtherCAT network configuration

    • Build the EcMasterDemo_STM32H747I-DISCO project for CM7 CPU

  4. Run on a STM32H747I-DISCO board
    • Connect the board to PC using CN2 connector. This connection will be used for powering the board and for debugging as well.

    • Connect EtherCAT cable to the Ethernet interface on the board and the EtherCAT slave(s).

    • Power on EtherCAT slave(s).

    • Using your favorite terminal application (i.e. Teraterm) connect to the serial port of STM32H747I-DISCO. Usually it is called STMicroelectronics STLink Virtual COM Port. Ensure it has the following settings: 115200,8,N,1.

    • Create a debug or run configuration, select STM32 Cortex-M C/C++ Application as template. For this configuration select SWD in GDB Server Command Line Options.

    Note

    in order to let the application run with different command line parameter please change szCommandLine declared in app_main.c