User manual - STMicroelectronics

User manual - STMicroelectronics

UM1523

User manual

Getting started with software and firmware environments for the

STM32F0DISCOVERY

k

it

Introduction

This document describes the software, firmware environment and development recommendations required to build an application around the STM32F0DISCOVERY 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 1: Getting started

.

Section 2

describes the firmware applications package.

Section 4

presents development toolchain installation and overview of ST-LINK/V2

interface.

Section 5

,

Section 6

,

Section 7

, and

Section 8

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.

Table 1

lists the microcontrollers and development tools concerned by this application note.

Table 1.

Applicable products and tools

Type Applicable products

Microcontrollers

Development tools

STM32 F0 series Entry-level Cortex™-M0 microcontrollers

STM32F0DISCOVERY evaluation board and discovery kit

Reference documents

STM32F0DISCOVERY high-performance discovery board data brief

STM32F0DISCOVERY peripherals firmware examples (AN4062)

STM32F0xx reference manual (RM0091)

STM32F051x4 STM32F051x6 STM32F051x8 datasheet

The above documents are available at www.st.com/stm32f0-discovery.

March 2012 Doc ID 022896 Rev 1 1/46

www.st.com

3

4

5

Contents

Contents

1

2

6

7

2/46

UM1523

Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.1

System requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.2

Running the built-in demonstration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Description of the firmware package . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.1

Libraries folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.1.1

2.1.2

CMSIS subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

STM32F0xx_StdPeriph_Driver subfolder . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.2

Project folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.2.1

2.2.2

2.2.3

Demonstration subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Master_Workspace subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Peripheral_Examples subfolder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.3

Utilities folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Binary images for reprogramming firmware applications . . . . . . . . . . 9

ST-LINK/V2 installation and development . . . . . . . . . . . . . . . . . . . . . . . 10

Using IAR Embedded Workbench® for ARM . . . . . . . . . . . . . . . . . . . . 11

5.1

Building an existing EWARM project . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

5.2

Debugging and running your EWARM project . . . . . . . . . . . . . . . . . . . . . 12

5.3

Creating your first application using the EWARM toolchain . . . . . . . . . . . 14

5.3.1

5.3.2

Managing source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Configuring project options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Using MDK-ARM Microcontroller Development Kit by Keil™ . . . . . . . 20

6.1

Building an existing MDK-ARM project . . . . . . . . . . . . . . . . . . . . . . . . . . 20

6.2

Debugging and running your MDK-ARM project . . . . . . . . . . . . . . . . . . . 21

6.3

Creating your first application using the MDK-ARM toolchain . . . . . . . . . 23

6.3.1

6.3.2

Managing source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Configuring project options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

Using Atollic TrueSTUDIO® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

7.1

Building an existing TrueSTUDIO project . . . . . . . . . . . . . . . . . . . . . . . . . 28

Doc ID 022896 Rev 1

UM1523

8

9

Contents

7.2

Debugging and running your TrueSTUDIO project . . . . . . . . . . . . . . . . . . 31

7.3

Creating your first application using TrueSTUDIO toolchain . . . . . . . . . . 32

Using TASKING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

8.1

Building an existing TASKING project . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

8.2

Debugging and running your TASKING project . . . . . . . . . . . . . . . . . . . . 40

8.3

Creating your first application using TASKING toolchain . . . . . . . . . . . . . 41

Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

Doc ID 022896 Rev 1 3/46

List of figures

List of figures

UM1523

Figure 1.

Hardware environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Figure 2.

Hardware environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Figure 3.

IAR Embedded Workbench IDE (Integrated Design Environment) . . . . . . . . . . . . . . . . . . 11

Figure 4.

EWARM project successfully compiled. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Figure 5.

Download and Debug button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Figure 6.

IAR Embedded Workbench debugger screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Figure 7.

Go button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Figure 8.

Create New Project dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Figure 9.

IDE interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Figure 10.

main.c example file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Figure 11.

Adding files to a project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Figure 12.

New project file tree structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Figure 13.

Configuring project options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Figure 14.

General options > Target tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Figure 15.

