· st st di fea in th to at k fo li k th r w th s se co sw co e et as an no d th ul th k...

37
ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K TMicroelectronics TMicroel scovery aturing Ser ntroductio he purpose of t olkit featuring t the end of thi eil MDK supp or the complete inux: For ST eil MDK-Litehis 32K limit. T TX RTOS: A Why Use K 1. μVision ARM ® 2. A full f comes w 3. Serial W 4. RTX K 5. Keil Te renewa his document 1. Serial W 2. Real-tim intrusiv 3. Six Har 4. RTX V 5. A DSP erial Wire erial Wire Vie ounters and a ti WV does not s oreSight displa mbedded TM records an s “going into th nalysis and cod ot have the ETM Discovery he STM32F407 LINK2, ULIN he Keil MCBST eil MDK has e s Discovery STM The For lectroni y evalua rial Wire Vi on: this lab is to int the IDE μVisi is tutorial, you orts and has ex e list which is a processors run is a free eval The addition of All variants of M Keil MDK ? n IDE with Inte Compiler tool feature Keil RT with a BSD typ Wire Viewer an Kernel Awarene echnical Suppo able. This help details these f Wire Viewer (S me Read and W ve to your prog rdware Breakp Viewer: a kerne example progr e Viewer ( ewer (SWV) di imestamp. Thi teal any CPU c ays memory co Trace Ma nd displays all i he weeds” and de execution ti M connector ev Board Deb 7 Discovery bo NKpro or J-Link TM32 series or examples and la M32F4 Lab with A latest version a CAN lab on t cs: Cort ation bo iewer Sum troduce you to ion ® . We will u will be able to xamples for mo also included in nning Linux, A luation version f a valid licens MDK contain t ? MDK pro egrated Debug chain. MDK i TOS called RT pe license. Sou nd ETM trace c ess window. It ort is included f s you get your features: SWV) and ETM Write to memor gram. No CPU points (can be s l awareness pr ram using ARM (SWV): isplays PC Sam is information cycles and is co ontents and var acrocell (E instructions tha “how did I get imes. ETM req ven though the bug Adap oard lacks the s k to these boar r a STM32xxx- abs for these b ARM ® Keil™ MD of this docum the STM32F4 D tex™-M4 ard using mer 2014 V the STMicroe use the Serial W o confidently w ost ST ARM pr n MDK: in μV Android and bar n that limits cod se number will the full version ovides these f gger, Flash prog is a turn-key pr X is included w urce code is pr capability is in t is updated in for one year an project compl M trace. Real- ry locations for U cycles are sto set/unset on-the rogram for the K M CMSIS-DSP mples, Exceptio comes from th ompletely non- riable values in ETM): at were execute t here?”. Keil μ quires a specia e processor has ter Conne standard ARM ds. In order to -EVAL board. oards. This do K toolkit 1 ent is here: Discovery: 4 Traini g ARM ® K Version 1.2 Rob electronics Cor Wire Viewer (S work with these rocessors. Che Vision, select P re metal are su de size to 32 K turn MDK into n of RTX with features part grammer and th roduct. with MDK. RT rovided. ncluded. real-time. nd is easily eted faster. time tracing up r Watch, Mem len. No instru e-fly) and four Keil RTX RTO P libraries. ww ons (including he ARM CoreS -intrusive. (exc n real-time and ed. This is ver μVision uses E l debug adapte s ETM. Most o ections: M debugger con o use features li Versions are ocument uses o Copyright © 2014 www.keil www.keil ing STM eilMDK bert Boys, bob.b rtex™-M4 proc SWV) and the e processors an eck the Keil De Project/Select D upported by AR Kbytes. Nearly o a full comme source code. S ticularly suit the TX pdated while th mory and RTX T umentation cod Watchpoints ( OS that update ww.arm.com/cm interrupts), da Sight™ debug m cept for the ITM these can be m ry useful for de ETM to provide er such as the U other ST and al nnections. This ike ETM trace available with only the on-boa ARM Limited or its aff www.keil.co .com/appnotes .com/appnotes M32F4 K 5 toolkit b[email protected] cessor using th on-board ST-L nd Keil MDK. evice Database Device for targe RM DS-5 . ww y all Keil examp ercial version. See www.keil. ted for Corte he program is r Tasks window de is added to y (also known as es while your p msis ata reads and w module integra M Debug print modified on-the ebugging progr e Code Covera ULINKpro. Th ll Keil boards d s means it is no e, it is easier to Cortex-M3 an ard ST-LINK. filiates. All rights reser om/st s/docs/apnt_23 s/docs/apnt_23 t he ARM ® KeilLink V2 Debug See www.keil e ® on www.kei et… ww.arm.com/d ples will comp com/rl-arm/ker ex-M process running. s. These are n your source file s Access Break rogram is runn writes, ITM (pri ated into STM3 tf Viewer). e-fly. ram flow probl age, Performan he Discovery s do have this co ot easy to conn obtain a board nd Cortex-M4 p See www.keil rved 30.asp 36.asp MDK g Adapter. l.com/st. il.com/dd ds5. pile within rnel.asp. or users: non- es. ks). ning. intf), CPU 32 CPU. lems such nce series do onnector. nect a d such as processors. l.com/st.

Upload: others

Post on 20-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

STDifea

InThtoAt

Kfo

Li

Kth

R

W

Th

SSecoSW

Co

EETasAnno

DThULthK

TMicroelectronics

TMicroelscovery

aturing Ser

ntroductiohe purpose of tolkit featuringt the end of thi

eil MDK suppor the complete

inux: For ST

eil MDK-Lite™

his 32K limit. T

TX RTOS: A

Why Use K1. µVision

ARM®

2. A full fcomes w

3. Serial W

4. RTX K

5. Keil Terenewa

his document

1. Serial W

2. Real-timintrusiv

3. Six Har

4. RTX V

5. A DSP

erial Wireerial Wire Vieounters and a tiWV does not s

oreSight displa

mbedded TM records ans “going into thnalysis and codot have the ETM

Discovery he STM32F407LINK2, ULIN

he Keil MCBSTeil MDK has e

s Discovery STM

The For

lectroniy evaluarial Wire Vi

on:

this lab is to intthe IDE μVisi

is tutorial, you

orts and has exe list which is a

processors run

™ is a free evalThe addition of

All variants of M

Keil MDK ?n IDE with InteCompiler tool

feature Keil RTwith a BSD typ

Wire Viewer an

Kernel Awarene

echnical Suppoable. This help

details these f

Wire Viewer (S

me Read and Wve to your prog

rdware Breakp

Viewer: a kerne

example progr

e Viewer (ewer (SWV) diimestamp. Thiteal any CPU c

ays memory co

Trace Mand displays all ihe weeds” and de execution tiM connector ev

Board Deb7 Discovery bo

NKpro or J-LinkTM32 series orexamples and la

M32F4 Lab with A

latest version a CAN lab on t

cs: Cortation boiewer Sum

troduce you toion®. We will uwill be able to

xamples for moalso included in

nning Linux, A

luation versionf a valid licens

MDK contain t

? MDK proegrated Debugchain. MDK i

TOS called RTpe license. Sou

nd ETM trace c

ess window. It

ort is included fs you get your

features:

SWV) and ETM

Write to memorgram. No CPU

points (can be s

l awareness pr

ram using ARM

(SWV): isplays PC Samis information cycles and is co

ontents and var

acrocell (Einstructions tha“how did I getimes. ETM reqven though the

bug Adapoard lacks the sk to these boarr a STM32xxx-abs for these b

ARM® Keil™ MD

of this documthe STM32F4 D

tex™-M4ard using

mer 2014 V

the STMicroeuse the Serial Wo confidently w

ost ST ARM prn MDK: in μV

Android and bar

n that limits codse number will

the full version

ovides these fgger, Flash progis a turn-key pr

X is included wurce code is pr

capability is in

t is updated in

for one year anproject compl

M trace. Real-

ry locations forU cycles are sto

set/unset on-the

rogram for the K

M CMSIS-DSP

mples, Exceptiocomes from thompletely non-

riable values in

ETM): at were executet here?”. Keil µquires a speciae processor has

ter Connestandard ARMds. In order to-EVAL board. oards. This do

K toolkit

1

ent is here: Discovery:

4 Trainig ARM® K

Version 1.2 Rob

electronics CorWire Viewer (S

work with these

rocessors. CheVision, select P

re metal are su

de size to 32 Kturn MDK into

n of RTX with

features partgrammer and throduct.

with MDK. RTrovided.

ncluded.

real-time.

nd is easily eted faster.

time tracing up

r Watch, Memlen. No instru

e-fly) and four

Keil RTX RTO

P libraries. ww

ons (including he ARM CoreS-intrusive. (exc

n real-time and

ed. This is verµVision uses El debug adapte

s ETM. Most o

ections: M debugger cono use features li

Versions are ocument uses o

Copyright © 2014

www.keilwww.keil

ing STMeil™ MDK

bert Boys, bob.b

rtex™-M4 procSWV) and the e processors an

eck the Keil DeProject/Select D

upported by AR

Kbytes. Nearlyo a full comme

source code. S

ticularly suitthe

TX

pdated while th

mory and RTX Tumentation cod

Watchpoints (

OS that update

ww.arm.com/cm

interrupts), daSight™ debug mcept for the ITM

these can be m

ry useful for deETM to provideer such as the Uother ST and al

nnections. Thisike ETM traceavailable with

only the on-boa

ARM Limited or its aff

www.keil.co

.com/appnotes

.com/appnotes

M32F4 K 5 toolkit

[email protected]

cessor using thon-board ST-L

nd Keil MDK.

evice DatabaseDevice for targe

RM DS-5™. ww

y all Keil exampercial version.

See www.keil.

ted for Corte

he program is r

Tasks windowde is added to y

(also known as

es while your p

msis

ata reads and wmodule integraM Debug print

modified on-the

ebugging progre Code Covera

ULINKpro. Thll Keil boards d

s means it is noe, it is easier to

Cortex-M3 anard ST-LINK.

filiates. All rights reser

om/st

s/docs/apnt_23s/docs/apnt_23

t

he ARM® Keil™Link V2 DebugSee www.keil

e® on www.keiet…

ww.arm.com/d

ples will comp

com/rl-arm/ker

ex-M process

running.

s. These are nyour source file

s Access Break

rogram is runn

writes, ITM (priated into STM3tf Viewer).

e-fly.

ram flow problage, Performanhe Discovery sdo have this co

ot easy to connobtain a board

nd Cortex-M4 p See www.keil

rved

30.asp 36.asp

™ MDK g Adapter. l.com/st.

il.com/dd

ds5.

pile within

rnel.asp.

or users:

non-es.

ks).

ning.

intf), CPU 32 CPU.

lems such nce series do onnector.

nect a d such as processors. l.com/st.

Page 2:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

2

1. Keil Evaluation Software: 3

2. Keil Software Download and Installation: 3

3. On-board ST-Link V2 Debug Adapter: 3

4. Example Programs 3

5. Getting Started MDK 5 Manual: 3

6. µVision Software Packs Download and Install Process: 4

7. Testing the ST-Link V2 Connection: 5

8. Installing the ST-Link USB Drivers: 5

9. Blinky example using the STM32F4 Discovery board: 6

10. Hardware Breakpoints: 6

11. Call Stack & Locals window: 7

12. Watch and Memory windows and how to use them: 8

13. How to view Local Variables in Watch and Memory windows: 9

14. View Variables Graphically with the Logic Analyzer (LA): 10

15. Watchpoints: Conditional Breakpoints (Access Breakpoints) 11

16. RTX_Blinky example: Keil RTX RTOS: 12

17. RTX Kernel Awareness using RTX Viewer: 13

18. Logic Analyzer: View variables real-time in a graphical format: 14

19. ITM (Instrumentation Trace Macrocell): 15

20. Serial Wire Viewer (SWV) and how to use it: 16

1) Data Reads and Writes 16

2) Exceptions and Interrupts 17

3) PC Samples (program counter samples) 18

21. Serial Wire Viewer (SWV) Configuration: 19

22. DSP Sine Example using ARM CMSIS-DSP Libraries 20

23. Creating your own project from scratch: 24

24. Creating your own RTX RTOS project from scratch: 27

25. ETM Trace and its benefits: for reference 28

26. Configuring the ST-Link V2: 33

27. Configuring the Keil Flash Programmer: 34

28. Serial Wire Viewer and ETM summary: 35

29. Document Resources: 36

30. Keil Products and contact information: 37

Notes on using this document:

1. The latest version of this document and the necessary example source files are available here: www.keil.com/appnotes/docs/apnt_230.asp

2. MDK 5.10 was used in the exercises in this document.

3. To use MDK 4.7x, see www.keil.com/appnotes/docs/apnt_261.asp

4. The on-board ST-Link V2 is used by default in this document. All you need install is the USB driver to your PC.

5. The ST-Link V2 interfaces very well with Keil µVision and its performance is quite good including SWV.

Page 3:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

1Mth

MTh

Mth

W

K

Th

2

3Thco

4MRTww

5

TMicroelectronics

) Keil EvaMDK 5 now usehe Packs you ne

MDK 4.7x is stihe older versio

MDK 4 projectshen run legacy M

We recommend

eil has several

his document

) Keil Sof1. Downlo

2. Install M

3. We rec

4. If you i

6. The exa

7. You can

8. You do

) The on-he on-board STontains a test fo

) ExamplMDK 5 Softwar

TX_Blinky5 anww.keil.com/a

) Getting

STM32STM32F4processor u

STM32F4This board

Changing

In the file s

Change the

You will hThe DSP5

Note: The

#defi#defi

s Discovery STM

aluation Ses Software Paeed will be dow

ill available. Mon of this docum

can be used wMDK 4 projec

that MDK 5.1

labs for variou

uses only MD

ftware Dooad MDK 5.10

MDK into the

ommend you u

install MDK in

ample DSP5 is

n use the evalu

o not need any

-board STT-Link V2 is uor the ST-Link

le Programre Pack containnd the DSP exa

appnotes/docs/a

g Started M

F401C-DI4-Discovery: Tusing a CPU sp

401C-DISCO: d contains a ST

the clock spee

system_stm32

ese values acco

have to modify example runs

Software Pack

ine PLL_M ine PLL_Q

M32F4 Lab with A

Software: acks to distributwnloaded from

MDK 4.7x contment written fo

with MDK 5 byts without any

0 Software pac

us STM32 proc

DK 5.10 or late

ownload a0 or later from t

default directo

use the default

nto a different d

s available on t

