Using embOS with STM32CubeMX

From SEGGER Wiki
Revision as of 12:00, 5 February 2020 by Martin (talk | contribs) (Created page with "This article describes how '''embOS''' may be used with '''STM32CubeMX'''. == MadeForSTM32 == ''MadeForSTM32'' is a new quality label delivered by ST and is granted after an...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This article describes how embOS may be used with STM32CubeMX.

MadeForSTM32

MadeForSTM32 is a new quality label delivered by ST and is granted after an extended evaluation process. It helps engineers identify software solutions with the highest level of integration and quality for the STM32 microcontrollers’ ecosystem.

embOS was one of the first solutions to receive the MadeForSTM32 (v1) label in an advanced collaboration of SEGGER and ST Microelectronics. As a result, SEGGER has published the official I-CUBE-EMBOS expansion for STM32CubeMX, which may be used to generate ready-to-go embOS projects for use with ST's STM32F746-Discovery board and various IDEs. Furthermore, it may also be used as a starting point for creating further embOS projects for different evaluation boards and devices.

For more information on MadeForSTM32 and the I-CUBE-EMBOS expansion, please visit SEGGER.com.

Creating projects from scratch

To use embOS with STM32CubeMX, customers may either

  • use the I-CUBE-EMBOS expansion for STM32CubeMX and adopt it to their desired target hardware,
  • generate a project in STM32CubeMX and subsequently add all generated HAL files and further sources to the shipped embOS start project for their desired target hardware, or
  • generate a project in STM32CubeMX and subsequently add embOS to that generated project.

This article will walk readers through the latter approach. The described configuration of the target application in STM32CubeMX, however, applies and must therefore be followed in either approach.

Creating the basic project

Start STM32CubeMX and create a project for any specific target hardware. For this walk-through, we create a project for the 32F429IDISCOVERY board, but chosing any different evaluation board or device will work as well. After the project was initialized, feel free to add clock configurations, GPIO settings, middleware compontents and further settings as needed. The result should look similar to the screenshot below:

CubeMX InitialProject.png

When done configuring the project, begin to adopt it for embOS along the guidelines given in the following sections.

Setting up interrupt priorities for embOS

To prepare the project for use with embOS, care needs to be taken of the required interrupt handlers for using embOS with Cortex-M devices. To do so, navigate to System Core in the menu outline and select NVIC. In the editor window, select the NVIC tab and check the Enabled checkbox for both the Penadable request for system service and System tick timer as shown below:

CubeMX InterruptPriorities.png

Please also note the column Preemption Priority. With embOS for Cortex-M, specific rules for Interrupt prioritization apply:

  • embOS utilizes the Penadable request for system service to perform context switches; it must use the lowest priority in the entire system in all cases. Hence, it gets configured for a priority of 15 in this example.
  • embOS utilizes the System tick timer to generate a time base; it may use any valid priority for an embOS interrupt. Typically, however, using the second-to-lowest priority in the entire system is advised. In this example, it therefore gets configured for a priority of 14.
  • In case your application utilizes further interrupts (that shall use embOS API), please ensure these are configured for valid embOS interrupt priorities as well.

Configuring interrupt handler generation

STM32CubeMX may generate handlers for specific interrupt sources.

  • Since embOS includes its own handler implementation for the Penadable request for system service, that handler may not be generated by STM32CubeMX. To disable its creation, switch to the Code generation tab and uncheck the Generate IRQ handler checbox for this specific handler.
  • While embOS includes a handler implementation for the System tick timer as well, a seperate handler should be geenrated by STM32CubeMX. It should call HAL API functions (enable via according checkbox), which we will later use to call embOS' own handler implementation as a callback.
  • In case your application utilizes further interrupts, appropiate handlers for these may be generated as required.

CubeMX ISRGeneration.png

Generate the project

After generating of the project, open its location in the file system.

CubeMX FileSystem.png