Linker > Config tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Figure 16.

Linker configuration file editor dialog box > Vector Table tab . . . . . . . . . . . . . . . . . . . . . . . 17

Figure 17.

Linker configuration file editor dialog box > Memory Regions tab . . . . . . . . . . . . . . . . . . . 17

Figure 18.

C/C++ Compiler > Preprocessor tab. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Figure 19.

Debugger > Setup tab. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Figure 20.

Select Flash loaders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Figure 21.

ST-Link communication protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Figure 22.

MDK-ARM µVision4 IDE environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Figure 23.

Build Output - MDK-ARM µVision4 project successfully compiled . . . . . . . . . . . . . . . . . . . 21

Figure 24.

Starting an MDK-ARM µVision4 debugging session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Figure 25.

MDK-ARM IDE workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Figure 26.

Creating a new project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Figure 27.

Device selection dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Figure 28.

Copy the STM32 Startup Code dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Figure 29.

main.c example file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Figure 30.

Adding source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Figure 31.

New project file tree structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Figure 32.

Target Options dialog box - Target tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

Figure 33.

Target Options dialog box - Debug tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Figure 34.

Target Options dialog box - Utilities tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Figure 35.

MDK-ARM µVision4 project successfully built . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Figure 36.

TrueSTUDIO workspace launcher dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Figure 37.

Atollic TrueSTUDIO®/STM32 Lite welcome screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Figure 38.

Atollic TrueSTUDIO®/STM32 Lite import source select dialog box . . . . . . . . . . . . . . . . . . 29

Figure 39.

Atollic TrueSTUDIO®/STM32 Lite import projects dialog box . . . . . . . . . . . . . . . . . . . . . . 30

Figure 40.

TrueSTUDIO® project successfully compiled. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Figure 41.

TrueSTUDIO Debug Configuration dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

Figure 42.

TrueSTUDIO Debug window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Figure 43.

TrueSTUDIO workspace launcher dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Figure 44.

TrueSTUDIO® C Project dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Figure 45.

TrueSTUDIO® Build Settings dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Figure 46.

TrueSTUDIO® Misc Settings dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Figure 47.

TrueSTUDIO® project successfully built . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Figure 48.

TASKING workspace launcher dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

4/46 Doc ID 022896 Rev 1

UM1523 List of figures

Figure 49.

TASKING VX-Toolset for ARM Cortex welcome screen. . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Figure 50.

TASKING import source select dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Figure 51.

TASKING import projects dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Figure 52.

TASKING project successfully compiled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Figure 53.

TASKING debug window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

Figure 54.

TASKING Workspace Launcher dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Figure 55.

TASKING New C/C++ Project dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Figure 56.

Processor selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Figure 57.

Debug configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Figure 58.

TASKING Import dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Figure 59.

Adding a new source file window.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Figure 60.

Tasking project successfully built . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Doc ID 022896 Rev 1 5/46

Getting started

Before running your application, you should establish the connection with the

STM32F0DISCOVERY board as following.

Figure 1.

Hardware environment

UM1523

1.2

To run and develop any firmware applications on your STM32F0DISCOVERY 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.

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 the jumper position on the board, JP2 on, CN2 on (Discovery selected).

Connect the STM32F0-DISCOVERY board to a PC with a 'USB type A to Mini-B' cable through USB connector CN1 to power the board. Then red LEDs LED1 (PWR) and

LED2 (COM) light up and green LED3 blinks.

Press user button B1 (Button left corner of the board). The blinking of green LED3 changes according to clicks on user button B1.

Each click on the USER push-button is confirmed by blue LED4.

6/46 Doc ID 022896 Rev 1

UM1523

2

Description of the firmware package

Description of the firmware package

The STM32F0DISCOVERY firmware applications are provided in one single package and supplied in one single zip file. The extraction of the zip file generates one folder,

STM32F0-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

This folder contains the Hardware Abstraction Layer (HAL) for STM32F0xx devices.

This subfolder contains the STM32F0xx and Cortex-M0 CMSIS files.

Cortex-M0

CMSIS files consist of:

Core Peripheral Access Layer: contains name definitions, address definitions and helper functions to access Cortex-M0 core registers and peripherals. It defines also a device independent interface for RTOS Kernels that includes debug channel definitions.

STM32F0xx CMSIS files consist of:

stm32f0xx.h: contains the definitions of all peripheral registers, bits, and memory mapping for STM32F0xx devices. The file is the unique include file used in the application programmer C source code, usually in main.c.

system_stm32f0xx.c/.h: contains the system clock configuration for STM32F0xx devices. It exports

SystemInit()

function which sets up the system 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_stm32f0xx.s file.

startup_stm32f0xx.s: provides the Cortex-M0 startup code and interrupt vectors for all

STM32F0xx device interrupt handlers.

Doc ID 022896 Rev 1 7/46

Description of the firmware package UM1523

2.1.2 STM32F0xx_StdPeriph_Driver subfolder

This subfolder contains sources of STM32F0xx peripheral drivers.

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, stm32f0xx_ppp.c, and a header file,

stm32f0xx_ppp.h. The stm32f0xx_ppp.c file contains all the firmware functions required to use the PPP peripheral.

This folder contains the source files of the STM32F0DISCOVERY firmware applications.

This subfolder contains the demonstration source files with preconfigured project for

EWARM, MDK-ARM, TrueSTUDIO and TASKING toolchains.

A binary image (*.hex) of this demonstration is provided under Binary subfolder. You can use any in-system programming tool to reprogram the demonstration using this binary image.

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.

This subfolder contains a set of examples for some peripherals with preconfigured projects

for EWARM, MDK-ARM, TrueSTUDIO and TASKING toolchains. See

Section 4

and

STM32F0DISCOVERY peripheral firmware examples, AN4062, for further details.

This folder contains the abstraction layer for the STM32F0DISCOVERY hardware. It provides the following drivers:

stm32f0_discovery.c: provides functions to manage the user push-button and 2 LEDs

(LED3 and LED4).

8/46 Doc ID 022896 Rev 1

UM1523

3

Binary images for reprogramming firmware applications

Binary images for reprogramming firmware applications

This section describes how to use the provided binary images to reprogram the firmware applications. The STM32F0DISCOVERY firmware package contains binary images (*.hex) of the provided applications under Binary subfolder. You can use any in-system programming tool to reprogram the demonstration using this binary image.

to reprogram the firmware applications, use the “in-system programming tool” and:

1.

Connect the STM32F0DISCOVERY board to a PC with a 'USB type A to Mini-B' cable through USB connector CN1 to power the board.

2. Make sure that the embedded ST-LINK/V2 is configured for in-system programming

(both CN3 jumpers ON).

3. Use *.hex binary (for example,

\Project\Demonstration\Binary\STM32F0-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).

Doc ID 022896 Rev 1 9/46

ST-LINK/V2 installation and development

4 ST-LINK/V2 installation and development

Note:

UM1523

STM32F0DISCOVERY 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.30 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.30\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 TrueSTUDIO® 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™ TASKING 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.

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.

10/46 Doc ID 022896 Rev 1

UM1523

5

Using IAR Embedded Workbench® for ARM

Using IAR Embedded Workbench® for ARM

5.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)

dialog box. Browse to select the demonstration workspace file and click Open to launch it in the Project window.

Doc ID 022896 Rev 1 11/46

Using IAR Embedded Workbench® for ARM UM1523

4.

If your project is successfully compiled, the following window in

Figure 4

is displayed.

Figure 4.

EWARM project successfully compiled

5.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.

12/46 Doc ID 022896 Rev 1

UM1523 Using IAR Embedded Workbench® for ARM

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

Doc ID 022896 Rev 1 13/46

Using IAR Embedded Workbench® for ARM

5.3

5.3.1

UM1523

Creating your first application using the EWARM toolchain

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

14/46

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.

Doc ID 022896 Rev 1

UM1523 Using IAR Embedded Workbench® for ARM

The IAR Embedded Workbench enables C color syntax highlighting when you save your file

using the dialog File > Save As… under a filename with the *.c extension. In

Figure 10: main.c example file