uation version (

debug adapters

T-Link V2 Dsed exclusivelyV2 drivers.

ms: ns a Blinky andample (DSP5) apnt_230.asp.

MDK 5: Ob

SCO DiscoThis tutorial is peed of 168 MH

This newer boTM32F401VCT

ed:

2f4xx.c near lin

ording to the pr

the Core Clockat 57 MHz so n

k for STM32F4

STM32

ARM® Keil™ MD

MDK 4.7te processor sp

m the web. The

tains all the fileor MDK 4 is av

y using the LegSoftware Pack

cks are used if

cessors includi

er.

and Instalthe Keil websi

ory. You can in

directories for

directory, you w

he web where

(MDK-Lite) fo

s: just the Disc

Debug Ady in this lab. In

d RTX_Blinky is available on

btain this usefu

overy Boawritten for theHz. The numb

oard will workT6U processor.

nes 254 and 25

rocessor you ar

k: value in the no modificatio

401C-DISCO c

2F4-Discover8 7

K toolkit

3

x and MDpecific softwareey can also be i

es needed to ruvailable here:

gacy install softks.

they are availa

ng one using C

lation: ite. www.keil.c

nstall into any

r this tutorial. W

will have to ad

you got this do

or this lab. No

covery board, a

dapter: nstructions on

example progrn the web wher

ul book here: w

ard: e STM32F4-Diber MB997B o

k but the CPU c. STM32F401

6 are two #def

re using as foll

Trace Config on is needed.

contains Blinky

ry 168 MHz

Copyright © 2014

K 5 e, examples animported manu

un projects. Thwww.keil.com

ftware available

able. New one

CAN. See www

com/mdk5/inst

directory, but t

We will use C:

djust for the dir

ocument.

license is need

a USB cable an

configuring th

rams. We willre the latest ver

www.keil.com/m

iscovery board or similar is ma

clock speed muC-DISCO is m

fines: #define

lows:

window when

y and RTX_Bl

STM32

ARM Limited or its aff

www.keil.co

nd middlewareually.

he MDK 5 Softm/appnotes/doc

e on www.keil

es are continual

w.keil.com/st f

tall

this lab uses th

:\MDK\ for the

rectory differen

ded.

nd MDK 5.10 i

he ST-Link V2

l use only Blinkrsion of this do

mdk5/.

d with a STM32arked on the bo

ust be reduced marked on the b

PLL_M and #d

using the Seri

linky examples

2F401C-DISC336

4

filiates. All rights reser

om/st

. MDK 5 is in

ftware Packs arcs/apnt_261.asp

.com. Then, M

lly being added

for details.

he default C:\K

e examples.

nces.

installed on you

are given. Pag

ky. An enhancocument is stor

2F407VGT6 oard.

to 84 MHz. board.

define PLL_Q

ial Wire Viewe

s at 84 MHz.

CO 84 MHz

rved

nstalled and

re not used. p.

MDK 5 can

d.

Keil_v5

ur PC.

ge 5

ced red:

.

er.

Page 4:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

61)In

2)

TI

3)

TIMdi

4)

TI

TIwiEx

TMicroelectronics

) µVision) Start µVisionternet, µVisio

1. Connec

2. Start µV

3. Open th

4. This wiunder th

5. You can

6. Note: “right. to the In

7. If there

were noyou hav

) Install The S

1. Click o

2. Select KC:\Keil

3. Its statu

IP: If you clic

) Install the B

1. Select t

2. Select B

3. Select C

4. The CoUse Pac

5. Type in

6. The Bli

7. We do version

IP: The defauMDK is C:\User

irectory of C:\M

8. Close th

) Install the R

1. Obtain

2. Unzip t

3. The DS

IP: An Update

IP: If you lookill find anotherxamples tab in

s Discovery STM

n Softwaren and open Pa

on and Softwa

ct your comput

Vision by click

he Pack Install

indow opens uphe Packs tab.

n enter Discov

“ONLINE” is dIf “OFFLINE”nternet before

e are no entries

ot connected tove connected to

STM32F4 Soft

n the Packs tab

Keil::STM32F4l_v5\ARM\Pac

us will be indic

ck on the Devic

Blinky MDK 5

the Examples t

Blinky (STM32

Copy

opy Example wck Folder Struc

n C:\MDK. Cl

inky example w

not need to copn that has 4 thre

ult directory forrs\<user>\DocuMDK\ in this tu

he Packs Instal

RTX_Blinky5 a

the example so

this into the dir

SP5 folder will

e icon means th

k in the director Blinky. This the Pack Insta

M32F4 Lab with A

e Packs Dack Installer: are Packs will

ter to the intern

king on its desk

er by clicking

p: Under the B

very in Search t

displayed at the” is displayed, continuing.

shown becaus

o the Internet wo the Internet.

tware Pack:

b. Initially, the

4xx_DFP and ck\Keil\ST\ by

cated by the “U

ces tab, you can

.10 Example:

tab to display th

2F4-Discovery

as shown

window below octure: Unselec

ick OK to copy

will now copy

py CMSIS-RTeads instead of

r copied exampuments. For siutorial. You ca

ller. You can o

and DSP5 Exa

oftware zip file

rectory C:\MD

be created wit

here is an upda

ory C:\Keil_v5is a read-only

aller window to

ARM® Keil™ MD

ownload a (after the firsautomatically

net. This is nee

ktop icon.

on its icon:

Boards tab, Sel

to filter.

e bottom connect

se you

when Pack Insta

e Software Pac

click on Instaldefault. This d

Up to date” icon

n select the pro

his window:

y):

n here:

opens up: Select Launch µVis

y the Blinky pr

to C:\MDK\Bo

TOS Blinky. Wf two to make th

ples the first timmplicity, we wan use any dire

open it any tim

amples from K

e from www.ke

K\Boards\ST\S

th the Blinky a

ated Software P

\ARM\Pack\Kversion for ba

o the directory

K toolkit

4

and Instast MDK instaly startup. Oth

eded to downlo

A Pack Inst

lect STM32F4-

aller opened, s

ck ARM::CMS

l. This Softwadownload can

n:

ocessor you are

ect sion:

roject.

oards\ST\ STM

We will use a sphings interestin

me you install will use the defaectory you pref

me by clicking o

Keil.com:

eil.com/appnot

STMF32F4-Di

and RTX_Blink

Pack available

Keil\STM32F4xckup purposesyou chose. In

Copyright © 2014

all Processll is complete herwise, follow

oad the Softwa

taller Welcome

-Discovery as

select Packs/Ch

SIS is installed

are Pack will dtake two to fou

e using and thi

MF32F4-Discov

pecial ng.

fault fer.

on its icon.

tes/docs/apnt_2

iscovery\.

ky folder as sho

for download.

xx_DFP\1.0.6\s. Use only the

this tutorial w

ARM Limited or its aff

www.keil.co

s: and if you are

w Steps 1 and

are Packs.

e screen will op

shown below:

heck for Updat

by default.

download and inur minutes.

is will be displa

very.

230.asp.

own here:

.

\Boards\ST\STe projects you c

we are using C:\

filiates. All rights reser

om/st

e connected to2 below)

pen. Read and

This will filte

tes or to re

nstall to

ayed in the Pac

TM32F4-Discovcopied over fro\MDK.

rved

o the

d close it.

er the list

efresh once

cks tab.

very, you om the

Page 5:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

7

TIanwi

TI

8

In

SuwafirV2

C LELEtoLELELEth N

TMicroelectronics

) Testing

1. Start µV

2. Connec

3. If the Smight h

4. Two re

5. Select t

6. Select S

7. Select T

8. Click oworking

9. A numb

10. If nothinext ste

11. If you sinstalleOptions

IP: To refreshnd then select Sindow.

IP: The main

8) Install

nstalling the

1. Do not

2. The USC:\Keil

3. Plug in

uper TIP: Theant to update thrmware version2.J19.S0. This

OM LED LD1

ED is blinking ED is RED: co ST-Link (i.e. ED is GREENED is blinking ED is off, exce

he SWV trace is

o Led: ST-LIN

s Discovery STM

g the ST-L

Vision if

ct the Discover

ST-Link USB dhave to install t

d LEDs will lig

the Blinky proj

STM32F407 F

Target Options

n Settings: andg. You can co

ber in the SN: b

ing or an error ep: Installing t

see a proper disd properly. Cls windows and

h the SW DevicSW again. You

difference betw

ing ST-Lin

ST-Link USB

have the Disco

SB drivers musl_v5\ARM\STL

the Discovery

e ST-Link V2 he ST-Link firmn. It is importas version is inc

1 indication:

RED: the startommunication bin Debug mod: µVision is coGREEN/RED

ept for a brief Rs enabled in µV

NK/V2 comm

M32F4 Lab with A

ink V2 Co

f it is not alread

ry board to you

drivers are instathe drivers man

ght:LD1 (COM

ject C:\MDK\B

lash as shown

s or ALT-F

d the window bntinue with the

box means µV

is displayed inthe ST-Link US

splay, your STlick OK twice td continue to th

ce box, in the Pu can also exit

ween ST-Link

nk V2 USB

B Drivers: (O

overy board US

st be installed mLink\USBDriv

y board to USB

firmware updamware, find thant you are usincompatible to th

t of USB enumbetween the PCe).

onnected in DebD: data is activeRED flash whilVision.

unication with

ARM® Keil™ MD

onnection:

dy running. Se

ur PC with a US

alled correctly,nually. See the

M) and LD2 (P

Boards\ST\STM

here:

F7 and select th

below opens upe tutorial. Clic

Vision is connec

n this SW DeviSB Drivers:

T-Link USB drito exit the Targ

he next page.

Port: box selectthen re-enter t

and ST-Link V

B Drivers:

Only needed if

SB port connec

manually by exver. Find this f

B CN1. The US

ater utility ST-Lhis file and doung firmware Vhe latest driver

meration with thC and ST-LINK

bug mode and ely being exchale entering Deb

h the target or

K toolkit

5

:

elect Project/Op

SB cable as sh

, you should he directions belo

WR)

MF32F4-Disco

he Debug tab:

p: If an IDCODck on OK twice

cted to the ST-

ice box, this mu

ivers are get

t JTAG this

V2 is the additi

(might not

f the above test

cted to your PC

xecuting stlink_file and double

SB drivers will

LinkUpgrade.euble click on it.V2.J16.S0 or latrs.

he PC is takingK/V2 is establi

the last commanged betweenbug mode and

r µVision has

Copyright © 2014

pen Project.

hown on the fir

ear the usual Uow.

overy\Blinky.uv

DE and Devicee to return to th

-Link adapter.

ust be correcte

ion of Serial W

be necessa

t fails)

C at this time.

_winusb_instalclick on it. Th

l now finish in

exe is located h. It is easy to uter for proper S

g place but not ished (end of e

munication wasn the target anda brief flash w

failed. Cycle

ARM Limited or its aff

www.keil.co

st page of this

USB connected

vprojx.

e name is displhe µVision ma

ed before you c

Wire Viewer (S

ary if the tes

ll.bat. This filehe drivers will

stalling in the n

here: C:\Keil_vuse. It will cheSWV operation

yet completedenumeration).

successful. d µVision. when clicking o

the board pow

filiates. All rights reser

om/st

tutorial.

dual-tone. If n

layed, ST-Linkain menu.

can continue. S

WV) trace cap

st above pas

e is found in install.

normal fashion

v5\ARM\STLieck and report n. Do not use

d. µVision is not

on RUN happen

wer to restart

rved

not, you

k is

See the

pability.

sses)

n.

ink. If you the current

t connected

ns when

.

Page 6:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

9W

NoNo

TIfr

1Th

TIDidias

TIseinim

Rex

TIseCl

TID

TMicroelectronics

) Blinky eWe will connect

1. Start µV

2. Select P

3. By defahave to

4. Compil

5. Program

6. Enter DNote: Y

7. Click o

The 4 L

Press t

ow you knowote: The boar

IP: If you arerequency set to

0) Hardwhe STM32F4 h

1. With Bwhile lo

2. A red c

3. Note th

4. You canexistenc

5. Every t

6. You can

IP: If single stisassembly winisassembly linessembly level r

IP: A hardwaret to. ARM Con Flash are not mportant featur

emove all brexercise by click

IP: You can delecting Debuglick on Close t

IP: You can vebug/Breakpoi

s Discovery STM

example pt a Keil MDK d

Vision by click

Project/Open P

ault, the ST-Lin install the US

le the source fi

m the STM32 f

Debug mode byYou only need

n the RUN ico

LEDs on the

the blue USE

w how to comrd will start Blin

e using a STMoo high. See t

ware Breahas six hardwar

linky running, oop. Between

circle will appe

he breakpoint is

n set a breakpoce of an assem

time you click

n also click on

tep (Step In) dndow to bring e. This tells µVrather than at th

re breakpoint doreSight breakpsubstituted or mes for efficient

akpoints whenking on them

delete the brea/Breakpoints (oo return.

view the breakints or Ctrl-B.

M32F4 Lab with A

program udevelopment sy

king on its desk

Project. Open t

nk is selected. B drivers. See

iles by clicking

flash by clickin

y clicking on thto use the Loa

on. Note:

e STM32F4

ER button a

pile a programnky stand-alon

M32F401C-DIShe instruction

kpoints: re breakpoints

in the Blinky.around lines 5

ear and the prog

s displayed in b

oint in either thmbly instruction

on the RUN ic

n Single Step (S

oesn’t work, clit into focus. I

Vision you wanhe C source lev

does not executpoints are no-skmodified. Thet software deve

n you are donagain.

kpoints by clicor Ctrl-B) and

kpoints set by s

ARM® Keil™ MD

using the ystem using re

ktop icon.

the file C:\MD

If this is the fie the configura

g on the Rebuil

ng on the Load

he Debug icon.ad icon to down

: you stop the

Discovery b

and they wi

m, program ine. Blinky is no

SCO board anns on page 3 un

that can be set

c window, clic59 through 74 w

gram will stop.

both the disass

he Disassemblyn at that point.

con the pro

Step In) ,

lick on the If needed, clicknt to single stepvel.

te the instructiokid. Your instr

ese are rather elopment.

e for the next

cking on them oselecting Kill

electing

K toolkit

6

STM32F4 eal target hardw

Connect your

DK\Boards\ST\S

first time you htion instruction

ld icon. . Y

d icon: Pro

Select Onload to FLAS

program with t

board will n

ill all come

t into the STMow permanent

nd the LEDs dnder STM32F

t or unset on th

ck on a darker gwill suffice.

.

sembly and sou

y or Source win

ogram will run

Step Over

k on a p at the

on it is ructions

or All.

Copyright © 2014

Discoverware using the b

r PC to the boa

STM32F4-Dis

have run µVisions on the previ

You can also u

ogress will be i

OK if the EvaluH and not for R

the STOP icon

now blink in

on.

M32 processoly programmed

do not blink, yF401C-DISCO

he fly while the

grey block in t

urce windows

ndows as long

until the break

and Step Ou

ARM Limited or its aff

www.keil.co

ry board: built-in ST-Lin

ard with a USB

scovery\Blinky

on and the Discious page.

use the Build ic

indicated in the

ation Mode boRAM operatio

n.

n succession

or Flash, run d in the Flash

you might haveO Discovery B

e program is ru

the left margin

as shown belo

there is a gray

kpoint is again

ut .

filiates. All rights reser

om/st

nk V2 debug a

B cable to CN1.

y\Blinky.uvproj

covery board, y

con beside it.

e Output Wind

ox appears. on if it is chosen

n.

it and stop ituntil reprogram

e the clock oard:

unning. on a line in ma

ow:

y rectangle indi

encountered.

rved

adapter.

.

jx

you might

dow.

n.

! mmed.

ain() in the

icating the

Page 7:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

7

11) Call Stack + Locals Window: Local Variables: The Call Stack and Local windows are incorporated into one integrated window. Whenever the program is stopped, the Call Stack + Locals window will display call stack contents as well as any local variables belonging to the active function.

If possible, the values of the local variables will be displayed and if not the message <not in scope> will be displayed. The Call + Stack window presence or visibility can be toggled by selecting View/Call Stack window.

1. Run and Stop Blinky. Click on the Call Stack + Locals tab.

2. Shown is the Call Stack + Locals window.

