5 - Keil MDK Version 5 - Hands-On
5 - Keil MDK Version 5 - Hands-On
5 - Keil MDK Version 5 - Hands-On
Christopher Seidl
Technical Marketing Manager, DSG
1
Installing the Workshop Material
Required software:
DAVE™ 3.1.10 Including the latest Updates
MDK Version 5.11: MDK511.exe
MDK Add-On Installer: MDK-ARM_Pro_Eval_AddOn.exe
Infineon XMC400 Device Family Pack: Infineon.XMC4500_DFP.2.0.0.pack
DAVE Project:
Please use the one that has been created in the morning session. If you do not have it, use:
Project\Relax_kit.zip (can be imported into DAVE™ using the DAVE™ import functionality: File
Import DAVE Project; then browse to the project ZIP file)
2
Software Packs in Keil MDK Version 5
MDK Core
3
Software Packs
Software Pack
Software components are delivered in one
easy to install Software Pack Component
Libraries
Configuration Files
A package description file (PDSC) contains: Header File (API)
Supplier information Documentation
4
Device Family Pack Device Family
Pack
Example: Infineon.XMC4500_DFP
System/Startup
Device family and devices startup_device.s
Tool chains
CMSIS-Driver
Example Projects USB, …
5
MDK-Professional Middleware
6
6
Middleware: Network
7
Middleware: Graphic
8
Middleware: USB Host
USB Host Component
HID
Human Interface Device
CORE
Class
MSC
USB Host
Mass Storage
Driver
9
Middleware: USB Device
10
Middleware: File System
Variants:
NAND Flash NOR Flash
Memory Card • Long File Names
SD/SDHC/MMC • Short File Names
Driver
MCI
NAND Flash NOR Flash
SPI
11
Web Portal for Software Packs
12
Keil MDK Workflow using Software Packs
13
Component View and templates in Keil MDK Version 5
14
Advantages of Software Components in Keil MDK
Enhanced Long-term
Improved Flexibility
Productivity Project Maintenance
• Convenient • Software Packs • Support for new
selection of with update facility devices is provided
software and version by Software Packs
components management
• Easy access to • Open standard
documentation • Simplifies the allows adding third
• Code templates and replacement of the party components
examples to kick- target device
start development
15
Importing DAVE™ projects in MDK Version 5
Hands-On
16
Required Setting for GPDSC Generation
18
Resource Solving and Code Generation
Next, the library code of the DAVE™ Apps needs to be generated. This will also trigger
the creation of the GPDSC file.
Click the Generate Code button:
19
Invoking µVision® from DAVE™
To import the project to µVision, simply double-click the Relax_kit.gpdsc file in the
C/C++ Projects view.
µVision starts:
Note: µVision will create a project in the same folder as the DAVE™ project
20
Add a Main.c File to the µVision® Project
1. Click on Main.c
2. Click Add
3. Click Close
21
Explore the Project
22
Going Back to DAVE™
Changing the DAVE™ project (add/remove Apps or adjust App settings) needs to be
done in DAVE™.
The Play button in the Manage Run-Time Environment window invokes DAVE™ with
the correct project:
23
Open Target Options Dialog
24
Select the J-LINK Debugger
25
Enable the SW Port
µVision will try to connect to the J-LINK using a JTAG port. This is not available on the
Relax Kit
Click on Port: JTAG and set to SW
The connected device will be detected
automatically
Click OK twice
26
Build the Project and Download to Target
Go to Flash Download (or click on ) to download the program into the target’s
Flash memory
27
Start a Debug Session
Go to Debug Start/Stop
Debug Session (or press
CTRL+F5) to switch to the
µVision debugger.
During the start of the debug
session, µVision loads the
application, executes startup
code, and stops at the main C
function
Click Run on the toolbar. The
LED connected to P1.1 will start
flashing
28
printf Debugging using the
Instrumentation Trace Macrocell (ITM)
29
CoreSight
On-chip Debug and Trace Technology
Debug Interface
JTAG/Serial Wire Debug (SWD)
Start/Stop/Single Step Debug
Set/Reset Breakpoints
Read/Write Memory and Peripheral Registers
Trace Port Interface
Serial Wire Trace Output (SWO) only in
SWD debug mode
Instrumentation Trace Macrocell (ITM)
provides:
Printf debugging
RTOS information
Interrupt execution information
30
Serial Wire Viewer (SWV) – Real-Time Trace
The Serial Wire Viewer (SWV) provides real-time data trace information from various
sources within the Cortex-M3/M4 device. This is output via the single SWO pin while
your system processor continues running at full speed.
Diagnostic system information is available from the ITM and DWT:
Data read/write of selected variables
PC values
Exception and interrupt execution
Timing statistics
Periodic samples of the program counter
Event counters display CPU statistics
Indicates required device wait states or the idle time
31
SWV: Three Ways to View Variables
32
SWV Trace Windows
Event Counters
Real-time values of event counters
Trace Exceptions
Statistical information about
program exceptions
Trace Data (with ETM Trace only)
Time stamps, PC sample, r/w accesses
Updated while target system is running
33
Event Counters
34
Trace Exceptions
35
ITM printf Debugging
Install Private.Debug_ITM.1.0.0.pack
Double-click on Private.Debug_ITM.1.0.0.pack in the Packs directory of your USB
stick
The Pack will automatically be installed:
Open the Manage Run-Time Environment window in µVision and browse to the Debug
software component:
36
Setting the __DBG_ITM Define
37
Enabling Trace in J-LINK
http://www.keil.com/support/man/docs/jlink/jlink_cortextrace.htm
Click on the Debug tab.
Click on Settings. A new window opens
(Cortex JLink/JTrace Target Driver Setup)
1. Click on the Trace tab
2. Check Enable
3. Enter the correct Core Clock:
120 MHz
4. Click OK twice
38
Add Code to Main.c
39
Rebuild the Project and Download to Target
40
Debug (printf) Viewer
41
ULINKpro
Debug and Trace Adapter
Programming + Run Control
Memory + Breakpoint Access
Serial Wire Trace (SWO)
100 Mbps (Manchester Mode)
ITM and Data Trace @ CPU speed
ETM Streaming Trace
Up to 800 Mbps
100% Code Coverage and Performance Analysis
SWO ETM
JTAG SWD
100 Mpbs Streaming
42
ULINKpro
Fastest Data Trace
100 x faster than most other MCU solutions
Real-Time data trace analysis
CPU operates at full speed
No overflows or lost data
MDK gives clear visibility into application
behaviour
SWO ETM
JTAG SWD
100 Mpbs Streaming
43
ULINKpro
Streaming Instruction Trace
What is Streaming Trace?
Trace data transferred in real-time to debug host
Trace for minutes, hours, or longer
Required for full code-coverage and
timing analysis
ULINKpro
Only solution to stream trace directly to PC
Search trace data
Save trace data
Function trace
Synchronized to source code
SWO ETM
JTAG SWD
100 Mpbs Streaming
44
ULINKpro
Advanced Debug Capability
Streaming Instruction Trace Code Coverage
Debug historical sequences Implement 100% accurate Code Coverage on
Full details of execution history silicon
Application Soak testing over long periods Essential for validation and verification
of time Fastest Data Trace
Performance Analysis 100 times faster than any other solution
Optimize and Profile Applications CPU at full speed
Identify hotspots quickly No overflows or lost data
SWO ETM
JTAG SWD
100 Mpbs Streaming
45
Creating Applications using Software Packs
46
Objective: Blinky Project with RTOS
Later, we will add a USB driver and Middleware to set and reset the LEDs from a PC
47
Create a New Project
48
Select Device for Target: XMC4500-F100x1024
49
Manage Run-Time Environment
Select Software Components
Expand CMSIS
Select CORE
Validation Output shows required
software components
In Validation Output click on
Infineon::Device:Startup
You will be automatically directed to the
required component
Select the component
Expand CMSIS:RTOS (API)
Select Keil RTX
Click OK
50
Add Code
Copy the files main.c, LED.c, and LED.h from the Code directory on the USB stick to
your RTOS_Blinky project directory
Expand Target 1 in the Project view
Right click on Source Group 1 and select
Add Existing Files to Group ‘Source Group 1’…
Click on main.c and LED.c
1. Click Add
2. Click Close
51
Work with the Code
53
Build the Project
54
Select the J-LINK Debugger
55
Enable the SW Port
µVision will try to connect to the J-LINK using a JTAG port. This is not available on the
Relax Kit
Click on Port: JTAG and set to SW
The connected device will be identified
automatically
56
Enabling Trace in J-LINK
57
Start a Debug Session
Go to Debug Start/Stop
Debug Session (or press
CTRL+F5) to switch to the
µVision debugger.
During the start of the debug
session, µVision loads the
application, executes startup
code, and stops at the main C
function
Click Run on the toolbar.
LED1 and LED2 will start flashing
alternately
58
Add more Debug Information
59
Kernel-Aware Debugging
60
Trace Exceptions
61
System Viewer
62
Extending the Project with USB
63
Adding USB Functionality to the Project
64
CMSIS-Driver 2.0 Software Packs
Microcontroller Device Middleware
Control
Startup/System
API describing peripheral Structs
driver interfaces for USB USB Controller USB Device Driver USBD0 USB Device
Infineon::XMC4000_DFP USB USB Controller USB Host Driver USBH0 USB Host
provides compliant drivers
RTE_Device.h
for USB Configuration File
65
Manage Run-Time Environment
Select USB Middleware Components
Stop the Debug session
Click on
Expand USB
Select CORE
Expand USB:Device
Set HID to 1
Click Resolve
Click OK
66
Add USB HID Template File
67
USBDUser_HID_0.c Template File (1)
It implements the application specific functionality of the HID class and is used to
receive and send data reports to the USB Host
The implementation must match the configuration file USBD_Config_HID_0.h
Add the following:
#include "LED.h"
68
USBDUser_HID_0.c Template File (2)
70
Implement the Application
71
RTOS Configuration
72
Run the Application
73
HID Client Application
C:\Keil\ARM\Utilities\HID_Client\Release\HIDClient.exe
A Windows program is available to test the functionality of the code
The HIDClient.exe utility is located in "C:\Keil\ARM\Utilities\HID_Client\Release" and
can run stand-alone without the need to install the software
To check the client utility with your board, do the following:
Download the application to your board.
Verify all jumper settings on the board.
Connect the board to a Windows PC. The PC should recognize the HID device and install the
correct driver automatically.
Run "C:\Keil\ARM\Utilities\HID_Client\Release\HIDClient.exe".
Select the Device to establish the communication channel.
Test the application by enabling the correct LEDs (here 0 and 1)
and by pressing the push-buttons on the development board
74
MDK Professional Evaluation License
The license you have received today will expire 2nd July, 2014
If you want to test the Middleware longer, please visit
https://www.keil.com/trial
You will receive a 30-Day Free Trial License for MDK Professional
75
µVision IDE Features
76
Context Sensitive F1 Help
Pressing F1 with cursor on any keyword will bring up the related help page:
77
Code Completion
78
Parameter Information
While typing, the bolded text indicates the next required parameter
79
Dynamic Syntax Checking while Typing
80
Feature Configuration
81
Collaterals on USB Stick
82
Links on USB Stick
83