, the file is saved as main.c.

Figure 10.

main.c example file

Once you have created your source file, you can add this file to your project by opening the

Project menu, selecting Add and adding the selected file as in

Figure 11: Adding files to a project

.

Figure 11.

Adding files to a project

If the file is added successfully,

Figure 12: New project file tree structure

is displayed.

Figure 12.

New project file tree structure

Doc ID 022896 Rev 1 15/46

Using IAR Embedded Workbench® for ARM

5.3.2

UM1523

Configuring project options

Follow these steps to configure project options.

1.

In the Project Editor, right-click on the project name and select Options... to display the

Options dialog box as in

Figure 13

.

Figure 13.

Configuring project options

2. In the Options dialog box, select the General Options category, open the Target tab and select Device - ST -STM32F0xx.

Figure 14.

General options > Target tab

16/46 Doc ID 022896 Rev 1

UM1523 Using IAR Embedded Workbench® for ARM

pane, select Override default and click Edit to display the Linker configuration file editor.

Figure 15.

Linker > Config tab

the .intvec.start variable to

0x08000000

.

Figure 16.

Linker configuration file editor dialog box > Vector Table tab

the

Figure 17

.

Figure 17.

Linker configuration file editor dialog box > Memory Regions tab

Doc ID 022896 Rev 1 17/46

Using IAR Embedded Workbench® for ARM UM1523

7. If your source files include header files, select the C/C++ Compiler category, open the

Preprocessor tab, and specify their paths as shown in

Figure 18

. The path of the

include directory is a relative path, and always starts with the project directory location referenced by

$PROJ_DIR$

Figure 18.

C/C++ Compiler > Preprocessor tab

8. To set up the ST-Link embedded debug tool interface, select the Debugger category, open the Setup tab and, from the drop-down Driver menu, select ST-Link as shown in

Figure 19

.

Figure 19.

Debugger > Setup tab

the

Figure 20

.

Figure 20.

Select Flash loaders

18/46 Doc ID 022896 Rev 1

UM1523 Using IAR Embedded Workbench® for ARM

protocol as shown in

Figure 21

.

Figure 21.

ST-Link communication protocol

12. To build your project, follow the instructions given in

Section 5.1: Building an existing

EWARM project on page 11

.

13. Before running your application, establish the connection with the

STM32F0DISCOVERY board as described in

Section 1: Getting started

.

14. To program the Flash memory and begin debugging, follow the instructions given in

Section 5.2: Debugging and running your EWARM project on page 12

.

Doc ID 022896 Rev 1 19/46

Using MDK-ARM Microcontroller Development Kit by Keil™

6

UM1523

Using MDK-ARM Microcontroller Development Kit by

Keil™

6.1 Building an existing MDK-ARM project

Follow these steps to build an existing MDK-ARM project.

1.

Open the MDK-ARM µVision4 IDE, debugger, and simulation environment.

Figure 22: MDK-ARM µVision4 IDE environment

shows the basic names of the windows referred to in this section.

Figure 22.

MDK-ARM µVision4 IDE environment

20/46 box. Browse to select the STM32F0-Discovery.uvproj project file and click Open to launch it in the Project window.

Doc ID 022896 Rev 1

UM1523 Using MDK-ARM Microcontroller Development Kit by Keil™

4.

If your project is successfully compiled, the following Build Output window (

Figure 23:

Build Output - MDK-ARM µVision4 project successfully compiled

) is displayed.

Figure 23.

Build Output - MDK-ARM µVision4 project successfully compiled

6.2 Debugging and running your MDK-ARM project

In the MDK-ARM µVision4 IDE, click the magnifying glass to program the Flash memory

and begin debugging as shown below in

Figure 24

.

Figure 24.

Starting an MDK-ARM µVision4 debugging session

Doc ID 022896 Rev 1 21/46

Using MDK-ARM Microcontroller Development Kit by Keil™ UM1523

The debugger in the MDK-ARM IDE can be used to debug source code at C and assembly levels, set breakpoints, monitor individual variables and watch events during the code execution as shown below in

Figure 25

.

Figure 25.