The contents of the local variables are displayed as well as names of active functions. Each function name will be displayed as it is called from the function before it or from an interrupt or exception.

When a function exits, it is removed from the list.

The first called function is at the bottom of this table.

This table is active only when the program is stopped.

3. Click on the Step In icon or F11:

4. Note the function different functions displayed as you step through them. If you get trapped in the Delay function,

use Step Out or Ctrl-F11 to exit it faster.

5. Click numerous times on Step In and see other functions.

6. Right click on a function name and try the Show Callee Code and Show Caller Code options as shown here:

7. Click on the StepOut icon to exit all functions to return to main().

TIP: If single step (Step In) does not work, click on the Disassembly window to bring it into focus. If needed, click on a disassembly line to step through assembly instructions. If a source window is in focus, you will step through the source lines instead.

TIP: You can modify a variable value in the Call Stack & Locals window when the program is stopped.

TIP: This is standard “Stop and Go” debugging. ARM CoreSight debugging technology can do much better than this. You can display global or static variables updated in real-time while the program is running. No additions or changes to your code are required. Update while the program is running is not possible with local variables because they are usually stored in a CPU register. They must be converted to global or static variables so they always remain in scope.

If you have a ULINKpro and ETM trace, you can see a record of all the instructions executed. The Disassembly and Source windows show your code in the order it was written. The ETM trace shows it in the order it was executed. ETM additionally provides Code Coverage, Performance Analysis and Execution Profiling.

Changing a local variable to a static or global normally means it is moved from a CPU register to RAM. CoreSight can view RAM but not CPU registers when the program is running.

Call Stack: The list of stacked functions is displayed when the program is stopped as you have seen. This is useful when you need to know which functions have been called and what return data is stored on the stack.

TIP: You can modify a local variable value when the program is stopped.

TIP: You can access the Hardware Breakpoint table by clicking on Debug/Breakpoints or Ctrl-B. This is also where Watchpoints (also called Access Points) are configured. You can temporarily disable entries in this table.

Selecting Debug/Kill All Breakpoints deletes Breakpoints but not Watchpoints.

Page 8:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

1Thdelo

WA

TIin

TI

TIop

M

TIopex

TI

SeThWac

TMicroelectronics

2) Watchhe Watch and Mebugging techncations in real-

Watch windodd a global va

1. Stop th

2. In Blink

3. Add the

4. Select F

5. Click o

6. Enter DMemor

7. In Blinkneeded

8. value

IP: You can anto a Watch or M

IP: Make sure

9. You cantyping t

IP: To Drag ‘npens, move you

Memory wind1. Right-c

necessa

2. Note tha pointe

3. Add an

4. Right c

5. The dat

6. Both thupdated

7. You canwith a rdata fie

IP: No CPU cperations. See xplanation on h

IP: To view v

erial Wire Viewhis mechanism

Wire Debug (SWccesses.

s Discovery STM

h and MemMemory windonology that is p-time. It is pos

ow: ariable: Recal

e processor

ky.c, declare a

e statements va

File/Save All o

n Rebuild.

Debug mode. ry windows wh

ky.c, right clickand value wi

will increment

also block valuMemory windo

e View/Periodi

n also enter a vthe variable. U

n Drop into a taur mouse into t

dow: click on valueary.

he value of valer is pointing to

n ampersand “&

click in the mem

ta contents of v

he Watch and Md in real-time.

n modify valueright-click witheld and select M

cycles are normthe next page

how DAP funct

variables and th

wer (SWV) dom uses a differenWD) or JTAG c

M32F4 Lab with A

mory Windows will displapart of Cortex-Mssible to “drag

ll the Watch an

and exit Deb

global variabl

alue++; and if

or click .

. Click on Lo

Click on Rhile the program

k on the variabill be displayed

t until 0x10 in

ue, click and how.

ic Window Upd

variable manuaUse the View/S

ab that is not acthe window an

e and enter into

lue is displayio but this not w

&” in front of th

mory window a

value is now d

Memory windo

e in the Memorh the mouse cuModify Memor

mally used to pe“How It Worktions.

heir location u

es not need to nt feature of Cconnection via

ARM® Keil™ MD

dows and ay updated variM processors. and drop” vari

nd Memory win

ug mode.

le (I called it va

f (value > 0x

oad to prog

RUN . Recam is running.

ble value and d as shown here

real-time.

hold and drag it

date is selected

ally by double-Symbols windo

ctive, pick up td release the v

o the Memory 1

ing its address what we want t

he variable nam

and select Uns

displayed as a 3

ows are

ry window ursor over the ry.

erform these ks” for an

se the Symbol

be configured oreSight than S the CoreSight

K toolkit

8

how to usiable values in It is also possi

iable names int

ndows can’t se

alue) near line

x10) value =

gram the Flash

all you can set

select Add vale:

t

d.

-clicking underow to enter a va

the variable anvariable.

1 window or en

in Memory 1 ato see at this tim

me and press E

igned/Int.

32 bit value.

window. Sele

in order for theSWV. These Rt Debug Access

Copyright © 2014

se them: real-time. It d

ible to “put” orto windows or

ee local variabl

e 20 like this: u

0;as shown h

h.

Watch and

lue to … and s

r Name or presariable fully qu

nd hold it over t

nter it manually

as if it is a poinme.

Enter. The phy

ect View/Symb

e Memory andRead and Writes Port (DAP), w

ARM Limited or its aff

www.keil.co

does this througr insert values

r enter them ma

les unless stopp

unsigned int v

here near line 7

elect Watch 1.

ssing F2 and usualified.

the tab you wa

y. Select View

nter. This is u

ysical address i

bol Window wh

d Watch windowe accesses are which provide

filiates. All rights reser

om/st

gh the ARM Cinto these mem

anually.

ped in their fun

value = 0;

71:

Watch 1 will

sing copy and p

ant to open; wh

w/Memory Win

seful to see wh

s shown (0x20

hile in Debug m

ws to operate ahandled by the

es on-the-fly m

rved

CoreSight mory

nction.

open if

paste or

hen it

ndows if

hat address

000_0014).

mode.

as shown. e Serial emory

Page 9:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

1

TI

HAl

TI

TI

TI

HµValwThtim

Thex

TMicroelectronics

3) How t1. Make s

2. Locate

3. Enter ebecausesays yo

4. Set a brstop the

5. Remov

6. Set a br

7. Hold doprogramUSER p

IP: Remembe

8. µVisionwhen mvariable

9. Remove

How to viewll you need to

1. Move th

IP: You could

IP: You can ed

2. Compil

3. To prog

4. Enter D

5. Now thThis is

6. You canfunction

7. Stop th

IP: View/Peri

How It WoVision uses ARways non-intruhis means it hame for the Core

his can be slighxactly the same

s Discovery STM

to view Losure Blinky.c is

where the thre

ach of the three µVision cann

ou are unable to

reakpoint in thee program and

e this breakpoi

reakpoint at if

own the blue Um will stop. A pressed, a 0 wi

er: you can set a

n is unable to dmain is runninge and this mean

e the breakpoi

w local variado is to make t

he declarations uns

int

int

uin

also make the

dit files in edit

le the source fi

gram the Flash

Debug mode.

he three variablARM CoreSig

n read (and wrn to function.

e CPU and exi

iodic Window

orks: RM CoreSight usive and does as separate instreSight debug m

htly intrusive ine time. Then th

M32F4 Lab with A

ocal Variabs running. We

ee local variabl

e variables intonot access the Co add a variabl

e Blinky.c whithe current var

int.

f (btns != (1

USER button anbtns value of

ill be displayed

and unset hard

determine the vg. They disappns it is probabl

int and make su

ables updatethe local variab

s for num, dir aigned int va

t32_t num = -

t32_t dir =

nt32_t btns =

them static ! i

or debug mod

iles by clicking

h, click on the L

Click on R

les are updatedght technology

rite) global, staThis includes r

it debug mode

Update must b

technology to not impact theruction and dat

module to read

n the unlikely ehe CPU will be

ARM® Keil™ MD

bles in thewill use the lo

es are declared

o Watch 1 winCPU registers we, stop and star

ile loop. The priable values w

1UL << 0)) ne

nd start the pro1 will display. d if you click o

dware breakpoi

value of these tear in functionly stored in a C

ure the program

ed in real-timbles num, dir a

and btns out ofalue = 0;

1;

1;

= 0;

i.e. static int32

e. However, y

g on the Rebuil

Load icon.

RUN.

d in real-time. working.

atic variables anreads and write

for the next ste

be selected. Ot

read or write me program execta buses. Whilor write value

event the CPUe stalled for on

K toolkit

9

e Watch oocal variables fr

d in Blinky.c ne

ndow by right-cwhile running wrt the Blinky pr

problem will will appear.

ear line 61.

ogram. The Without

on Run again.

ints on-the-fly

three variablesns and handlersCPU register w

m is not runnin

me: and btns global

f main() and to

2_t num = -1

you can compil

ld icon. They w

. A progress b

Press and relea

nd structures. es to periphera

ep. and

therwise variab

memory locatiocution timings.le the CPU is f

es without steal

U and µVision rne clock cycle.

Copyright © 2014

or Memoryfrom main(): n

ear line 46, at t

clicking on thewhich is whererogram.

in the Cortex-M

when the progs outside of ma

which µVision i

ng . Exit D

l where it is de

o the top of Blin

;

le them only in

will compile w

bar will be disp

ase the User bu

Anything that als.

bles update onl

ons without ste Remember thfetching instrucling any CPU c

reads or writes In practice, th

ARM Limited or its aff

www.keil.co

y windownum, dir and bt

the start of the

m. Note it saye value is prob

M4 while the p

gram is runningain. They are ais unable to acc

ebug mode.

eclared in Blink

nky.c to make

n edit mode.

with no errors o

played at the bo

utton and btns

stays around in

ly when the pro

ealing any CPUhe Cortex-M4 ictions at full spcycles.

to the same mhis cycle stealin

filiates. All rights reser

om/st

s: tns.

e main function

ys < not in scopbably located. I

program is runn

g because theya local or automcess during run

ky.c !

them global va

or warnings.

ottom left.

will update to

n a variable fro

ogram is stopp

U cycles. This is a Harvard arpeed, there is p

memory locationng never happe

rved

n.

pe > If µVision

ning !

y exist only matic n time.

ariables:

0 or 1.

om

ed.

is nearly rchitecture. plenty of

n at ens.

Page 10:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

1Wus

C

C

TI

Ru

TIm

TIgl

TMicroelectronics

4) View VWe will display

sed. This uses

1. Stop th

onfigure Seria

2. Select TConfirm

3. In the Telse is s

4. Click O

5. Click O

onfigure Logi

1. Open V

or selec

IP: You can c

2. Click oAdd vaalso Dr

3. Click o

4. With va

5. Click o

un Program:

1) Click o

2) The var

IP: If you do nmight also have

IP: You can slobal, static or r

3) Enter thbutton a

4) Note th

5) Select the LA on the Sthe Updbox.

6) Stop th

7) Click othe LA btns. Ythe Del

this ico

8) Click o

s Discovery STM

Variables the global varithe Serial Wir

e processor

al Wire Viewe

Target Optionsm SW is select

Trace tab, selecset as shown he

OK once to retu

OK return to the

ic Analyzer:

View/Analysis

ct the LA wind

configure the L

n the Blinky.c alue to… and thrag and Drop o

n the Select bo

alue selected,

n Close.

Note: The LA

n Run. Cl

riable value w

not see a waveto repower the

how up to 4 varaw addresses

he static variaband see the vol

he variable valu

Signal Info, Shby clicking

Stop icon in date Screen

e CPU.

n Setup in and delete

You can use lete key or

n:

n Close.

M32F4 Lab with A

Graphicaiable value youe Viewer and t

and exit Deb

er (SWV):

s or ALT-Fed. SW selecti

ct Trace Enableere:

urn to the Debu

e main menu.

Windows and

dow on the tool

LA while the pr

tab. Right clichen select Logir enter it manu

ox and the LA

, set Display R

A can be config

lick on Zoom O

will increment t

eform, exit and e Discovery bo

ariables in the Lsuch as *((uns

ble btns into theltages below:

ue stops increm

how Cycles, A

ARM® Keil™ MD

lly with thu created earlietherefore does

ug mode.

F7 and select thion is mandato

e. Unselect Pe

ug tab.

Enter debug m

select Logic A

lbar.

rogram is runni

ck on value anic Analyzer. Y

ually.

Setup window

ange Max: to 0

gured while the

Out until Grid

to 0x10 (decim

re-enter Debuard. Confirm t

Logic Analyzesigned long *)0

e LA and set th

menting while U

Amplitude and C

K toolkit

10

he Logic Aer in the Logic not steal CPU

he Debug tab. ory for SWV. S

eriodic and EX

mode.

Analyzer

ing.

nd select You can

w appears:

0x15 as shown

e program is ru

is about 1 seco

mal 16) and the

ug mode to refrthe Core Clock

er. These varia0x20000000).

he Display Ran

USER is held d

Cursor to see th

Copyright © 2014

Analyzer (Analyzer. Nocycles.

Select SettingST-Link uses o

CTRC. Set Co

n here:

unning.

ond.

en is set to 0.

resh the LA. Yk: value is corr

ables must be

nge Max: to 0x

down. Also no

he measuring c

ARM Limited or its aff

www.keil.co

(LA): o code stubs in

gs: on the rightonly SW. Sele

ore Clock: to 1

You rect.

x2. Click on R

ote how easy it

capabilities of

filiates. All rights reser

om/st

the user code w

t side of this wiect the Trace ta

68 MHz. Eve

RUN and press t

t is to view this

the LA. You c

rved

will be

indow. ab.

erything

the User

s effect.

can stop

Page 11:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

1ReThthva

TI

TIcoWcli

TItem

TIAn

Sh

TMicroelectronics

5) Watchecall STM32 phe STM32 also

he same comparariables free in

1. Use the

2. We wil

3. The SW

4. The var

5. Select D

6. Select b

7. Click o

8. Enter thalready

9. Open DCheck “

10. Click o

window

11. Click o

12. You wiwell as

13. When vthe prog

14. Note thshown bThis is a slight

15. There acan entin the Bcurrentl

16. To repe

17. When y

18. Leave D

IP: You canno

IP: To edit a Wonfiguration are

Watchpoint. Yoick on Kill Sel

IP: The checkbmporarily unse

IP: Raw addren example is:

hown above rig

s Discovery STM

hpoints: Cprocessors haveo have four Warators as Watchthe Logic Ana

e same Blinky c

ll use the globa

WV Trace does

riable value s

Debug in the m

both the Read a

n Define and i

he value to thy listed.

Debug/Debug S“on Data R/W

n OK twice. O

w.

n RUN.

ill see value cin the Watch w

value equals 0gram.

he data writes inbelow. 0x5 is with the ST-Li

tly different dis

are other types er and are deta

Breakpoints winly implemente

eat this exercis

you are finishe

Debug mode.

ot set Watchpoi

Watchpoint, doea. Clicking o

ou should deletlected or try the

box beside the elect or disable

