ST STM32F4DISCOVERY, UM1467 Getting Started

September 2011 Doc ID 022172 Rev 1 1/46
UM1467
User manual
Getting started with software and firmware environments
for the STM32F4DISCOVERY Kit
1 Introduction
This document describes the software, firmware environment and development recommendations required to build an application around the STM32F4DISCOVERY board.
It presents the firmware applications package provided within this board with details on its architecture and contents. It provides guidelines to novice users on how to build and run a sample application and allows them to create and build their own application.
This document is structured as follows:
System requirements to use this board and how to run the built-in demonstration are
provided in Section 2: Getting started.
Section 3 describes the firmware applications package.
Section 5 presents development toolchain installation and overview of ST-LINK/V2
interface.
Section 6, Section 7, Section 8, and Section 9 introduce how to use the following software
development toolchains: – IAR Embedded Workbench® for ARM (EWARM) by IAR Systems – Microcontroller Development Kit for ARM (MDK-ARM) by Keil™ – TrueSTUDIO® by Atollic – TASKING VX-toolset for ARM Cortex by Altium
Although this user manual cannot cover all the topics relevant to software development environments; it demonstrates the first basic steps necessary to get started with the compilers/debuggers.
Reference documents
STM32F4DISCOVERY high-performance discovery board data brief
STM32F4DISCOVERY peripherals firmware examples (AN3983)
STM32F40x reference manual (RM0090)
STM32F405xx STM32F407xx datasheet
The above documents are available at www.st.com/stm32f4-discovery.
www.st.com
UM1467 Contents
Doc ID 022172 Rev 1 2/46
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1 System requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Running the built-in demonstration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Description of the firmware package . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 Libraries folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.1 CMSIS subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 STM32_USB_Device_Library subfolder . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.3 STM32_USB_HOST_Library subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.4 STM32_USB_OTG_Driver subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.5 STM32F4xx_StdPeriph_Driver subfolder . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Project folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1 Demonstration subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.2 Master_Workspace subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.3 Peripheral_Examples subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Utilities folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4 Binary images for reprogramming firmware applications . . . . . . . . . . 9
5 ST-LINK/V2 installation and development . . . . . . . . . . . . . . . . . . . . . . . 10
6 Using IAR Embedded Workbench® for ARM . . . . . . . . . . . . . . . . . . . . 11
6.1 Building an existing EWARM project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.2 Debugging and running your EWARM project . . . . . . . . . . . . . . . . . . . . . 12
6.3 Creating your first application using the EWARM toolchain . . . . . . . . . . . 14
6.3.1 Managing source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6.3.2 Configuring project options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
7 Using MDK-ARM Microcontroller Development Kit by Keil™ . . . . . . . 20
7.1 Building an existing MDK-ARM project . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.2 Debugging and running your MDK-ARM project . . . . . . . . . . . . . . . . . . . 21
7.3 Creating your first application using the MDK-ARM toolchain . . . . . . . . . 23
Contents UM1467
3/46 Doc ID 022172 Rev 1
7.3.1 Managing source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7.3.2 Configuring project options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
8 Using Atollic TrueSTUDIO® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.1 Building an existing TrueSTUDIO project . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.2 Debugging and running your TrueSTUDIO project . . . . . . . . . . . . . . . . . . 31
8.3 Creating your first application using TrueSTUDIO toolchain . . . . . . . . . . 32
9 Using TASKING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
9.1 Building an existing TASKING project . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
9.2 Debugging and running your TASKING project . . . . . . . . . . . . . . . . . . . . 40
9.3 Creating your first application using TASKING toolchain . . . . . . . . . . . . . 41
10 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
UM1467 Getting started
Doc ID 022172 Rev 1 4/46
2 Getting started
2.1 System requirements
Before running your application, you should establish the connection with the STM32F4DISCOVERY board as following.
Figure 1. Hardware environment
To run and develop any firmware applications on your STM32F4DISCOVERY board, the minimum requirements are as follows:
Windows PC (2000, XP, Vista, 7)
'USB type A to Mini-B' cable, used to power the board (through USB connector
CN1) from host PC and connect to the embedded ST-LINK/V2 for debugging and programming
Additional hardware accessories will be needed to run some applications:
'USB type A to Micro-B' cable, used to connect the board (through USB connector
CN5) as USB Device to host PC.
Headphone with male jack connector.
Getting started UM1467
5/46 Doc ID 022172 Rev 1
2.2 Running the built-in demonstration
The board comes with the demonstration firmware preloaded in the Flash memory. Follow the steps below to run it:
Check jumper position on the board, JP1 on, CN3 on (Discovery selected).
Connect the STM32F4DISCOVERY board to a PC with a 'USB type A to Mini-B'
cable through USB connector CN1 to power the board. Red LED LD2 (PWR) then lights up.
Four LEDs between B1 and B2 are blinking.
Press User Button B1 then MEMS sensor is enabled, move the board and observe
the four LEDs blinking according to the motion direction and speed.
If you connect a second 'USB type A to Micro-B' cable between PC and CN5
connector then the board is recognized as standard mouse and its motion will also control the PC cursor.
UM1467 Description of the firmware package
Doc ID 022172 Rev 1 6/46
3 Description of the firmware package
The STM32F4DISCOVERY firmware applications are provided in one single package and supplied in one single zip file. The extraction of the zip file generates one folder, STM32F4-Discovery_FW_VX.Y.Z, which contains the following subfolders:
Figure 2. Hardware environment
1. VX.Y.Z refer to the package version, ex. V1.0.0
3.1 Libraries folder
This folder contains the Hardware Abstraction Layer (HAL) for STM32F4xx Devices.
3.1.1 CMSIS subfolder
This subfolder contains the STM32F4xx and Cortex-M4F CMSIS files.
Cortex-M4F
CMSIS files consist of:
Core Peripheral Access Layer: contains name definitions, address definitions and
helper functions to access Cortex-M4F core registers and peripherals. It defines also a device independent interface for RTOS Kernels that includes debug channel definitions.
CMSIS DSP Software Library: features a suite of common signal processing
functions for use on Cortex-M processor based devices. The library is completely written in C and is fully CMSIS compliant. High performance is achieved through maximum use of Cortex-M4F intrinsics.
STM32F4xx CMSIS files consist of:
stm32f4xx.h: this file contains the definitions of all peripheral registers, bits, and
memory mapping for STM32F4xx devices. The file is the unique include file used in the application programmer C source code, usually in the main.c.
system_stm32f4xx.c/.h: This file contains the system clock configuration for
STM32F4xx devices. It exports SystemInit() function which sets up the system
Description of the firmware package UM1467
7/46 Doc ID 022172 Rev 1
clock source, PLL multiplier and divider factors, AHB/APBx prescalers and Flash settings. This function is called at startup just after reset and before connecting to the main program. The call is made inside the startup_stm32f4xx.s file.
startup_stm32f4xx.s: Provides the Cortex-M4F startup code and interrupt vectors for
all STM32F4xx device interrupt handlers.
3.1.2 STM32_USB_Device_Library subfolder
This subfolder contains USB Device Library Core and the class drivers.
The Core folder contains the USB Device library machines as defined by the revision 2.0 Universal Serial Bus Specification.
The Class folder contains all the files relative to the Device class implementation. It is compliant with the specification of the protocol built in these classes.
3.1.3 STM32_USB_HOST_Library subfolder
This subfolder contains USB Host Library Core and the class drivers.
The Core folder contains the USB Host library machines as defined by the revision 2.0 Universal Serial Bus Specification.
The Class folder contains all the files relative to the Host class implementation. It is compliant with the specification of the protocol built in these classes.
3.1.4 STM32_USB_OTG_Driver subfolder
This subfolder contains the low level drivers for STM32F4xx USB HS and FS cores. It provides an hardware abstraction layer, USB communication operations and interfaces used by the high level Host and Device Libraries to access the core.
3.1.5 STM32F4xx_StdPeriph_Driver subfolder
This subfolder contains sources of STM32F4xx peripheral drivers (excluding USB and Ethernet).
Each driver consists of a set of routines and data structures covering all peripheral functionalities. The development of each driver is driven by a common API (application programming interface) which standardizes the driver structure, the functions and the parameter names.
Each peripheral has a source code file, stm32f4xx_ppp.c, and a header file, stm32f4xx_ppp.h. The stm32f4xx_ppp.c file contains all the firmware functions required to use the PPP peripheral.
3.2 Project folder
This folder contains the source files of the STM32F4DISCOVERY firmware applications.
3.2.1 Demonstration subfolder
This subfolder contains the demonstration source files with preconfigured project for EWARM, MDK-ARM, TrueSTUDIO and TASKING toolchains.
UM1467 Description of the firmware package
Doc ID 022172 Rev 1 8/46
A binary images (*.hex and *.dfu) of this demonstration is provided under Binary subfolder. You can use the STM32F4xx’s embedded Bootloader or any in-system programming tool to reprogram the demonstration using this binary image.
3.2.2 Master_Workspace subfolder
This subfolder contains, for some toolchains, a multi-project workspace allowing you to manage all the available projects (provided under the subfolders listed below) from a single workspace window.
3.2.3 Peripheral_Examples subfolder
This subfolder contains a set of examples for some peripherals with preconfigured projects for EWARM, MDK-ARM, TrueSTUDIO and TASKING toolchains. See Section 5 and STM32F4DISCOVERY peripheral firmware examples, AN3983, for further details.
3.3 Utilities folder
This folder contains the abstraction layer for the STM32F4DISCOVERY hardware. It provides the following drivers:
stm32f4_discovery.c: provides functions to manage the user push button and 4 LEDs
(LD3.LD6)
stm32f4_discovery_audio_codec.c/.h: provides functions to manage the audio DAC
(CS43L22)
stm32f4_discovery_lis302dl.c/.h: provides functions to manage the MEMS
accelerometer (LIS302DL).
Binary images for reprogramming firmware applications UM1467
9/46 Doc ID 022172 Rev 1
4 Binary images for reprogramming firmware
applications
This section describes how to use the provided binary images to reprogram the firmware applications. The STM32F4DISCOVERY firmware package contains binary images (*.hex and *.dfu) of the provided applications which allow to use the STM32F4xx's embedded Bootloader or any in-system programming tool to reprogram these applications easily.
Below are the steps to follow:
Using “in-system programming tool”
Connect the STM32F4DISCOVERY board to a PC with a 'USB type A to Mini-B'
cable through USB connector CN1 to power the board.
Make sure that the embedded ST-LINK/V2 is configured for in-system
programming (both CN3 jumpers ON).
Use *.hex binary (for example,
\Project\Demonstration\Binary\STM32F4-Discovery_Demonstration_V1.0.0.hex) with your preferred in-system programming tool to reprogram the demonstration firmware (ex. STM32 ST-LINK Utility, available for download from www.st.com).
Using “Bootloader (USB FS Device in DFU mode)”
Configure the STM32F4DISCOVERY board to boot from “System Memory” (boot
pins BOOT0:1 / BOOT1:0)
Set BOOT0 pin to high level: on the male header P2 place a jumper between
BOOT0 pin and VDD pin
Set BOOT1(PB2) pin to low level: on the male header P1 place a jumper between
PB2 pin and GND pin
Connect a 'USB type A to Mini-B' cable between PC and USB connector CN1 to
power the board.
Connect a 'USB type A to Micro-B' cable between PC and USB connector CN5,
the board will be detected as USB device.
Use *.dfu binary (for example,
\Project\Demonstration\Binary\STM32F4-Discovery_Demonstration_V1.0.0.dfu) with “DFUse\DFUse Demonstration" tool (available for download from www.st.com) to reprogram the demonstration firmware.
UM1467 ST-LINK/V2 installation and development
Doc ID 022172 Rev 1 10/46
5 ST-LINK/V2 installation and development
STM32F4DISCOVERY board includes an ST-LINK/V2 embedded debug tool interface that is supported by the following software toolchains:
IAR™ Embedded Workbench for ARM (EWARM) available from www.iar.com
The toolchain is installed by default in the C:\Program Files\IAR Systems\Embedded Workbench 6.2 directory on the PC’s local hard disk.
After installing EWARM, install the ST-LINK/V2 driver by running the
ST-Link_V2_USB.exe from [IAR_INSTALL_DIRECTORY]\Embedded Workbench
6.2\arm\drivers\ST-Link \ST-Link_V2_USBdriver.exe
RealView Microcontroller Development Kit (MDK-ARM) toolchain available from
www.keil.com
The toolchain is installed by default in the C:\Keil directory on the PC’s local hard disk; the installer creates a start menu µVision4 shortcut.
When connecting the ST-LINK/V2 tool, the PC detects new hardware and asks to install the ST-LINK_V2_USB driver. The “Found New Hardware wizard” appears and guides you through the steps needed to install the driver from the recommended location.
Atollic TrueSTU D I O ® STM32 available from www.atollic.com
The toolchain is installed by default in the C:\Program Files\Atollic directory on the PC’s local hard disk.
The ST-Link_V2_USB.exe is installed automatically when installing the software toolchain.
Altium™ TA S K ING VX-toolset for ARM® Cortex-M available from www.tasking.com
The toolchain is installed by default in the “C:\Program Files\TASKING directory on the PC’s local hard disk. The ST-Link_V2_USB.exe is installed automatically when installing the software toolchain.
Note: The embedded ST-LINK/V2 supports only SWD interface for STM32 devices.
Refer to the firmware package release notes for the version of the supporting development toolchains.
Using IAR Embedded Workbench® for ARM UM1467
11/46 Doc ID 022172 Rev 1
6 Using IAR Embedded Workbench® for ARM
6.1 Building an existing EWARM project
The following is the procedure for building an existing EWARM project.
1. Open the IAR Embedded Workbench® for ARM (EWARM).
Figure 3 shows the basic names of the windows referred to in this document.
Figure 3. IAR Embedded Workbench IDE (Integrated Design Environment)
2. In the File menu, select Open and click Workspace to display the Open Workspace dialog box. Browse to select the demonstration workspace file and click Open to launch it in the Project window.
3. In the Project menu, select Rebuild All to compile your project.
UM1467 Using IAR Embedded Workbench® for ARM
Doc ID 022172 Rev 1 12/46
4. If your project is successfully compiled, the following window in Figure 4 is displayed.
Figure 4. EWARM project successfully compiled
6.2 Debugging and running your EWARM project
In the IAR Embedded Workbench IDE, from the Project menu, select Download and Debug or, alternatively, click the Download and Debug button the in toolbar, to program the
Flash memory and begin debugging.
Figure 5. Download and Debug button
The debugger in the IAR Embedded Workbench can be used to debug source code at C and assembly levels, set breakpoints, monitor individual variables and watch events during the code execution.
Using IAR Embedded Workbench® for ARM UM1467
13/46 Doc ID 022172 Rev 1
Figure 6. IAR Embedded Workbench debugger screen
To run your application, from the Debug menu, select Go. Alternatively, click the Go button in the toolbar to run your application.
Figure 7. Go button
UM1467 Using IAR Embedded Workbench® for ARM
Doc ID 022172 Rev 1 14/46
6.3 Creating your first application using the EWARM toolchain
6.3.1 Managing source files
Follow these steps to manage source files.
1. In the Project menu, select Create New Project and click OK to save your settings.
Figure 8. Create New Project dialog box
2. Name the project (for example, NewProject.ewp) and click Save to display the IDE interface.
Figure 9. IDE interface
To create a new source file, in the File menu, open New and select File to open an empty editor window where you can enter your source code.
Loading...
+ 32 hidden pages