MDK-ARM IDE workspace

22/46 Doc ID 022896 Rev 1

UM1523

6.3

6.3.1

Using MDK-ARM Microcontroller Development Kit by Keil™

Creating your first application using the MDK-ARM toolchain

Managing source files

Follow these steps to manage source files.

1.

In the Project menu, select New µVision Project... to display the Create Project File dialog box. Name the new project and click Save.

Figure 26.

Creating a new project

2.

When a new project is saved, the IDE displays the

Device selection dialog box

. Select

the device used for testing. In this example, we use the STMicroelectronics device mounted on the STM32F0DISCOVERY board: double-click on STMicroelectronics, select the STM32F051R8 device and click OK to save your settings.

Figure 27.

Device selection dialog box

project as shown in

Figure 28

.

Figure 28.

Copy the STM32 Startup Code dialog box

Note: The default STM32 startup file includes the SystemInit function. You can either comment out this file not to use it, or add the system_stm32f0xx.c file from the STM32f0xx firmware library.

Doc ID 022896 Rev 1 23/46

Using MDK-ARM Microcontroller Development Kit by Keil™ UM1523

To create a new source file, in the File menu, select New to open an empty editor window where you can enter your source code.

The MDK-ARM toolchain enables C color syntax highlighting when you save your file using the File > Save As… dialog under a filename with the *.c extension. In this example

(

Figure 29

), the file is saved as main.c.

Figure 29.

main.c example file

MDK-ARM offers several ways to add source files to a project. For example, you can select the file group in the Project Window > Files page and right-click to open a contextual menu. Select the Add Files... option, and browse to select the main.c file previously created.

Figure 30.

Adding source files

24/46

If the file is added successfully, the following window is displayed.

Figure 31.

New project file tree structure

Doc ID 022896 Rev 1

UM1523

6.3.2

Using MDK-ARM Microcontroller Development Kit by Keil™

Configuring project options

1.

In the Project menu, select Options for Target 1 to display the Target Options dialog box.

2. Open the Target tab and enter IROM1 and IARM1 Start and Size settings as shown in

Figure 32

.

Figure 32.

Target Options dialog box - Target tab

and select the SWD protocol. Click OK to save the ST-Link setup settings.

Doc ID 022896 Rev 1 25/46

Using MDK-ARM Microcontroller Development Kit by Keil™

Figure 33.

Target Options dialog box - Debug tab

UM1523

the ST-Link Debugger from the drop-down menu.

Figure 34.

Target Options dialog box - Utilities tab

26/46

9. If your project is successfully built, the following window is displayed.

Doc ID 022896 Rev 1

UM1523 Using MDK-ARM Microcontroller Development Kit by Keil™

Figure 35.

MDK-ARM µVision4 project successfully built

10. Before running your application, establish the connection with the

STM32F0DISCOVERY board as described in

Section 1: Getting started

.

11. To program the Flash memory and begin debugging, follow the instructions given in

Section 5.2: Debugging and running your EWARM project on page 12

.

Doc ID 022896 Rev 1 27/46

Using Atollic TrueSTUDIO® UM1523

7.1 Building an existing TrueSTUDIO project

1.

Open the TrueSTUDIO®/STM32 product folder and select the Atollic TrueSTUDIO®

STM32 product name. The program launches and asks for the Workspace location.

Figure 36.

TrueSTUDIO workspace launcher dialog box

2. Browse to select the STM32F0DISCOVERY Demonstration TrueSTUDIO workspace and click OK to save your settings and to display the Welcome screen. To start using

Atollic TrueSTUDIO®, click Start using TrueSTUDIO.

Figure 37.

Atollic TrueSTUDIO®/STM32 Lite welcome screen

28/46

3. The TrueSTUDIO Discovery workspace contains a demo project for the

STM32F0DISCOVERY kit. To load this project, select Import... in the File menu to display the Import dialog box.

Doc ID 022896 Rev 1

UM1523 Using Atollic TrueSTUDIO®

click Next.

Figure 38.

Atollic TrueSTUDIO®/STM32 Lite import source select dialog box

Doc ID 022896 Rev 1 29/46