esses can also b*((unsigned lo

ght is the Logic

M32F4 Lab with A

Conditional e 6 hardware batchpoints. Wahpoints in its oalyzer to use W

configuration a

al variable valu

not need to be

hould be still e

main µVision w

and Write Acc

t will be accep

he Watch 1 win

Settings and selsample” and u

Open the Trace

change in the Lwindow.

0x5, the Watch

n the Trace Rein the last Datink. A ULINKsplay.

of expressionsailed in the Helndow. Not all d in µVision.

e, click on RU

d, stop the prog

ints on-the-fly

uble-click on in Define will c

te the old one be next TIP:

expression alle a Watchpoint

be entered into ong *)0x20000

c Analyzer win

ARM® Keil™ MD

Breakpointreakpoints. Thatchpoints can operations and

Watchpoints. W

as the previous

ue you created

e configured fo

entered in the L

window and sel

ess. In the Exp

pted as shown h

ndow if it is not

lect the trace tauncheck EXTR

e Records

Logic Analyzer

hpoint will stop

ecords window a column. Plu

K2 will show th

s you lp button are

UN.

gram, click on

while the prog

it in the Breakpcreate another by highlighting

ows you to t without deleti

the Logic Ana000)

ndow displayin

K toolkit

11

ts: This dohese breakpoinbe thought of they must be s

Watchpoints are

s page. Stop th

d in Blinky.c to

or Watchpoints

Logic Analyzer

lect Breakpoint

pression box en

here: Click on

t

ab. RC.

r as

p

us the address thhe same windo

Debug and sel

gram is running

points window

g it and

ing it.

alyzer.

ng the variable

Copyright © 2014

oes not neednts can be set oas conditional

shared. This me also referred

he program if n

o explore Watc

s. However, w

r from the last

ts or press Ctrl

nter: “value

Close.

he data writtenow. A ULINKp

lect Breakpoin

g like you can w

and its inform

value trigge

ARM Limited or its aff

www.keil.co

d or use Seron-the-fly witho

breakpoints. Tmeans in µVisio

to as Access B

necessary. Stay

chpoints.

we will use it in

exercise on th

l-B.

= = 0x5” witho

n to and the PCpro or a J-Link

nts (or Ctrl-B) a

with hardware

mation will be d

er point of 0x5.

filiates. All rights reser

om/st

rial Wire Vieout stopping thThe Logic Anaon you must haBreakpoints.

y in debug mod

this exercise.

e previous pag

out the quotes.

C of the write ink (black case) w

and Kill the W

e breakpoints.

dropped down

This is three

rved

ewer: he CPU. alyzer uses ave two

de.

ge.

nstruction. will show

Watchpoint.

into the

runs.

Page 12:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

1KRTpr

NRT

RT

Yo

W

Th

TMicroelectronics

6) RTX_Beil provides RTTX RTOS projroject. RTX co

OTE: RTX_BTX_Blinky tha

TX and all its c

ou must have c

1. With µV

2. Open th

3. If the U

4. This pr

5. Compil

6. To prog

7. Enter th

8. The fou

TIP: If youfrequency s

9. Click o

We will explore

he Configur1. Click o

2. Click o

3. Open u

4. See how

5. Changi

6. You can

7. This scrSee ww

s Discovery STM

Blinky ExaTX, a full featuject. MDK wilomes with a BS

Blinky suppliedat has fours tas

components ar

copied RTX_B

Vision in Edit

he file C:\MDK

Update Config

oject is pre-con

le the source fi

gram the Flash

he Debug mod

ur LEDs will b

u are using a Sset too high. S

n STOP .

the operation

ation Wizarn the RTX_Co

n the Configur

up the individua

w easy it is to m

ng an attribute

n create Config

ripting languagww.keil.com/su

Text Editor

M32F4 Lab with A

ample Proure RTOS. RTll work with anSD type license

d with MDK 5 ks and lights fo

re located here:

Blinky5 to C:\M

mode (not in d

K\Boards\ST\S

guration Files

nfigured for th

iles by clicking

h manually, clic

e by clicking o

link in success

STM32F401CSee the instruc

of RTX with th

rd for RTX: onf_CM.c sour

ration Wizard t

al directories to

modify these se

e in one tab cha

guration Wizar

ge is shown beupport/docs/273

: Source Code

ARM® Keil™ MD

ogram witTX is included ny RTOS. Ane and source co

is a two task pfour LEDs. It i

: C:\Keil_v5\A

MDK\Boards\S

debug mode):

STM32F4-Disc

window open

he ST-Link V2

g on the Rebuil

ck on the Load

on the debug ic

sion simulating

C-DISCO boarctions on page

he Kernel Awa

rce file tab as sh

tab at the botto

o show the var

ettings here as

anges it in the o

rds in any sour

low in the Tex35.htm for inst

e

K toolkit

12

h Keil RTXas part of Keil RTOS is just a

ode is provided

project that blins more interest

ARM\Pack\AR

ST\STM32F4-D

Select Project/

covery\RTX_B

ns, select Canc

debug adapter

ld icon. .

d icon. . A p

con and cli

g the signals fo

rd and the LEDe 3 under STM

areness window

hown below on

om and your vi

ious configura

opposed to fin

other automatic

rce file with the

xt Editor as comtructions.

Copyright © 2014

X RTOS: Al MDK includina set of C functd with all versi

nks one LED. ting.

RM\CMSIS\3.2

Discovery\ as d

/Open Project.

Blinky5\Blinky

cel.

r.

They will com

progress bar w

ick on the RUN

r a stepper mo

Ds do not blinM32F401C-DI

ws.

n the left. You

ew will change

ation items avai

nding and chan

cally. You sho

e scripting lang

mments starting

Config

ARM Limited or its aff

www.keil.co

A Stepperng source. Thitions that gets ions of MDK.

Supplied with

20.4\CMSIS_R

described on pa

.uvprojx.

mpile with no e

will be at the bo

N icon.

tor.

nk, you might ISCO Discover

u can open it w

e to the Config

ilable.

nging entries in

ould save a mo

guage as used i

g such as a </h

guration Wiza

filiates. All rights reser

om/st

r Motor exis example expcompiled with

h this document

RTX.

age 4.

errors or warnin

ottom left.

have the clockry Board:.

with File/Open

guration Wizar

n the source cod

odified window

in the Text Edi

h> or <i>.

ard

rved

xample plores the h your

t is an

ngs.

k

if needed.

d.

de.

w.

itor.

Page 13:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

1Uusco

Im

RTW

TIReCode

Calr

Thfin

TI

TMicroelectronics

7) RTX Ksers often wansually stored inompanies also p

1. Run RT

2. Open DViewerhave toscreen. same reMemor

mportant TIP:

3. Open Dis proba

TX Viewer: We must activat

1. Stop th

2. Click o

3. Click th

4. In the Dnot JTA

5. Click o

6. Set Corand sele

7. Unselec

8. ITM StmethodinformaIt is slig

9. Click oThe Se

10. Enter D

11. Select “

12. Click o

13. This wiformat You prosec by c

IP: If Event Vecords and conore Clock correpending on th

ortex-M3 Alerready describe

he data is updand this feature

IP: You can u

s Discovery STM

Kernel Awant to know the nn a structure or provide awaren

TX_Blinky by

Debug/OS Suppr and the windo grab the wind These values

ead write technry windows.

: View/Period

Debug/OS Suppably no data di

Configuringte Serial Wire V

e CPU and exi

n the Target O

he Settings box

Debug windowAG. SWV wor

n the Trace tab

re Clock: to 16ect Trace Enab

ct the Periodic

timulus Port 31d the RTX Viewation out to be ghtly intrusive.

n OK twice to rial Wire View

Debug mode an

“Tasks and Sys

n the Event Vi

indow displaysas shown in thobably have toclicking on the

iewer doesn’t wnfirm there are ect ? This proje board you ar

rt: µVision wied. The Event V

ated while the pvery useful ! R

use a ULINK2,

M32F4 Lab with A

areness unumber of the cmemory area b

ness plug-ins f

clicking on the

port and select ow on the rightdow and move i

are updated innology as used

dic Window Up

port and select isplayed becau

g Serial WirViewer to get t

it debug mode.

Options icon

x next to ST-Li

w, make sure Porks only with S

b to open the T

68 MHz (84 forble.

and EXCTRC

1 must be checkwer gets the kedisplayed in th.

return to µViswer is now conf

nd click on RUN

stem” tab: the d

iewer tab.

s task events inhe RTX Kernelo change the Rae Zoom ALL an

work, open up good ITM 31 ject is running e using.

ill update all RViewer uses IT

program is runnRemember, RT

ULINK-ME,

ARM® Keil™ MD

using Seriacurrent operatiby the RTOS.

for µVision.

e Run icon.

System and Tht opens up. Yoit into the cent

n real-time usinin the Watch a

pdate must be s

Event Viewerse SWV is not

re Viewer (Sthe Event View

next to the t

ink Debugger.

ort: is set to SWSW mode.

Trace window.

r STM32F401

C boxes as show

ked. This is thernel awarenesshe Event View

sion. figured !

N.

display is upda

n a graphical window below

ange to about 0nd + and – icon

the Trace frames presentat 168 or 84 M

TX informatioTM and is sligh

ning. No instrTX with source

ULINKpro, ST

K toolkit

13

al Wire Viing task and the Keil provides

hread ou might er of the

ng the and

selected !

. There configured.

SWV): wer working.

arget box. Sel

W and

board)

wn:

he s er.

ated.

w. 0.1 ns.

t. Is MHz

on in real-time ohtly intrusive.

rumentation coe code is includ

T-Link V2 or J

Copyright © 2014

ewer (SWe status of the a Task Aware

lect the Debug

on a target boa

de needs to be ded with all ve

J-Link for these

ARM Limited or its aff

www.keil.co

WV): other tasks. Th

e window for R

tab.

ard due to its re

inserted into yersions of MDK

e RTX Kernel

filiates. All rights reser

om/st

his informationRTX. Other RT

ead/write capab

your source. YK.

Awareness wi

rved

n is TOS

bilities as

You will

indows.

Page 14:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

1µVVi

En

TIm

Th

I

TI

TI

TMicroelectronics

8) Logic Vision has a griewer in the ST

1. Close th

2. Add 4 g

3. Add 2 lbelow: and 53 remaini

4. Select F

5. Rebuild

6. Enter d

7. You can

8. Open V

window

nter the Var9. Click o

to… an

10. Repeat Now w

IP: If you can’ust be configu

he Logic Analy

It can’t see loca

11. Click o

12. Click o

13. Using t

14. Select Sof the w

15. Click o

IP: You can al

IP: You can vi

s Discovery STM

Analyzer raphical Logic TM32. RTX_B

he RTX Viewe

global variable

lines to each ofphasea=1; and(just after the Ling threads, ad

File/Save All o

d the project.

debug mode

n run the progr

View/Analysis

w on the toolba

riables into n the Blinky.c

nd finally select

for phaseb, pwe have to adjus

’t get these varured correctly in

yzer can displa

als: just make t

n the Setup ico

n Close to go b

the All, OUT a

Signal Info andwaveforms and

n Stop in Upda

lso enter these

iew signals tha

M32F4 Lab with A

Window: Analyzer wind

Blinky uses fou

er windows. S

es unsigned i

f the four thread phasea=0;. LED_On and L

dd the correspon

or click .

Program t

.

ram at this poin

Windows and

ar.

the Logic Atab. Right clict Logic Analyz

phasec and phst the scaling.

riables entered n order to enter

ay static and gl

them static or g

on and click on

back to the LA

and In buttons s

d Show Cyclesd get timing and

ate Screen to st

variables into

at exist mathem

ARM® Keil™ MD

View varidow. Up to fouur tasks to crea

top the program

int phasea t

ads phaseA throThe first two lLED_Off functnding statemen

the Flash .

nt.

select Logic A

nalyzer (LAck on phasea,zer. Phasea wi

hased. These

into the LA, mr variables in t

obal variables,

global. To see

n each of the fo

A window.

set the range to

. Click to mard other informa

top (and start)

the Watch and

matically in a va

K toolkit

14

iables reaur variables canate the wavefor

m and exit

through unsig

ough phaseD inines are showntion calls). Fornts phaseb, pha

Analyzer or sele

A): , select Add ‘phill be added to

variables will

make sure the Tthe LA.

, structures and

peripheral reg

our variables an

o 0.2 second or

rk a place moveation as shown

the data collec

d Memory wind

ariable and not

Copyright © 2014

al-time in an be displayedrms. We will g

t debug mode.

gned int pha

n Blinky.c as sn added near linr each of the thasec and phase

ect the LA

hasea’ the LA.

be listed on th

Trace Config is

d arrays.

gisters read or w

nd set Max. in

r so. Move the

e the cursor to n in the inserted

ction.

dows to display

t available for

ARM Limited or its aff

www.keil.co

a graphicd in real-time ugraph these fou

ased to Blinky

shown nes 50 hree ed.

he left side of th

s set correctly.

write to them a

the Display Ra

e scrolling bar t

get timings. Pd box labeled p

y and change th

measuring in t

filiates. All rights reser

om/st

cal formatusing the Serialur waveforms.

y.c as shown h

he LA window

The Serial Wi

and enter them

ange: to 0x3.

to the far right

Place the cursophasec:

hem in real-tim

the outside wor

rved

t: l Wire

ere:

w as shown.

ire Viewer

in the LA.

if needed.

or on one

me.

rld.

Page 15:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

1ReITwrDan

Tr

WY

ITThcyto

TIcoon

SuIT

Su

TMicroelectronics

