Welcome to this Video Tutorial - my name is Ralf Kopsch, Senior Support Engineer for Keil
Microcontroller Software Development Tools!
We show you how simple it is, to start a new project based on CMSIS RTOS when using RTE,
the Runtime Environment, that is integrated in the new Microcontroller Development Kit
Version 5.
As target hardware I am using a STM32F4 Discovery board that I got at a recent trade show.
However - the project setup works similar for other Cortex-M microcontrollers that are
supported with a Device Pack in MDK Version 5.
You can replicate this Tutorial with a freely available MDK Lite version.
The Discovery Board uses the high-performance STM32F4 microcontroller family.
The devices are based on the Cortex-M4 processor and offer a rich set of peripherals.
Our Discovery Board uses the STM32F407VGT6 microcontroller, but check your actual microcontroller
since ST offers multiple board variants. The board uses an 8MHz XTAL, which is important
later for the system startup configuration. The Discovery Board includes many external
peripherals such as a Digital Accelerometer, a microphone, an
audio DAC with speaker amplifier, LEDs, push buttons and an USB port.
For the BLINKY example we will use the LED on Port D.13.
The Discovery Board includes also an ST-Link and the USB connector labeled CN1 interfaces For the BLINKY example we will use the LED on Port D.13.
The Discovery Board includes also an ST-Link and the USB connector labeled CN1 interfaces
to this ST-Link. We use a mini USB cable for power supply and
interface a PC based MDK debugger. On the PC we have already installed MDK Version
5 along with relevant Software Packs and the ST-Link driver.
Now we will start the uVision IDE and create our sample application. 5 along with relevant Software Packs and the ST-Link driver.
Now we will start the uVision IDE and create our sample application.
To create a new uVision project we select Project and next New uVision Project….
Create a suitable folder to store our project and enter a meaningful name, in this case
‘Blinky’.
‘Save’ creates the project - and in the next step we will select the device that is
used on our Discovery board.
In the Database we select ‘STMicroelectronics’ and pick the STM32F407VG from the list.
This device selection defines essential tool settings like the Memory Layout and the
Flash programming algorithm.
Now, the "Manage Run-Time Environment"-Window shows all available components from the installed Flash programming algorithm.
Now, the "Manage Run-Time Environment"-Window shows all available components from the installed
Software Packs for this selected device.
Our small Blinky project will be based on CMSIS RTOS and we therefore select the Keil Software Packs for this selected device.
Our small Blinky project will be based on CMSIS RTOS and we therefore select the Keil
RTX.
The Validation Output now shows dependencies to required software components, in our case
the Device Startup.
A click on a message in the Validation Output highlights related software components.
We use "Resolve" to automatically select other required software components.
Using this button selects the Device Startup and the CMSIS–CORE which completes our
Run Time Environment setup.
To apply this RTE setup simply click “OK”.
This creates the RTE components in our project tree and includes:
the Startup-file , the RTX configuration-file and the CMSIS system files.
Now we configure the CMSIS System file for our Discovery Kit,
which is using an 8MHz XTAL.
This system_stm32f4xx.c configuration file is located in the Device Group of
the project window.
The STM32 device will run at 168MHz core clock frequency – so we change now the
PLL-defines to reflect the 8MHz XTAL.
For details about this System-Clock Configuration please check the relevant Reference manual.
A direct link to this manual is available in the Books tab.
Some RTE components have Configuration Files that require Customization.
The RTX configuration file under the CMSIS group
can be modified using the MDK configuration wizard.
In this file we need to adjust the SysTick Timer Frequency
to 168MHz to match the core clock frequency.
We are using a CMSIS RTOS main.c template file, which we now add to our project.
To do this, right-click on ‘Source Group 1’ and use ‘Add New Item’.
Next select "User Code Template"
We choose the "CMSIS-RTOS main-function" and click "Add".
Then we open the Template File and start entering our application code:
Initially we insert the Device Header file using the context menu.
Then we add the code for the Blinky function and
define this function as a RTOS thread with normal priority. Then we add the code for the Blinky function and
define this function as a RTOS thread with normal priority.
Next we add code for the GPIO port initialization.
and then we add the start code for the Blinky thread using the ThreadCreate function.
Our little Blinky application is now complete and we use the Project–Build button to compile
and link the program code.
The Build Output Window reports potential syntax errors.
An error free build shows program size information and zero Errors and Warnings.
Before downloading our application to the Discovery board we need to select the
Debug and Flash programming unit.
Open the dialog Project – Options – Debug and select the ST-Link Debugger from the drop
down list.
At the Utilities-Tab ensure that “Use Debug Driver“ is selected
and verify the settings for the Flash-Algorithm.
To verify the settings for the Flash-algorithm open the Settings-dialog.
The ‘STM32F4xx Flash’ algorithm is suitable for the STM32F407VG microcontroller
mounted on our Discovery board.
Just use the Download button and the flash download progress is shown.
Now we start the Debugger…
...and click RUN to execute our Blinky application on the Discovery board.
The LED on the BOARD should now start to blink.
This completes our little demo example, offering an impression about the
Microcontroller Development Kit version 5 that you can download from our website
to explore this tool by yourself.
Visit www.keil.com or contact our sales team for further product details.
Thank you for your attention!