Using Atollic TrueSTUDIO®

the STM32F0-Discovery project.

Figure 39.

Atollic TrueSTUDIO®/STM32 Lite import projects dialog box

UM1523

menu, and click Build Project.

8. If your project is successfully compiled, the following window is displayed.

Figure 40.

TrueSTUDIO® project successfully compiled

30/46 Doc ID 022896 Rev 1

UM1523

7.2

Using Atollic TrueSTUDIO®

Debugging and running your TrueSTUDIO project

In the Project Explorer, select the STM32F0-Discovery project and press F11 to display the Debug Configuration dialog box.

Figure 41.

TrueSTUDIO Debug Configuration dialog box

Doc ID 022896 Rev 1 31/46

Using Atollic TrueSTUDIO® UM1523

the

Figure 41

and click OK to save your

settings and to program the Flash memory and begin debugging.

Figure 42.

TrueSTUDIO Debug window

7.3

The debugger in the Atollic TrueSTUDIO can be used to debug source code at C and assembly levels, set breakpoints, monitor individual variables and watch events during the code execution.

To run your application, from the Run menu, select Resume, or alternatively click the

Resume button in the toolbar.

Creating your first application using TrueSTUDIO toolchain

TrueSTUDIO includes a dedicated connection to the STM32F0DISCOVERY board. When choosing this connection, all required files (startup file, firmware library, etc.) are added to the workspace and sample files are generated in the project folder to simplify the development. The debug settings are automatically configured by selecting

STM32F0DISCOVERY as the evaluation board.

Follow these steps to create your first application using TrueSTUDIO toolchain.

1.

Open the TrueSTUDIO®/STM32 product folder and select the Atollic TrueSTUDIO®

STM32 product name. The program launches and asks for the Workspace location.

Browse to select an existing workspace, or enter a new workspace location and click

OK to confirm.

32/46 Doc ID 022896 Rev 1

UM1523

Figure 43.

TrueSTUDIO workspace launcher dialog box

Using Atollic TrueSTUDIO®

2. When the Atollic TrueSTUDIO® displays its Welcome window, click Start using

TrueSTUDIO to open the main window. In the File menu, select New and click C

Project.

3. Name the new project, select STM32 C Project in the Project type pane, then click

Next.

Figure 44.

TrueSTUDIO® C Project dialog box

Doc ID 022896 Rev 1 33/46

Using Atollic TrueSTUDIO® UM1523

Evaluation board, configure the other settings as shown in

Figure 45

and click Next.

Figure 45.

TrueSTUDIO® Build Settings dialog box

Note: Choosing STM32F0DISCOVERY as the evaluation board will configure the project as follows:

Microcontroller: STM32F051R8

Debug probe: ST-LINK

Connection: Serial Wire Debug (SWD).

34/46 Doc ID 022896 Rev 1

UM1523

Figure 46.

TrueSTUDIO® Misc Settings dialog box

Using Atollic TrueSTUDIO®

6. Your project has been created successfully. Atollic TrueSTUDIO® generates target specific sample files (main.c, stm32f0xx_it.c...) in the Project folder to simplify the development. You can tailor this project to your needs by modifying these sample files.

7. To build your project, click Build Project in the Project menu.

8. Your project is compiled successfully.

Figure 47.

TrueSTUDIO® project successfully built

9. Before running your application, establish the connection with the

STM32F0DISCOVERY board as described in

Section 1: Getting started

. To program the Flash memory and begin debugging, follow the instructions given in

Section 7.2:

Debugging and running your TrueSTUDIO project on page 31

.

Doc ID 022896 Rev 1 35/46

Using TASKING UM1523

8.1 Building an existing TASKING project

Follow these steps to build an existing TASKING project.

1.

Open the TASKING VX-toolset for ARM Cortex IDE. The program launches and asks for the Workspace location.

Figure 48.

TASKING workspace launcher dialog box

2. Browse to select the STM32F0DISCOVERY Demonstration TASKING workspace and click OK to save your settings and to display the Welcome screen. To start using

TASKING, click Go to the workbench.

Figure 49.