9) ITM (Iecall that we sh

TM Stimulus Prite to the ITMebug (printf) V

nd compiled in

1. Stop th

2. Open th

3. Add thi

4. In the m

5. Rebuild

6. Open S

7. Configu

8. Unselec

9. Select I

10. Click O

11. Click o

12. In the D

13. As valu

race Record1. Open th

2. You wi

What Is This ou can see the

1. ITM 0 display

2. All thes

3. When y

TM Conclusihe writes to ITycle. It takes n your PC via th

IP: It is importonfiguration as nly those featur

uper TIP: ITMTM characters.

uper TIP: To s

s Discovery STM

Instrumenhowed you canort 31. ITM P

M port, zero CPUViewer window

Blinky.c in or

e program if it

he project C:\M

is code to Blink#define ITM

main function iITM_Port8(0

while (ITM_

ITM_Port8(0

while (ITM_

ITM_Port8(0

d the source fil

Select Target O

ure the Serial W

ct On Data R/W

ITM Port 0. IT

OK twice. Ente

n View/Serial

Debug (printf)

ue is increment

ds he Trace Recor

ill see a window

? e ITM writes aframes (Num c

yed the Data co

se are timestam

you are done, s

on M Stimulus Po

no CPU cycles he Serial Wire

tant to select apossible to av

res that you rea

M_SendChar is It is found in

see how to use

M32F4 Lab with A

ntation Trn display informort 0 is availabU cycles are re

w. Note: the glrder for this exe

is running

MDK\Boards\S

ky.c. A good pM_Port8(n)

in Blinky.c afte0) = value +

_Port8(0) ==

0) = 0x0D;

_Port8(0) ==

0) = 0x0A;

les, program th

Options or

Wire Viewer as

W Sample, EX

TM Stimulus P

er Debug mode

Windows and

Viewer you wi

ted its ASCII c

rds if not alread

w such as the o

and Data writcolumn) are oulumn.

mped in both C

stop the proces

ort 0 are intrusito get the data Output (SWO

s few options ioid overloadinally need.

s a useful functthe header cor

e printf in your

ARM® Keil™ MD

race Macromation about thble for a printfequired to get tobal variable vercise to work.

and exit Debu

ST\STM32F4-D

place is near lin(*((volatile

er the second D0x30; /*

0);

0);

he Flash memor

ALT-F7 and s

s described on

CTRC and PC

Port “0” enables

e.

select Debug (

ill see the ASC

character is disp

dy open. Doub

one below with

es (value beiur ASCII chara

CPU cycles and

sor and exit de

ive and are usuout the proces) pin.

in the Trace ng the SWO pin

tion you can usre.CM3.h.

code, see the D

K toolkit

15

ocell) ITMhe RTOS in rea type of instrumthe data out of value from 12)

ug mode.

Discovery\Blin

ne 19, just aftee unsigned ch

Delay(200); nea* displays va

ry and enter de

elect the Debu

page 10. Use

C Sample. (this

s the Debug (p

(printf) Viewer

CII of value app

played.

ble click on it t

h ITM and Exc

ing displayed cters from val

d time in second

ebug mode.

ually one ssor and

n. Enter

se to send

DSP example.

Copyright © 2014

M uses Seral-time using tmentation that the processor a) Watch and M

nky\Blinky.uvp

er the #include har *)(0xE000

ar line 72, entealue in ASCII

ebug mode.

ug tab, and then

168 MHz for t

is to help not o

prinftf) Viewer

r and click on R

pear.

to clear it.

ception frames.

in the LA). lue with carriag

ds.

ARM Limited or its aff

www.keil.co

rial Wire Vithe RTX Viewerequires minimand into µVisi

Memory Wind

projx. (do not u

"LED.h". 00000+4*n)))

er these lines: I */

n the Trace tab

the Core Clock

overload the SW

r.

RUN.

.

ge return (0D)

filiates. All rights reser

om/st

iewer. er. This is donmal user code. on for display

dows … must b

use RTX_Blink

.

k.

WO port)

and line feed (

rved

ne through After the in its be entered

ky).

(0A) as

Page 16:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

16

20) Serial Wire Viewer (SWV) and how to use it: 1) Data Reads and Writes: (Note: Data Writes but not Reads are enabled in the current version of µVision).

You have already configured Serial Wire Viewer (SWV) on page 13 under RTX Viewer: Configuring the Serial Wire Viewer:

Now we will examine some of the features available to you. SWV works with µVision and ST-Link V2, ULINK2/ME, ULINKpro or a Segger J-Link V6 or higher. SWV is included with MDK and no other equipment must be purchased.

Everything shown here is done without stealing any CPU cycles and is completely non-intrusive. Your program runs at full speed and needs no code stubs or instrumentation software added to your source code. Screens are shown using a ST-Link.

1. Use RTX_Blinky5 from the previous exercise. Enter Debug mode and Run the program if not already running.

2. Select View/Trace/Records or click on the Trace icon and select Records.

3. The Trace Records window will open up as shown here:

4. The ITM frames are the data from the RTX Kernel Viewer which uses Port 31 as shown under Num. here:

5. To turn this off, select Debug/Debug Settings and click on the Trace tab. Unselect ITM Stimulus Port 31. TIP: Port 0 is used for Debug printf Viewer.

6. Unselect EXCTRC and Periodic.

7. Select On Data R/W Sample.

8. Click on OK twice to return.

TIP: If the SWV trace fails to work properly after this change, exit Debug mode, cycle the power to the Discovery board and re-enter Debug mode.

If you are using the STM32F401 board see page 3.

9. Click on the RUN icon.

10. Double-click in Trace Records window to clear it.

11. Only Data Writes will appear now.

TIP: You could have right clicked on the Trace Records window to filter the ITM frames out. Unselecting a feature is better as it reduces SWO pin traffic and trace overflows.

What is happening here ?

1. When variables are entered in the Logic Analyzer (remember phasea ?), the reads and/or writes will appear in Trace Records.

2. The Address column shows where the variable is.

3. The Data column displays the data values written to phasea.

4. PC is the address of the instruction causing the writes. You activated it by selecting On Data R/W Sample in the Trace configuration window.

5. The Cycles and Time(s) columns are when these events happened.

TIP: You can have up to four variables in the Logic Analyzer and subsequently displayed in the Trace Records window. You must have all Watchpoints off.

TIP: If you select View/Symbol Window you can see where the addresses of the variables are located.

Note: You must have Browser Information selected in the Options for Target/Output tab to use the Symbol Browser.

TIP: ULINKpro and Segger J-Link adapters display the trace frames in a slightly different style trace window. The J-Link currently does not display Data writes.

Page 17:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

17

2) Exceptions and Interrupts: The STM32 family using the Cortex-M4 processor has many interrupts and it can be difficult to determine when they are being activated and how often. Serial Wire Viewer (SWV) on the STM32 family makes this task easy.

1. Stop the RTX_Blinky example program. Be in Debug mode. Open Debug/Debug Settings and select the Trace tab.

2. Unselect On Data R/W Sample, PC Sample and ITM Ports 31 and 0. (this is to minimize overloading the SWO port)

3. Select EXCTRC as shown here:

4. Click OK twice.

5. Double click on Trace Records to clear it.

6. Click RUN to start the program.

TIP: If the SWV trace fails to work properly after this change, exit and re-enter Debug mode.

7. You will see a window similar to the one below with Exceptions frames displayed.

.What Is Happening ?

1. You can see two exceptions happening.

Entry: when the exception enters.

Exit: When it exits or returns.

Return: When all the exceptions have returned to the main program. This is useful to detect tail-chaining.

2. Num 11 is SVCall from the RTX calls.

3. Num 15 is the Systick timer.

4. In my example you can see one data write from the Logic Analyzer.

5. Note everything is timestamped.

6. The “X” in Ovf is an overflow and some data was lost. The “X” in Dly means the timestamps are delayed because too much information is being fed out the SWO pin. Always limit the SWV features to only those you really need.

TIP: The SWO pin is one pin on the Cortex-M4 family processors that all SWV information is fed out. There are limitations on how much information we can feed out this one pin. These exceptions are happening at a very fast rate. µVision easily recovers gracefully from these overflows. Overflows are shown when they happen. Using a ULINKpro helps reduce overruns, especialy if the 4 bit Trace Port connection is used rather than the 1 bit SWO pin.

1. Select View/Trace/Exceptions or click on the Trace icon and select Exceptions.

2. The next window opens up and more information about the exceptions is displayed as shown below:

3. Note the number of times these have happened under Count. This is very useful information in case interrupts come too fast or slow. Click on Count to bring the most active exceptions to the top of the window.

4. ExtIRQ are the peripheral interrupts.

5. You can clear this trace window by double-clicking on it.

6. All this information is displayed in real-time and without stealing any CPU cycles or stubs in your code !

TIP: Num is the exception number: RESET is 1. External interrupts (ExtIRQ), which are normally attached to peripherals, start at Num 16. For example, Num 41 is also known as 41-16 = External IRQ 25. Num 16 = 16 – 16 = ExtIRQ 0.

Page 18:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

18

3) PC Samples: Serial Wire Viewer can display a sampling of the program counter.

SWV can display at best every 64th instruction but usually every 16,384 is more common. It is best to keep this number as high as possible to avoid overloading the Serial Wire Output (SWO) pin. This is easily set in the Trace configuration.

1. Open Debug/Debug Settings and select the Trace tab.

2. Unselect EXCTRC, On Data R/W Sample and select Periodic in the PC Sampling area.

3. Click on OK twice to return to the main screen.

4. Close the Exception Trace window and leave Trace Records open. Double-click to clear.

5. Click on RUN and this window opens:

6. Most of the PC Samples in the example shown are 0x0800_055A which is a branch to itself in a loop forever routine. Note: the exact address you get depends on the source code and the compiler settings.

7. Stop the program and the Disassembly window will show this Branch as shown below:

8. Not all the PCs will be captured. Still, PC Samples can give you some idea of where your program is; especially if it is not caught in a tight loop like in this case.

9. Set a breakpoint in one of the tasks.

10. Run the program and when the breakpoint is hit, you might see another address at the bottom of the Trace Records window. See the screen below:

11. Scroll to the bottom of the Trace Records window and you might (probably not) see the correct PC value displayed. Usually, it will be a different PC depending on when the sampling took place.

12. To see all the instructions executed, you can use the ETM instruction trace with a ULINKpro.

13. Remove the breakpoint.

14. Stop the program.

15. Leave Debug mode.

Page 19:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

2Thmco

TIco

TMicroelectronics

1) Serial he essential pla

must configure Sonfiguration inf

A. In Editthis win

B. In Deb

1) Core CSWV. your stausuallyThis muadapter

2) Trace EIt can oThis doMemor

3) Trace P

4) Timestselects

5) PC Samcounter

a.

b.

c.

6) ITM StµVisionused fo

7) Trace Eand an window

a.

b.

c.

d.

e.

f.

IP: Counters wounters with yo

s Discovery STM

Wire Viewace to configurSWV for everyformation will

t mode: Selecndow and then

ug mode: Sel

Clock: The CPThe CPU speeartup code or in called SYSCLust be set corrers except ULIN

Enable: Enabonly be changedoes not affect thry window disp

Port: This is p

tamps: Enablethe Prescaler.

mpling: Samplr:

Prescaler 10

Periodic: En

On Data R/Wlisted in the L

timulus Portsn. Port 31 (a) r the Debug (p

Enable: Dis

Privilege: Pr

Events: Enablevent is create

w. The event c

CPI: Cyclesfirst, one inc

Fold: Cumulunused instru

Sleep: Cum

EXC: Cumuexception co

LSU: Cumu

EXCTRC: of exceptionfeature to dis

will increment our program as

M32F4 Lab with A

wer (SWVre the trace is iny project and ad

be saved in th

t Target Optionthe Trace tab.

lect Debug/Deb

PU clock speeded can be foundn Abstract.txt.

LK or Main Cloectly for all

NKpro.

les SWV and Id in Edit modehe Watch and play updates.

preset for ST-L

es timestamps a1 is the defaul

les the program

024*16 (the de

nables PC Sam

W Sample: DiLogic Analyze

: Enables the tis used for the

printf) Viewer.

splays a 32 bit

rivilege is used

les various CPUd when this coreated when a

s per Instructiluding any inst

lative number uctions are rem

mulative numbe

ulative cycles Code. Includes s

ulative number

Exception Tras in the Instrucsplay exception

while single st they are memo

ARM® Keil™ MD

V) Configun the Trace tabdditionally for e project. The

ns or ALT Edit mode is

bug Settings an

d for d in It is

ock.

ITM. e.

Link.

and lt.

m

fault) means ev

mpling.

isplays the adder. This is not c

thirty-two 32 bKeil RTX Vie The rest are c

hex number in

d by an RTOS

U counters. Aounter overflow

counter wraps

ion: The cumultruction fetch s

of folded instrumoved (flushed

r of cycles the

CPU spent in estack operation

r of cycles spen

ace. This is difction Trace andn events and is

tepping. This ory mapped.

K toolkit

19

uration wib as shown beloevery target se

ere are two way

T-F7 and selectselected by de

nd then select t

very 16,384th P

dress of the instconnected with

bit registers useewer which is acurrently unuse

ndicating which

to specify whic

All except EXCws every 256 cy around is disp

lative number stalls.

uctions. Thesed) from the pipe

CPU is in slee

exception overhns and returns.

nt in load/store

fferent than thed Exception wis often used in

can provide so

Copyright © 2014

indow: (fow. You cannettings within ays to access thi

t the Debug tabfault when you

the Trace tab.

PC is displayed

truction that cah PC Sampling

ed to output daa real-time kerned in µVision.

h ports are ena

ch ITM ports c

CTRC are 8 bit ycles. These vplayed in the In

of extra cycles

e results from aeline giving a z

ep mode. Uses

head not includ

operations bey

e other items inindows. It is ndebugging.

ome very usefu

ARM Limited or its aff

www.keil.co

for referennot set SWV gloa project you wis menu:

b. Select Settinu start µVision

Debug mode i

d. The rest are

aused a data rebut rather with

ata in a printf tynel awareness

abled.

can be used by

counters. Eacvalues are displnstruction Trac

s used by each

a predicted brazero cycle exec

s FCLK for tim

ding total time

yond the first c

n this section. Tnot a counter. T

ul information.

filiates. All rights reser

om/st

nce) obally for µVi

want to use SW

ngs: on the righn.

is selected with

e not collected.

ad or write of ah data tracing.

ype statement twindow. Port

y a user program

h counter is culayed in the Coce window.

instruction bey

anch instructioncution time.

ming.

e spent processi

cycle.

This enables thThis is a very u

You can read

rved

sion. You WV. This

ht side of

h .

a variable

to 0 (b) is

m.

umulative ounter

yond the

n where

ing the

he display useful

d these

Page 20:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

2ARinM

Thin

Th

To

TI

TIan

Thvabe

TMicroelectronics

2) DSP SRM CMSIS-D

n C:\Keil_v5\AMicrocontroller

his example crn the Logic Ana

his example in

o obtain this ex

1. Open th

2. Build th

3. Program

4. Enter D

5. Click o

6. Four wZoom O

IP: If one varia

7. The pro

8. Open th

9. You can

10. Leave t

11. Close th

IP: The ULINKnd the program

he Watch 1 winariables updatinelow:

s Discovery STM

SINE examDSP libraries ar

RM\Pack\ARMSoftware Inter

eates a sine waalyzer using Se

corporates Kei

xample file, go

he project file s

he files.

m the STM32 f

Debug mode by

n the RUN ico

aveforms will Out for an appr

able shows no

oject provided

he Trace Recor

n right click in

the program ru

he Trace Recor

Kpro trace dispm must be stopp

ndow will dispng in real time

M32F4 Lab with A

mple usingre offered for AM\CMSIS. Seerface Standard.

ave with noise erial Wire View

il RTX RTOS.

o to www.keil.c

sine: C:\Keil\A

There will be n

flash by clickin

y clicking on th

on. Open

be displayed inropriate display

waveform, dis

has Serial Wir

rds window an

n this window a

unning.

rds window.

play is differenped to update it

play the four as shown

ARM® Keil™ MD

g ARM CMSARM Cortex-Me www.arm.co. CMSIS is an

added, and thewer.

RTX is availa

com/appnotes

ARM\Boards\S

no errors or wa

ng on the Load

he Debug icon.

the Logic Ana

n the Logic Any. Displayed a

sable the ITM S

re Viewer confi

nd the Data Wri

and deselect IT

nt t.

K toolkit

20

SIS-DSP LM3 and Cortex-

m/cmsis for m ARM standard

en the noise is f

able free with a

/docs/apnt_23

ST\STM32F4-D

arnings.

d icon: Prog

Select O

alyzer window.

nalyzer using thare 4 global var

Stimulus Port 3

figured and the

ites to the four

TM Events to g

Copyright © 2014

Libraries: -M4 processors

more informatiod.

filtered out. T

a BSD type lic

30.asp Extract

Discovery\DSP

gress will be in

OK if the Evalu

.

he Serial Wire riables: sine, n

31 in the Trace

Logic Analyz

r variables are l

get only Data W

ARM Limited or its aff

www.keil.co

s. DSP librarieon. CMSIS is a

The waveform i

cense. RTX so

t DSP to …\ST

P\sine.uvproj

ndicated in the

ation Mode bo

Viewer as shonoise, disturbed

e Config windo

er loaded with

listed as shown

Writes displaye

filiates. All rights reser

om/st

es are providedan acronym for

in each step is

urce code is pr

TM32F4-Disco

e Output Windo

ox appears.

own below. Add and filtered.

ow.

h the four variab

n here:

ed.

rved

d in MDK r Cortex

displayed

rovided.

overy\.

ow.

djust

bles.

Page 21:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

21

Signal Timings in Logic Analyzer (LA): 1. In the LA window, select Signal Info, Show Cycles, Amplitude and Cursor.

2. Click on STOP in the Update Screen box. You could also stop the program but leave it running in this case.

3. Click somewhere in the LA to set a reference cursor line.

4. Note as you move the cursor various timing information is displayed as shown below:

RTX Tasks and System: 5. Click on Start in the Update Screen box to resume the collection of data.

6. Open Debug/OS Support and select System and Thread Viewer. A window similar to below opens up. You probably have to click on its header and drag it into the middle of the screen.

7. Note this window does not update: nearly all the processor time is spent in the idle daemon: it shows it is Running. The processor spends relatively little time in the other threads. You will see this illustrated clearly on the next page.

8. Set a breakpoint in four of the threads in DirtyFilter.c by clicking in the left margin on a grey area.

9. Click on Run and the program will stop at each thread in turn and the Thread Viewer window will be updated accordingly. Here, I set a breakpoint in the disturb_gen thread:

10. Clearly you can see that disturb_gen was running when the breakpoint was activated.

11. Remove the breakpoints. Click on them or enter Ctrl-B and select Kill All.

TIP: You can set hardware breakpoints while the program is running.

TIP: Recall this window uses the CoreSight DAP read and write technology to update this window. Serial Wire Viewer is not used and is not required to be activated for this window to display and be updated.

The Event Viewer does use SWV and this is demonstrated on the next page.

Page 22:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

22

Event Viewer: 1. Stop the program. Click on Setup... in the Logic Analyzer. Select Kill All to remove all variables. This is necessary

because the SWO pin will likely be overloaded when the Event Viewer is opened up. Inaccuracies might occur. If you like – you can leave the LA loaded with the four variables to see what the Event Viewer will look like.

2. Select Debug/Debug Settings.

3. Click on the Trace tab.

4. Enable ITM Stimulus Port 31. Event Viewer uses this to collect its information.

5. Click OK twice.

6. Click on RUN.

7. Open Debug/OS Support and select Event Viewer. The window here opens up:

8. Note the main(1) thread. This screen is scrolled to the beginning after RESET. Main() runs only once.

Important TIP: If SWV trace fails to work after this change, exit Debug, cycle the board power and re-enter Debug mode.

TIP: If Event Viewer is blank or erratic, or the LA variables are not displaying or blank: this is likely because the Serial Wire Output pin is overloaded and dropping trace frames. Solutions are to delete some or all of the variables in the Logic Analyzer to free up some bandwidth.

ULINKpro is much better with SWO bandwidth issues. These have been able to display both the Event and LA windows. ULINKpro uses the faster Manchester format than the slower UART mode that ST-Link, ULINK2 and J-Link uses.

ULINKpro can also use the 4 bit Trace Port for faster operation for SWV. The Trace Port is mandatory for ETM trace.

9. Note on the Y axis each of the 5 running tasks plus the idle daemon. Each bar is an active task and shows you what task is running, when and for how long.

10. Click Stop in the Update Screen box.

11. Click on Zoom In so three or four tasks are displayed.

12. Select Cursor. Position the cursor over one set of bars and click once. A red line is set at the first arrow:

13. Move your cursor to the right over the next set (where the second arrow is) and total time and difference are displayed.

14. Note, since you enabled Show Cycles, the total cycles and difference is also shown.

The 10 msec shown is the SysTick timer value. This value is set in RTX_Conf_CM.c . The next page describes how to change this.

TIP: ITM Port 31enables sending the Event Viewer frames out the SWO port. Disabling this can save bandwidth on the SWO port if you are not using the Event Viewer.

Page 23:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

Ev

TIov

Th

Ch

TIcrThCM

TIgeCo

ThN

TMicroelectronics

vent Viewer1. Click o

2. Enable

3. Note on

4. Click o

IP: If the Evenverloading the

he Event View

hanging the

1. Stop th

2. Open thC:\Keil

3. Select tworks.

4. This wi

5. Note th

6. Change

IP: The 5,376,rystal. This proherefore it runsMSIS file syste

7. Rebuild

8. Enter d

9. When ybe spac

IP: The SysTicenerating an exonfiguration w

1. Set

2. Cli

This ends theext is how to m

s Discovery STM

r Timing: n Zoom In unt

Task Info (as w

ne entire seque

n a task to set

nt Viewer doesSWO pin. In th

wer can give you

e SysTick Tim

e processor

he file RTX_Cl\ARM\Boards

the Configurati

indow opens up

he Timer tick v

e this value to 2

,000 is the CPUogram was dess 8/25 slower them_stm32f4xx

d the source fil

debug mode

you check the tced at 2 msec.

ck is a dedicatexception 15. Ywindow.

t the SysTick t

ick on File/Sav

e exercises. make a new pro

M32F4 Lab with A

til one set of ta

well as Cursor

ence is shown.

the cursor and

not display cohis case, stop t

u a good idea i

mer Value:

and exit debu

onf_CM.c from\ST\STM32F4

ion Wizard tab

p. Expand Sys

alue is 1000 us

2,000.

U speed. The Digned for 168 Mhan designed f

x.c and is easily

les and program

and click on

timing of the ta

ed timer on CoYou can view th

imer back to 1

ve All or select

Thank you oject from scra

ARM® Keil™ MD

sks is visible a

r and Show Cyc

This screen is

move it to the

orrectly, the disthe program an

if your RTOS i

ug mode.

m the Project w4-Discovery\DS

b at the bottom

sTick Timer Co

sec or 1 msec.

Discovery boarMHz with a 25for. The PLL iy modified.

m the Flash.

RUN .

asks in the Eve

ortex-M proceshese exceptions

,000. You wil

t the Save All i

! atch, how ETM

K toolkit

23

as shown below

cles from the p

s taken with ST

end. The time

splay of the varnd delete all var

is configured c

window. You cSP.

of the window

onfiguration.

rd has a 8 MHz5 MHZ crystal.is configured in

ent Viewer win

sors that is uses in the Trace R

ll need to recom

icon:

M trace works an

Copyright © 2014

w:

previous exerci

T-Link V 2with

e difference is

riables in the Lriables (Kill A

correctly and ru

can also select

w. See page 12

z . n

ndow as you di

ed to switch tasRecords windo

mpile the sourc

nd Keil produc

ARM Limited or its aff

www.keil.co

ise).

h LA cleared o

noted. The Ta

Logic AnalyzerAll) and click on

unning in the r

File/Open in

2 for an explana

id on the previo

sks in an RTOSow by enabling

ce files and rep

ct and contact i

filiates. All rights reser

om/st

f variables.

ask Info box w

r window mighn Run.

ight sequence.

ation on how th

ous page, they

S. It does this g EXCTRC in t

program the Fla

information.

rved

will appear.

ht be

he Wizard

will now

by the Trace

ash.

Page 24:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

24

23) Creating your own MDK 5 project from scratch: All examples provided by Keil are pre-configured. All you have to do is compile them. You can use them as a template for your own projects. However, we will start an example project from the beginning to illustrate how easy this process is. Once you have the new project configured; you can build, load and run a bare Blinky example. It will have an empty main() function so it does not do much. However, the processor startup sequences are present and you can easily add your own source code and/or files. You can use this process to create any new project, including one using an RTOS.

Install the STM32 Software Pack for your processor:

1. Start µVision and leave in Edit mode. Do not be in Debug mode.

2. Pack Installer: The Pack for the STM32F4 processor must be installed. This has already been done on page 4.

3. You do not need to copy any examples over.

Create a new Directory and a New Project:

1. Click on Project/New µVision Project…

2. In the window that opens, shown below, go to the folder C:\MDK\Boards\ST\STMF32F4-Discovery\

3. Right click in this window and select New and create a new folder. I called it BlinkyNEW.

4. Double click on BlinkyNew to open it or highlight it and select Open.

5. In the File name: box, enter Blinky. Click on Save.

6. This creates the project Blinky.uvproj in C:\MDK\Boards\ST\STMF32F4-Discovery\BlinkyNEW.

7. As soon as you click on Save, the next window opens:

Select the Device you are using:

1. Expand STMicroelectronics, then STM32F4 Series, then STM32F407 and then finally select STM32F407VG:

TIP: Processor icons in green are from the Software Packs. Grey icons are from MDK 4.7x.

2. Click OK and the Manage Run Time window shown below bottom right opens.

Select the CMSIS components you want:

1. Expand all the items and select CORE and Startup as shown below. They will be highlighted in Green indicating there are no other files needed. Click OK.

2. Click on File/Save All or select the Save All icon:

3. The project Blinky.uvproj will now be changed to Blinky.uvprojx.

4. You now have a new project list as shown on the bottom left below: The appropriate CMSIS files you selected have been automatically entered and configured.

5. Note the Target Selector says Target 1. Highlight Target 1 in the Project window.

6. Click once on it and change its name to CMSIS-DAP and press Enter. The Target selector name will also change.

What has happened to this point:

You have created a blank µVision project using MDK 5 Software Packs. All you need to do now is add your own source files.

Page 25:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

C

A

TI

C

Th

TMicroelectronics

reate a blank

1. Right c

2. This wi

3. Highlig

4. In the N

5. Click o

6. Click o

7. Expandand Bli

8. It will a

dd Some Cod

9. In the b

10. Click o

11. Build th

IP: You can a

onfigure the T

1. Select t

2. Enter 8

3. Select t

4. In the BFlash.

5. Double

6. Click o

7. Click o

8. Select t

9. Select Sconnect

10. Click o

11. Click oSTM32

12. Click o

13. Click o

14. Build th

he Next Step ?

s Discovery STM

C Source File

click on Source

indow opens up

ght the upper le

Name: field, en

n Add to close

n File/Save Al

d Source Grouinky.c will now

also open in the

e to Blinky.c:

blank Blinky.c,

n File/Save Al

he files.

also add existin

Target CMSIS

the Target Opti

in Xtal (MHz)

the Output tab

Browse for Fol

e click on Flash

n the Listings

on the Debug t

the Settings: ic

SW as shown hted to your PC

n OK once to

n the Utilities 2Fx series proc

n OK twice to

n File/Save Al

he files. T

? Let us run y

M32F4 Lab with A

e:

e Group 1 in th

p:

eft icon: C file

nter Blinky.

e this window.

ll or

up 1 in the Projw display.

e Source windo

, add the C cod

ll or

There will be n#include

unsigned

/*------- MAIN fu *-------int main while(1

}

ng source files:

S-DAP: Pleas

ions icon .

). This is used

b. Click on Sel

der window th

h to enter this f

tab. Click on

tab. Select St-L

on.

here in the Port, you must now

go back to the

tab. Select Secessors:

return to the m

ll or

There will be n

your program

ARM® Keil™ MD

e Project wind

e (.c):

ect window

ow.

de below:

no errors or wa"stm32f4xx.h"

int counter =

---------------unction ---------------(void) {

1) { counter++; if (counter >}

e complete the

Select the Ta

d for timing cal

lect Folder for

hat opens: right

folder and click

Select Folder f

Link Debugger

t: box: w see a valid ID

Target Config

ettings and Add

main menu.

no errors or war

m and see what

K toolkit

25

dow and select

arnings if all w

0;

--------------

--------------

0x0F) counter

ese instruction

arget tab.

lculations. Sel

Objects…:

t click and crea

k OK. Compila

for Objects…:

r in the Use: bo

JTAG heDCODE and D

guration window

d the correct Fl

rnings if all wa

t happens ! Pl

Copyright © 2014

was entered cor

------------

------------*/

= 0;

N

s carefully to p

ect Use MicroL

ate a new folde

ation files will

Double click

ox:

ere will not woDevice Name in

w. Otherwise,

lash algorithm:

as entered corre

lease turn the

ARM Limited or its aff

www.keil.co

rrectly.

No need to at th

prevent unusu

LIB to optimiz

er called

l now be stored

on Flash and c

ork with SWV.n the SW Devi

, fix the connec

: Shown is the

ectly. If there

page….

filiates. All rights reser

om/st

.

his time.

ual problems…

ze for smaller c

d in this Flash f

click OK to clo

. If your boardice box.

ction problem.

e correct one fo

are, please fix

rved

code size.

folder.

ose.

d is

or the

them !

Page 26:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

Ru

TItim

Cl

TI

Cl

Wyoon

TIan

TMicroelectronics

unning Your

1. Program

2. Enter D

3. Click o

4. No LED

5. Right c

6. counter

7. You canthis poi

8. You shmeanin

IP: The Watchme delays inser

lock Frequenc

1. Open th

2. Locate

3. Change

4. Click o

5. Build th

6. The CP

IP: If PLL_M

leaning up yo

We modified theou did a Build bnly in .\Flash.

1. Exit µV

2. Open M C:\MD

3. Delete

4. You can

5. Restart

IP: If you wannd its contents

s Discovery STM

Program:

m the ST Flash

Debug mode by

n the RUN ico

Ds will blink si

click on counter

r should be upd

n also set a breint if it is runni

ould now be abngful project.

h 1 is updated prted, the values

cy: The CPU c

he file system_

the line #defin

e the value to 8

n File/Save Al

he files.

PU speed is now

= 336 and PLL

ur Project: (y

e folder where before this was

Vision. Otherw

Microsoft ExploDK\Boards\ST\

all files and fo

n also leave an

µVision. Hav

nt to save or senare easily reco

M32F4 Lab with A

h by clicking on

y clicking on th

on. Note:

ince there is no

r in Blinky.c an

dating as shown

eakpoint in Blining properly. I

ble to add your

periodically, nos in Watch 1 w

clock speed is 5

_stm32f4xx.c.

ne PLL_M 25

8.

ll or

w 168 MHz.

L_Q = 4, then t

you only need t

the output ands done, there w

wise, you can’t

orer and naviga\STMF32F4-D

lders except th

ny backup or µV

ving all compila

nd the project fnstructed with

ARM® Keil™ MD

n the Load icon

he Debug icon

: you stop the

o source to acc

nd select Add

n here:

nky.c and the pIf you do this, r

r own source c

ot when a variawill appear to ju

53.76 MHz. T

as shown below

the clock speed

to do this once

d listings files awill be files in y

delete files tha

ate to: iscovery\Blink

hese: (you can

Vision files tha

ation files stor

files to someon a Build.

K toolkit

26

n: Progres

.

program with t

complish this ta

counter to … a

program shouldremove the bre

ode to create a

able value chanump and skip s

o change it to

w:

d is 84 MHz.

e: this is not a c

are stored. Thiyour project ro

at it still has op

kyNEW\.

delete Flash –

at identify you

ed in the .\Flas

ne, you can del

Copyright © 2014

ss will be indic

the STOP icon

ask. You could

and select Wat

d stop at eakpoint.

a

nges. Since Blsequential valu

168 MHz:

critical step)

is was in Stepsoot directory. N

pen.

– a Build will re

ur computer to

sh folder make

lete the folder F

ARM Limited or its aff

www.keil.co

cated in the Ou

n.

d add such cod

tch 1.

linky is runninues you know m

s 3 through 7 onNow we want t

ecreate it.)

retain your set

s it cleaner.

Flash to reduce