TASKING VX-Toolset for ARM Cortex welcome screen

36/46 Doc ID 022896 Rev 1

UM1523 Using TASKING

3. The TASKING Discovery workspace contains a demo project for the

STM32F0DISCOVERY kit. To load this project, select Import... in the File menu to display the Import dialog box.

click Next.

Figure 50.

TASKING import source select dialog box

Doc ID 022896 Rev 1 37/46

Using TASKING

STM32F0-Discovery project.

Figure 51.

TASKING import projects dialog box

UM1523

menu, and click Build Project.

38/46 Doc ID 022896 Rev 1

UM1523 Using TASKING

8. If your project is compiled successfully, the following window is displayed.

Figure 52.

TASKING project successfully compiled

Doc ID 022896 Rev 1 39/46

Using TASKING UM1523

8.2 Debugging running your TASKING project

Figure 53

shows the first step for debugging and running your TASKING project. From the project toolbar menu, select Debug > Debug STM32F0-Discovery_Demo.

Figure 53.

TASKING debug window

The debugger in TASKING can be used to debug source code at C and assembly levels, set breakpoints, monitor individual variables and watch events during the code execution.

To run your application, from the Run menu, select Resume, or alternatively click the

Resume button in the toolbar.

40/46 Doc ID 022896 Rev 1

UM1523

8.3

Using TASKING

Creating your first application using TASKING toolchain

The debug session is launched as follows:

1.

Open TASKING VX-Toolset for ARM Cortex. The program launches and asks for the

Workspace location. Browse to select an existing workspace, or enter a new workspace location and click OK to confirm.

Figure 54.

TASKING Workspace Launcher dialog box

2. When TASKING displays its Welcome window, click Go to workbench to open the main window. In the File menu, select New > TASKING VX-toolset for ARM C/C++

Project.

Project type box, select TASKING ARM Application and click Next.

Figure 55.

TASKING New C/C++ Project dialog box

Doc ID 022896 Rev 1 41/46

Using TASKING

4. From the list of supported devices, select STMicroelectronics > STM32F051 >

STM32F0518R8 as shown below in

Figure 56

.

Figure 56.

Processor selection

UM1523

5. To configure the project for Manta DISCOVERY board, select Debug > Debug

configurations and choose STMicroelectronics STM32F0 Stingray Discovery Kit.

Choosing STMicroelectronics STM32F0 Stingray Discovery Kit as the evaluation board, will add automatically the needed linker file and will configure the project as follows:

– Microcontroller: STM32F051R8

– Debug probe: ST-LINK

– Connection: Serial Wire Debugging (SWD).

Figure 57.

Debug configuration

42/46 Doc ID 022896 Rev 1

UM1523 Using TASKING

6. To add source file to your project, right-click on the project from the C/C++ project window and select Import.

the

Figure 58:

TASKING Import dialog box

.

Figure 58.

TASKING Import dialog box

Doc ID 022896 Rev 1 43/46

Using TASKING

Figure 59.

Adding a new source file window.

UM1523

10. To build your project, click on Project > Build Project from the toolbar menu.

11. Your project is compiled successfully.

Figure 60.

Tasking project successfully built

44/46

12. Before running your application, establish the connection with the

STM32F0DISCOVERY board as described in

Section 1: Getting started

.

Doc ID 022896 Rev 1

UM1523

Table 2.

Date

Document revision history

Revision

23-Mar-2012 1 Initial release.

Changes

Revision history

Doc ID 022896 Rev 1 45/46

UM1523

Please Read Carefully:

Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice.

All ST products are sold pursuant to ST’s terms and conditions of sale.

Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described herein.

No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein.

UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED

WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED

WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS

OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.

UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES, ST PRODUCTS ARE NOT

RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING

APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,

DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE

GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.

Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any liability of ST.

ST and the ST logo are trademarks or registered trademarks of ST in various countries.

Information in this document supersedes and replaces all information previously supplied.

The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.

© 2012 STMicroelectronics - All rights reserved

STMicroelectronics group of companies

Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan -

Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America

www.st.com

46/46 Doc ID 022896 Rev 1

Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project