filiates. All rights reser

om/st

utput Window.

de yourself.

g very fast witmust exist.

n the precedingthem

ttings.

e file size. Thi

rved

thout any

g page. If

is folder

Page 27:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

2ThM

Co

C

Bu

W

Tcrfr

TMicroelectronics

4) Creatihe MDK Softw

MDK 4.7x and e

onfiguring RTX

1. Using t

2. Select S

3. In Blink

4. Open th

5. Expand

6. Select K

7. Approp

8. Click o

onfigure RTX

1. In the P

2. Double

3. Select t

4. The win

5. Set Tim

6. Unselec

uild and Run

1. Build th

2. Enter D

3. Select Dwindow

4. You canrunningprogram

What you have

1. You muconfigu

2. See the

3. If you c

4. GettingimplemRTX.

his complereating yourom scratch

s Discovery STM

ing your oware Packs makearlier. The se

X is easy in M

the same examp

ST-Link Flash:

ky.c, at the top

he Manage Run

d all the elemen

Keil RTX as sh

priate RTX file

n File/Save Al

X:

Project window

e click on RTX

the Configurati

ndow is display

mer clock value

ct User Timers

Your RTX Pr

he files. P

Debug mode:

Debug/OS Supw below opens

n see two threag. As you add m, these will au

to do now:

ust add the RTured to your ne

e DSP5 and RT

copy Blinky.c f

g Started MDKmenting and ma

etes the exeur own RTXh.

M32F4 Lab with A

own RTX Mkes it easy to ccond comes w

MDK 5.10 and l

ple from the pr

:

p, add this line

n-Time Enviro

nts as shown he

hown and click

es will be added

ll or

w, expand the C

X_Conf_CM.c t

ion Wizard tab

yed here:

e: to 16800000

s. Use defaults

rogram:

Program the Fla

Click on th

pport/System anup.

ads: the main thmore threads tutomatically be

X framework ieds.

TX_Blinky5 ex

from the RTX_

K 5: Obtain thaintaining

ercise of X project

ARM® Keil™ MD

MDK 5 proonfigure an RTith MDK 5.10

ater. These ste

receding pages

: #include "cm

onment window

ere:

k OK.

d to your proje

CMSIS group.

to open it.

b: Select Expan

00 as shown: (

s for the other s

ash: .

he RUN icon.

nd Thread View

hread is the onto create a real e added to this

into your code

xamples to use

_Blinky projec

his useful book

K toolkit

27

oject fromTX project. Thand later. Thi

eps use the sam

s, Stop the prog

msis_os.h"

w:

ect. See the Pro

nd All.

(168 MHz)

settings.

wer. The

nly one RTX window.

and create you

as templates an

ct, it will blink

k here: www.ke

Copyright © 2014

m scratch: here are two veis second one i

me configuratio

gram and E

oject window.

ur threads to m

nd hints.

the LEDs. It h

eil.com/mdk5/

ARM Limited or its aff

www.keil.co

ersions of RTXis CMSIS-RTO

on as in the pre

Exit Debug mo

make this into a

has the RTX co

/. It has very u

filiates. All rights reser

om/st

X: The first comOS compliant.

eceding Blinky

ode.

a real RTX proj

ode incorporate

useful informat

rved

mes with

y example.

ject

ed into it.

ion on

Page 28:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

2Thbo

ET

M

TIto

TMicroelectronics

5) ETM These examples oard. These ex

TM provides s

Most STM32 pr

1. Connec

2. Start µV

3. Select P

4. Select T

5. Compil

6. Program

7. Enter D

8. DO NO

9. Open th

10. ExaminRESET

11. In this c

the valu

12. The insthe func

13. Scroll tinstruct

IP: You can se save only the

A Sspe

s Discovery STM

Trace Examwere run on th

xamples are inc

erious debuggi

ocessors are ET

ct the ULINKp

Vision by click

Project/Open P

TracePort Instr

le the source fi

m the STM32 f

Debug mode by

OT CLICK ON

he Data Trace w

ne the InstructiT until µVision

case, 086 444 s

ue of the next i

struction PUSHction where the

to the top of thetion executed a

et Trace Triggeframes you are

STM3240G-Eecial CoreSigh

M32F4 Lab with A

mples: Fo

he STM3240Gcluded for refer

ing power as sh

TM equipped.

pro to the STM

king on its desk

Project. Open C

ruction Trace in

iles by clicking

flash by clickin

y clicking on th

N RUN YET !!!

window by clic

on Trace windn halted the pro

s shows the las

instruction to b

H will display ae assembly isn

e Instruction Tafter RESET.

ers to start and e interested in.

EVAL board cht 20 pin ETM

ARM® Keil™ MD

or reference o

-EVAL evaluarence. A ULIN

hown on the ne

M3240G board u

ktop icon.

C:\Keil\ARM\B

n the Target O

g on the Rebuil

ng on the Load

he Debug icon.

!

cking on the sm

dow as shown bogram at the sta

st instruction to

be executed (0x

as shown on thnstructions are l

Trace window t

stop the Trace

onnected to aM connector:

K toolkit

28

only…Note:

ation board. ThNKpro debug a

ext few pages.

using the 20 pi

Boards\ST\STM

ptions box as s

ld icon. . Y

d icon: Pro

Select O

mall arrow bes

below: This is art of main() sin

o be executed.

x0800_0188 in

e last line in thlocated with th

to frame # 1. T

e collection. Th

ULINKpro us

Copyright © 2014

MDK 5 has e

hese are applicadapter is requ

It is worth the

in CN13 Trace

M3240G-EVA

shown here:

You can also u

ogress will be i

OK if the Evalu

side the Trace W

a complete recnce Run To m

(BX r0). In th

n my case). Cli

he trace windowhe start highligh

This is the

his allows

sing the

ARM Limited or its aff

www.keil.co

enhanced win

cable for the Keuired for ETM o

e small added c

connector.

AL\ Blinky_Ulp

use the Build ic

indicated in the

ation Mode bo

Windows icon.

cord of all the main is selected

he Register win

ick on Single S

w. Note the fuhted in orange

filiates. All rights reser

om/st

ndows and trig

eil MCBSTM3operation.

cost.

p\Blinky.uvpro

con beside it.

e Output Wind

ox appears.

.

program flow in µVision.

ndow the PC w

Step once.

unction column.

rved

iggers:

32F400

oj.

dow.

since

will display

n diplsyas

first

you

Page 29:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

3

Co

InCow

W0x

Cocoinas

Go

Co

A yo

TMicroelectronics

) Code Co

14. Click o

15. Examin

16. This is

olour blocks in

t

n the window oode Coverage bere taken (or n

Why was the brax800_105C wa

ode Coverage tompiler is execnstructions to bs the US FDA r

ood programm

ode Coverage i

Code Coveragour display may

s Discovery STM

overage:

n the RUN ico

ne the Disassem

Code Coverag

ndicate which a

1. Green: t

2. Gray: th

3. Orange:

4. Cyan: a

5. Light Grthis point.

6. RED: Br

7. Next ins

on the right youblock and if th

not).

anch BCC alwaas never taken ?

tells what assecuted and testede executed. Threquire Code C

ming practice re

is captured by

ge window is ay look differen

M32F4 Lab with A

For refere

on. After

mbly and Blink

ge provided by

assembly instru

his assembly in

his assembly in

a Branch is alw

Branch is alwa

ray: there is no

reakpoint is set

struction to be e

u can easily seehey were execu

ays taken resul? You should

mbly instructiod. You do not he result could

Coverage for ce

equires that the

the ETM. Cod

available as shont due to differe

ARM® Keil™ MD

nce only…

a second or so

ky.c windows.

ETM trace. T

uctions have be

nstruction was

struction was n

ways not taken

ays taken.

o assembly ins

t here.

executed.

e examples of euted or not and

lting in 0x0800devise tests to

ons were execuwant a bug or

d be catastrophiertification.

ese unexecuted

de Coverage is

own below. Thent compiler op

K toolkit

29

o stop the progr

Scroll and not

This indicates if

een executed.

executed.

not executed.

n.

struction at

each type of if branches

0_1048 never bexecute these

uted. It is impoan unplanned

ic as unexecute

instructions be

s also available

his window is aptions.

Copyright © 2014

ram with the S

tice different c

f an instruction

being executedinstructions so

ortant to ensurcircumstance ted instructions

e identified an

e in the Keil Sim

available in Vi

ARM Limited or its aff

www.keil.co

STOP icon.

color blocks in

n has been exec

d ? Or why theo you can test t

re all assembly to cause a sequcannot be test

nd tested.

mulator.

iew/Analysis/C

filiates. All rights reser

om/st

the left margin

cuted or not.

e branch BGE athem.

code produceduence of untestted. Some agen

Code Coverage

rved

n:

at

d by the ted ncies such

e. Note

Page 30:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

4PeSaSm

KThfo

TIca

Wto

TMicroelectronics

) Performerformance Anamples or the Emall loops cou

eil provides Pehe number of t

or a quick refer

1. Use the

2. Select V

3. Exit Demain()

4. Expand

5. Note thdisplay

6. We can

7. Click o

8. Note thcollect

9. Select F

10. Exit an

11. When y

IP: You can alan type g, main

When you click stop working.

s Discovery STM

mance Ananalysis tells youETM. If providld be entirely m

erformance Anotal calls madeence. If you ar

e same setup as

View/Analysis

ebug mode andas before. Or

d some of the m

he execution inyed.

n tell that most

n the RUN ico

he display chanthe informatio

Functions from

d re-enter Deb

you are done, e

lso click on then in the Comm

on the RESET Exiting and r

M32F4 Lab with A

alysis (PAu how much timded by the SWmissed. ETM p

nalysis with thee as well as there optimizing f

s used with Co

Windows/Per

d immediately rselect the Rese

module names a

formation that

of the time at t

on.

nges in real-timn. No code stu

m the pull down

ug mode again

exit Debug mod

e RESET icon mand window to

T icon, the Initire-entering Deb

ARM® Keil™ MD

A): For refme was spent i

WV, the results wprovides comp

e µVision simue total time spefor speed, work

de Coverage.

rformance Anal

re-enter it. et icon in the P

as shown below

has been colle

this point in th

me while the proubs are needed

n box as shown

n and click on R

de.

but the po accomplish th

ialization File .bug mode exec

K toolkit

30

ference onlin each functionwill be statistic

plete Performan

ulator or with Eent in each funck first on those

lysis. A windo

This clears thPA window to c

w.

ected in this ini

he program has

ogram Blinky id in your source

n here and noti

RUN. Note th

processor will shis.

ini will no longcutes the .ini sc

Copyright © 2014

ly… n. The data cacal and more acnce Analysis.

ETM and the Uction is displaye functions taki

ow similar to th

he PA windowclear it. Run th

itial short run.

been spent in

is running. The files.

ce the differen

e different data

stay at the initi

nger be in effeccript again.

ARM Limited or its aff

www.keil.co

an be provided ccuracy is impKeil provides

ULINKpro. SWyed. A graphicing the longest

he one below w

w and resets thehe program for

Both times an

the GLCD rou

here is no need

nce.

a set displayed

ial PC and will

ct and this can c

filiates. All rights reser

om/st

by either the Sproved with lononly ETM PA

WV PA is not ocal display is gt time to execu

will open up.

e STM32 and rer a short time.

nd number of c

utines.

to stop the pro

d.

l not run to mai

cause SWV an

rved

SWV PC nger runs. .

offered. enerated te.

eruns it to

alls is

ocessor to

in(). You

nd/or ETM

Page 31:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

31

5) Execution Profiling: For reference only… Execution Profiling is used to display how much time a C source line took to execute and how many times it was called. This information is provided by the ETM trace. It is possible to group source lines (called collapse) to get combined times and number of calls. This is called Outlining. The µVision simulator also provides Execution Profiling.

1. Enter Debug mode.

2. Select Debug/Execution Profiling/Show Time.

3. In the left margin of the disassembly and C source windows will display various time values.

4. Click on RUN.

5. The times will start to fill up as shown below right:

6. Click inside the yellow margin of Blinky.c to refresh it.

7. This is done in real-time and without stealing CPU cycles.

8. Hover the cursor over a time and ands more information appears as in the yellow box here:

9. Recall you can also select Show Calls and this information rather than the execution times will be displayed in the margin.

Page 32:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

6Sokninesco

If adtra

Thha0x

Thbude

TI

Th

TMicroelectronics

) In-the-ome of the hardnow that it happnterrupts and Rspecially when onditions and d

f a Hard Fault oddress points toace buffer will

his exception vandler and run x0800 01B0 as

he CPU and alsuffer will be vietermine the ca

1. Open thFlash anwindow

2. Locate

3. Set a br

4. Run the

5. Click o

6. In the Dbelow i

7. Right c0x0800Counte

8. Click othe Har

9. Examinbottom

IP: The addre

10. Note thbecausetherefor

he frames abov

s Discovery STM

-Weeds Exdest problems tpened and the TOS task switca problem occ

determining how

occurs, the CPUo the Hard Fausave millions

vector is found the program: a shown to the r

so the trace colsible and extre

ause of the cras

he Blinky_Ulpnd enter Debug

w.

the Hard fault

reakpoint at thi

e Blinky examp

n the Step_Ou

Disassembly win the third win

click on the PO0 124E as showr. This will be

n RUN and imrd Fault except

ne the Data Trascreen are the

esses you get w

he Branch at thee a hardware brre it is not reco

ve the POP are

M32F4 Lab with A

xample: Fto solve are thostack is corrupching plus unecurs and the conw to fix them.

U will end up alt handler. Thiof the same br

in the file starat the next Hardright) and stop

llection will stoemely useful tosh.

example, rebug mode. Open

vector near lin

is point. A red

ple for a few se

ut icon to g

window, scroll dndow:

OP instruction (wn below) and se the next instru

mmediately the tion branch inst

ace window an4 MOV instru

will be different

e Hard Fault dreakpoint does

orded in the tra

a record of all

ARM® Keil™ MD

For referencose when a crapted or providexpected and spnsequences are ETM trace ha

at the address sis is usually a b

ranch instructio

rtup_stm32f4xxd Fault event th.

op. The trace o investigate an

uild, program thn the Data Trac

ne 207 in the di

d block will app

econds and clic

go back to the m

down until you

or at the MOVselect Set Proguction execute

program will struction.

nd you find thisuctions plus the

t than these one

oes not show ins execute the inace buffer.

l previous instr

K toolkit

32

ce only… A Uash has occurrees no useful clupurious events.e not immediatandles these pro

specified in thebranch to itselfons. This is no

x.s. If we set ahe CPU will ju

nd

he ce

isassembly win

pear as shown

ck on STOP.

main() program

u find a POP in

V at gram d.

stop on

s POP plus evee offending PO

es.

n the trace winnstruction it is s

ructions execut

Copyright © 2014

ULINKpro is ed and you havues. Modern pr. Having a rectely visible. Aoblems and oth

e Hard Fault vef and this Bran

ot useful. We n

a breakpoint byump to the Har

ndow or in star

above.

m as shown in

nstruction. I fo

erything else thOP.

ndow set to

ted and tells yo

ARM Limited or its aff

www.keil.co

needed for ve no clue whatrograms tend tording of the p

Another problemhers easily and

ector located atnch instruction need to stop the

y double-clickrd Fault handle

rtup_stm32f4x

the Call Stack

ound one at 0x0

hat was previou

ou the complet

filiates. All rights reser

om/st

Instruction t caused this. Yto be asynchronprogram flow im is detecting rd is not hard to

t 0x00 000C. Twill run forevee CPU at this p

king on the Harer (in this case l

xx.s.

+ Locals wind

0800 1256 as s

usly executed.

e program flow

rved

Trace: You only nous with s useful race use.

This er. The point.

rd Fault located at

dow:

hown

In the

w.

Page 33:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

2by

TI

TIon

TIJT

N

D

It pr

UsuDire

If coco

It

Th

Se

TMicroelectronics

6) Config default in the exa

1. Connecfirst sta

2. Select TDebugg

IP: Do NOT s

3. Select Spanel fo

4. In Port

5. In the Sprocesspower s

IP: To refreshnce to leave an

IP: You can TAG except for

ext page: con

ebug Adapter

is easy to selecrogramming in

sing other Debuitable adjustmiscovery boardported that sho

f your debugginonnector providonnect an exter

is possible to u

he ST-Link is s

erial Wire View

s Discovery STM

guring themple programs. T

ct your PC to tharted – the alter

Target Optionsger as shown h

select ST-Link

Settings and thor the ULINKs

t: select SW.

SW Device aresor. If there is supply. Cycle

h this screen sed then click on

do everything r boundary sca

nfigure the Ke

rs:

ct a USB debutwo separate w

bug Adaptersments. You woud. Some step(sorting solder br

ng sessions aredes the ability trnal tool such a

use a Segger J-

selected as the

wer (SWV) is c

M32F4 Lab with A

e ST-Link These instructions a

he Discovery brnative to Debu

s or ALT-Fhere:

(Deprecated V

he next windows and ST-Link.

JTAG is not a

a: ARM CoreSan error displathe power to th

lect Port: and cn Settings again

with SW (SWan.

il Flash progr

gging adapter windows as des

: This documeuld need a suitas) to turn off thridge SB10 wil

unreliable, pleto use the Disc

as a Keil ULIN

-Link with µVi

default debug

completely sup

ARM® Keil™ MD

Debug Coare provided for re

board with a USug mode) and y

F7 and select th

Version).

w below opens u (they are the s

valid option fo

Sight SW-DP Mayed or it is blahe board.

change it or clin.

WD) as you can

ramming tool:

in µVision. Yscribed below.

ent uses the onable adapter toe on-board STll hold the ST-L

ease check for covery board as

NK2. Some ada

ision. Serial W

adapter for the

pported by ST-

K toolkit

33

onnection eference.

SB cable. Staryou have selec

he Debug tab.

up. This is thesame).

or ST-Link and

MUST be dispank this must b

ick OK

with

ou must config They are each

n-board ST-Lino connect a diff-Link adapter mLink processor

additional cons a debug adapaptation is requ

Wire Viewer is

e Keil example

-LINK Version

Copyright © 2014

to the tar

rt µVision. It mcted a valid pro

In the drop-do

e control

d this board. S

layed. This cobe fixed before

gure the conneh selected usin

nk. You can usferent adapter tmight also be nr in RESET all

nflicts or loadinpter on another uired but not di

supported.

es for this Disc

n 2. Firmware

ARM Limited or its aff

www.keil.co

rget: The follo

must be in Editoject. Blinky w

own menu box

SW is also know

onfirms you aree you can conti

ction to both thng the Debug a

se a ULINK2 oto the SWD conecessary to avlowing externa

ng on the SWDr board. Its maifficult to do.

covery board.

V2.16.S0 or la

filiates. All rights reser

om/st

owing steps are alr

t mode (as it iswill do fine.

x select ST-Lin

wn as SWD.

e connected to nue. Check th

he target and toand Utilities tab

or a ULINKproonnector on thevoid conflicts. al adapter opera

D pins. The SWain purpose is n

ater except V2.

rved

ready done

s when

nk

the target he target

o Flash bs.

o with e It is ation.

WD not to

.19.S0.

Page 34:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

2

TIch

TIin

TIVi

C LELEtoLELEN

R

It

uspr

Thhe

Lo

TMicroelectronics

7) Config6. Click o

7. Select t

8. Click S

9. Select S

10. Click o

IP: To prograheck Update tar

IP: If you selen the Debug tab

11. Click o

12. Select F

13. You haprocessprogram

IP: The Traceiewer (SWV).

OM led LD1 i

ED is blinking ED is RED: co ST-Link (i.e. ED is GREENED is blinking o Led: ST-LIN

Running prog

is possible to r

sed nor is the Lrocessor and lo

he Discovery Bere if you want

oading and Ru

1. Select S

2. Select T

3. The ini

4. Click o

5. Click obetween

6. Click o

7. Return

s Discovery STM

gure the Kn OK once and

the ST-Ling De

Settings to selec

STM32F4xx F

n OK once.

m the Flash evrget before De

ect Use Debug b will be used.

n OK to return

File/Save All.

ave successfullysor and configummer.

e tab is where y You will learn

indication:

RED: the firstommunication bin Debug mod: µVision is coGREEN/RED

NK/V2 comm

grams in the i

run your progra

Load icon. Afteoads your execu

Blinky project ht to try this mod

unning your p

STM32F407 R

Target Options

file is located

n Edit… to vie

n the Target tan the R/O and

n OK to return

to the STM32F

M32F4 Lab with A

Keil Flash d select the Uti

ebugger simila

ct the programm

lash as shown

very time you ebugging.

Driver, the de

n to the µVision

y connected toured the µVisio

you configure tn to do this late

t USB enumerabetween the PCe).

onnected in DebD: data is active

unication with

internal STM

am in the proc

er successfullyutable into RA

has a RAM setde.

program into R

RAM as shown

s or ALT-F

in the Initializ

ew its contents

ab. Note the RAR/W memory

n to the main µ

F407 Flash set

ARM® Keil™ MD

Programmilities tab.

ar to Step 2 abo

ming algorithm

here or the one

enter Debug mo

bugger you sel

n main screen.

the STM32 taon Flash

the Serial Wireer.

ation with the PC and ST-LINK

bug mode and ely being exchah the target or

M32 RAM:

essor RAM rat

y compiling theM.

tting. Select S

RAM:

above.

F7 and select th

ation File: box

.

AM at 0x2000areas.

Vision window

tting.

K toolkit

34

mer:

ove.

m if it is not vis

e for your proc

ode,

lected

arget

e

PC is taking plK/V2 is establi

the last commanged betweenr µVision has

ther than Flash

e source files, c

TM32F407 RA

he Debug tab.

x as shown here

0_0000 is split

w.

Copyright © 2014

sible or is the w

cessor:

lace. ished (end of e

munication wasn the target andfailed. Cycle

h. In this case,

click on Debug

AM as shown

e:

ARM Limited or its aff

www.keil.co

wrong one.

enumeration).

successful. d µVision.

the board pow

the Flash prog

g icon . An

filiates. All rights reser

om/st

µVision is not

wer to restart

gramming tool

n .ini file confi

rved

t connected

.

is not

figures the

Page 35:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

35

28) Serial Wire Viewer and ETM Trace Summary:

Serial Wire Viewer can see: Global variables.

Static variables.

Structures.

Peripheral registers – just read or write to them.

Can’t see local variables. (just make them global or static).

Can’t see DMA transfers – DMA bypasses CPU and SWV by definition.

Serial Wire Viewer displays in various ways: PC Samples.

Data reads and writes.

Exception and interrupt events.

CPU counters.

Timestamps.

ETM Trace is good for: Trace adds significant power to debugging efforts. Tells where the program has been.

A recorded history of the program execution in the order it happened.

Trace can often find nasty problems very quickly. Weeks or months can be replaced by minutes.

Especially where the bug occurs a long time before the consequences are seen.

Or where the state of the system disappears with a change in scope(s).

Plus - don’t have to stop the program. Crucial to some projects.

These are the types of problems that can be found with a quality ETM trace: Pointer problems. Illegal instructions and data aborts (such as misaligned writes).

Code overwrites – writes to Flash, unexpected writes to peripheral registers (SFRs), a corrupted stack. How did I get here ?

Out of bounds data. Uninitialized variables and arrays.

Stack overflows. What causes the stack to grow bigger than it should ?

Runaway programs: your program has gone off into the weeds and you need to know what instruction caused this. Is very tough to find these problems without a trace. ETM trace is best for this.

Communication protocol and timing issues. System timing problems.

ETM facilitates Code Coverage, Performance Analysis and program flow debugging and analysis.

For information on Instruction Trace (ETM) pleas e visit www.keil.com/st for other labs discussing ETM.

Page 36:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

Copyright © 2014 ARM Limited or its affiliates. All rights reserved

STMicroelectronics Discovery STM32F4 Lab with ARM® Keil™ MDK toolkit www.keil.com/st

36

29) Document Resources: See www.keil.com/st Books:

1. NEW! Getting Started MDK 5: Obtain this free book here: www.keil.com/mdk5/.

2. There is a good selection of books available on ARM processors. A good list of books on ARM processors is found at www.arm.com/university by selecting “Teaching Resources”. You can also select ARM Related Books but make sure to also select the “Books suited for Academia” tab to see the full selection.

3. µVision contains a window titled Books. Many documents including data sheets are located there.

4. A list of resources is located at: www.arm.com/products/processors/cortex-m/index.php Click on the Resources tab. Or search for “Cortex-M3” on www.arm.com and click on the Resources tab.

5. The Definitive Guide to the ARM Cortex-M0/M0+ by Joseph Yiu. Search the web for retailers.

6. The Definitive Guide to the ARM Cortex-M3/M4 by Joseph Yiu. Search the web for retailers.

7. Embedded Systems: Introduction to Arm Cortex-M Microcontrollers (3 volumes) by Jonathan Valvano.

Application Notes: 8. Using Cortex-M3 and Cortex-M4 Fault Exceptions www.keil.com/appnotes/files/apnt209.pdf

9. Segger emWin GUIBuilder with µVision™ www.keil.com/appnotes/files/apnt_234.pdf

10. Porting mbed Project to Keil MDK™ www.keil.com/appnotes/docs/apnt_207.asp

11. MDK-ARM™ Compiler Optimizations www.keil.com/appnotes/docs/apnt_202.asp

12. Using µVision with CodeSourcery GNU www.keil.com/appnotes/docs/apnt_199.asp

13. RTX CMSIS-RTOS in MDK 5 C:\Keil_v5\ARM\Pack\ARM\CMSIS\3.20.4\CMSIS_RTXDownload

14. RTX CMSIS-RTX www.keil.com/demo/eval/rtx.htm and www.arm.com/cmsis

15. Barrier Instructions http://infocenter.arm.com/help/topic/com.arm.doc.dai0321a/index.html

16. Lazy Stacking on the Cortex-M4: www.arm.com and search for DAI0298A

17. Cortex Debug Connectors: www.arm.com and search for cortex_debug_connectors.pdf

18. Sending ITM printf to external Windows applications: www.keil.com/appnotes/docs/apnt_240.asp

Keil Tutorials for STMicroelectronics Boards: see www.keil.com/st

Community Forums: www.keil.com/forum and http://community.arm.com/groups/tools/content

ARM University program: www.arm.com/university. Email: [email protected]

ARM Accredited Engineer Program: www.arm.com/aae

mbed: http://mbed.org

For comments or corrections on this document please email [email protected].

For more information on the ARM CMSIS standard: www.arm.com/cmsis,

Page 37:  · ST ST Di fea In Th to At K fo Li K th R W Th S Se co SW Co E ET as An no D Th UL th K Microelectronics Microel scovery turing Ser troductio e purpose of t olkit

ST

3

K

Fo

U

Th

Alww

K

CaSaTh

Al

Al

Cavi

Mmprin

C

Fo

Fo

FoK

K

Fo

Fo

CM

Al

TMicroelectronics

0) Keil P

Keil Microc MDK-L

NEW MDK-S MDK-P

or special pr

USB-JTAG ULINK ULINK ULINKp

he Keil RTX R

ll versions, incww.keil.com/d

eil provides fre

all Keil Sales fales can also prhey will help y

ll products are

ll products incl

all Keil Sales fiew various pro

MDK supports Smany other ST p

rocessors. See nformation is al

ontact Keil Sa

or the entire Ke

or Linux, Andr

or more inKeil Sales In US

Keil Technical

or comments o

or the latest ver

MSIS Version

lso see www.k

s Discovery STM

roducts a

controller Lite™ (Evalua

!! MDK-ARMStandard™ (uProfessional™romotional p

adapters 2 - (ULINK2-ME – sold onpro – Cortex MDK

RTOS is now p

cluding MDK-Ldemo/eval/rtx.h

ee DSP librarie

for details on crovide advice a

you find variou

available from

lude Technical

for special univograms and res

STM32 Cortexprocessors incluthe Keil Devic

lso included in

ales for USA p

eil catalog see

roid and bare m

nformatioSA: sales.us@k

Support in US

r corrections p

rsion of this do

3: See www.a

keil.com/st an

M32F4 Lab with A

nd Contac

Developmation version)

M-CM™ (for Cunlimited com™ (Includes Fl

pricing and

(for Flas2 and ME - SWnly with a box-Mx SWV & K also supporrovided under

Lite, includes Khtm or C:\Keil_

es with source

urrent pricing,about the vario

us labs and appn

m stock.

l Support for 1

versity pricing.sources.

x-M3 and Corteuding 8051, ARce Database® o MDK.

prices. Contac

www.keil.com

metal (no OS) s

on: keil.com or 800

SA: support.us

please email bo

ocument and fo

arm.com/cmsis

d www.keil.co

ARM® Keil™ MD

ct Informa

ment Kit () $0

Cortex-M sermpile and deb

ash File, TCP/

offers, plea

h programWV only – noard by Keil oETM trace. rts ST-Link, Ca Berkeley BS

Keil RTX RTO_v5\ARM\Pack

code for Corte

specials and qous tools optionnotes that are u

year. This is e

. Go to www.a

ex-M4 processoRM7, ARM9™

on www.keil.co

ct sales.intl@k

m or contact Ke

support on ST p

0-348-8051. O

@keil.com or

[email protected]

or more STMic

s and http://com

om/forum

K toolkit

37

ation:

MDK-ARM

ies processorbug code and /IP, CAN and U

ase contact

mming tooo ETM) r OEM.

CMSIS-DAP aSD type license

OS with sourcek\ARM\CMSI

ex-M processor

quantity discouns available to useful.

easily renewed

arm.com/unive

ors. Keil supp™ and ST10 om/dd for the c

keil.com for pri

eil or your loca

processors suc

Outside the US

800-348-8051.

com.

croelectronics s

mmunity.arm.c

Copyright © 2014

M™)

rs only – unli data size)

USB driver libra

Keil Sales fo

o)

and Segger J-e. This makes

e code ! S

rs.

unts. you.

d.

ersity to

ports

complete list o

icing in other c

al distributor.

ch as SPEAr, pl

: sales.intl@k

. Outside the U

specific inform

com/groups/too

ARM Limited or its aff

www.keil.co

mited code li

aries) for details.

-Link Debug ait free.

f STMicroelec

countries.

lease see DS-5

keil.com

US: support.in

mation, go to w

ols/content for

filiates. All rights reser

om/st

imit)

adapters.

ctronics suppor

5 www.arm.com

[email protected].

www.keil.com/s

r more informa

rved

rt. This

m/ds5.

st

ation.