Search for question
Question

This exercise is adapted from a KEIL application note (apnt_232) that walks a user through the process of installing the MDK (Microcontroller Development Kit) for the first time, configuring it, and

verifying its correct operation. THIS IS CRITICAL TO GET YOUR SOFTWARE INSTALLED PROPERLY OR YOU WILL ALWAYS HAVE PROBLEMS COMPILING AND RUNNING PROGRAMS. I marked up the original app note and highlighted in YELLOW only the parts you need to do: ESA PHW 1 rev. 4 - Keil apnt_232_v3.2.pdf. The steps are written out more clearly in the document EE505 Practical Homework 1.docx so you might want to refer to both as you follow the steps./n EE 405/505 Complete the steps highlighted in yellow. Number your screenshots and Practical Homework #1 put them into a report. Submit a PDF of the report through Blackboard. NXP Kinetis L Series: Cortex-M0+ Lab arm KEIL Using the Freedom KL25Z featuring MTB: Micro Trace Buffer Arm Keil MDK 5 Toolkit Fall 2017 vV 3.2 Robert Boys bob.boys@arm.com The latest version of this document is here: www.keil.com/appnotes/docs/apnt 232.asp Introduction: The purpose of this lab is to introduce you to the NXP Kinetis Cortex®-M0+ processor using the Arm® Keil® MDK toolkit featuring the IDE µVision®. We will demonstrate all debugging features available on this processer including Micro Trace Buffer (MTB). At the end of this tutorial, you will be able to confidently work with these processors and Keil MDK. We recommend you obtain the new Getting Started MDK 5: from here: www.keil.com/gsg. Keil MDK supports and has examples for most NXP Arm processors. Check the www.keil.com/NXP for the complete list. i.MX: For i.MX support see DS-MDK. www.keil.com/ds-mdk Also: www.arm.com/ds5. Keil MDK-Lite™ is a free evaluation version that limits code size to 32 Kbytes. Nearly all Keil examples will compile within this 32K limit. The addition of a valid license number will turn it into a commercial version. Why Use Keil MDK ? MDK provides these features particularly suited for NXP Cortex-M users: 1. μVision IDE with Integrated Debugger, Flash programmer and the Arm® Compiler toolchain. MDK is turn-key "out-of-the-box". Arm Compiler 5 and Arm Compiler 6 (LLVM) are include Compiler Safety Certification Kit: www.keil.com/safety/ 4. TÜV certified. SIL3 (IEC 61508) and ASILD (ISO 26262). 3. 5. Dynamic Syntax checking on C/C++ source lines. 6. MISRA C/C++ support using PC-Lint. www.gimpel.com 7. Keil Middleware: Network, USB, Flash File, Graphics and CAN for many NXP processors. Contact Keil Sales for assistance. 8. Event Recorder for Middleware, RTX and User programs. 9. RTX is included. RTX has a BSD or Apache 2.0 license with source code. FreeRTOS is now supported. www.keil.com/RTX and https://github.com/ARM-software/CMSIS 5 BS8 NXP Cortex-M0+ Lab with ARMⓇ KeilTM MDK 5 toolkit D 1 12 CI ACCEL PROM 07372 c201 86 187 ORY FROM-KL252 66666 90000 225 12oooooooooºo 00000000 10. Not on KL25: CoreSight™ Serial Wire Viewer (SWV). ETM instruction trace capability on appropriately equipped NXP processors. Provides Instruction Debugging, Code Coverage and Performance Analysis. 11. Debug Adapters: OpenSDA (CMSIS-DAP or P&E mode), Keil ULINK™2, ULINK-ME, ULINKpro and J-Link. 12. Affordable perpetual and term licensing with support. Contact Keil sales for pricing options. Inside-Sales@arm.com 13. Keil Technical Support is included for one year and is renewable. This helps you get your project completed faster. 14. ULINKplus power analysis: www.keil.com/mdk5/ulink/ulinkplus/ Available Nov 2018. Contact Keil sales. 15. Micrium µC/Probe compatible. www.micrium.com/ucprobe Displays/changes variables in graphical formats. This document includes details on these features plus more: The Freedom KL25Z board connected to run OpenSDA (CMSIS-DAP) and MDK. 1. Micro Trace Buffer (MTB). Instruction trace. A history where your program has been: the executed instructions. 2. Real-time Read and Write to memory locations for the Watch, Memory and peripheral windows. These are non- intrusive to your program. No CPU cycles are stolen. No instrumentation code is added to your source files. 3. Two Hardware Breakpoints (can be set/unset on-the-fly) and two Watchpoints (also known as Access Breaks). 4. RTX System & Threads window: a kernel awareness program for RTX that updates while your program is running. 5. A DSP example program using Arm CMSIS-DSP libraries. 6. How to create your own µVision projects and an extensive list of document resources available. Micro Trace Buffer (MTB): MDK supports MTB with OpenSDA (in CMSIS-DAP mode), ULINK2/ME or ULINKpro. MTB provides instruction trace which is essential for solving program flow and other related problems. How to use MTB is described in this document. Copyright © 2017 Arm Ltd. All rights reserved 1/25/2024 www.keil.com General Information: 1. NXP Evaluation Boards & Keil Evaluation Software: 2. MDK 5 Keil Software Download and Installation: 3. OpenSDA: An NXP Debug Adapter 4. Install Keil MDK Software: 5. Install Software Packs and Examples: Using the OpenSDA CMSIS-DAP Debug Adapter: 6. Programming the KL25Z Board with OpenSDA (CMSIS-DAP) 7. Testing the OpenSDA Installation: Blinky Example and Debugging Features: 8. Blinky example using the Freedom KL25Z and OpenSDA: 9. Hardware Breakpoints: 10. Call Stack & Locals window: 11. Watch and Memory windows and how to use them: 12. System Viewer (SV): 13. Watchpoints: Conditional Breakpoints: 14. RTX Kernel Awareness with System and Threads Viewer: MTB: Micro Trace Buffer with Blinky: 15. MTB: Micro Trace Buffer: 16. Cod Coverage: 17. Exploring the MTB Instruction Trace: 18. Trace Buffer Configuration and Control: 19. Trace Search: 20. Trace Data Wrap Around: 21. More MTB Exploration: 22. Trace "In the Weeds" Example: DSP Sine Example: 23. DSP Sine using Arm CMSIS-DSP Libraries: Creating Your Own MDK Project With and Without RTOS: 24. Creating Your Own MDK 5 Project from Scratch: 25. Adding RTX: 26. Adding a Thread: 27. Event Recorder General Information: 28. Interesting Bits & Pieces: 29. Kinetis KL25 Trace Summary: 30. CoreSight Definitions: 31. Document Resources: 32. Keil Products and Contact Information: NXP Cortex-M0+ Lab with ARMⓇ KeilTM MDK 5 toolkit 2 3 3 3 4 5 6 6 7 8 9 10 11 12 13 14 15 16 16 17 18 19 20 23 24 25 26 27 28 29 30 Copyright © 2017 Arm Ltd. All rights reserved www.keil.com 1) NXP Evaluation Boards & Keil Evaluation Software: Keil provides board support for Kinetis Cortex-M0+ and Cortex-M4 processors. They include Tower K20, K40, K53, K60, K70 and KL25Z (both Tower and Freedom boards), S32K and many more. See www.keil.com/NXP for the complete list. This lab was written using a KL25Z Freedom board with OpenSDA in CMSIS-DAP mode. This lab will also work for the TWR-KL28Z72M board. It has a slightly different example program. For the i.MX series see www.keil.com/mdk5/ds-mdk/ On the last page of this document is an extensive list of resources that will help you successfully create your projects. This list includes application notes, books and labs and tutorials for other NXP boards. We recommend you obtain the latest Getting Started Guide for MDK5: It is available on www.keil.com/gsg/. Arm forums: https://developer.arm.com Keil Forums: www.keil.com/forum/ (2) MDK 5 Keil Software Information: This document used MDK 5.39 MDK 5 Core is the heart of the MDK toolchain. This initially will be in the form of MDK Lite which is the evaluation version. The addition of a Keil license will turn it into one of the commercial versions. Contact Keil Sales for more information. Device and board support are distributed via Software Packs. These Packs are downloaded from the web with the "Pack Installer", the version(s) selected with "Select Software Packs" and your project configured with the "Run Time Environment" (RTE) utilities. These are components of µVision. You can distribute and install your own Pack for confidentiality. A Software Pack is an ordinary .zip file with the extension changed to .pack. It contains various header, Flash programming and example files and more. Contents of a Pack is described by a .pdsc file in XML format. See www.keil.com/dd2/pack for the current list of available Software Packs. More Packs are being added. Example Project Files: This document uses the RTX5_Blinky example project contained in the S32K Software Pack. (3) OpenSDA: OpenSDA is NXP's on-board debug adapter used extensively in the Kinetis and other families. It has a P&E and a CMSIS-DAP mode. CMSIS-DAP is an Arm standard. This lab will use the KL25Z board in CMSIS-DAP mode. LPC-Link2 is also CMSIS-DAP compliant. LPC-Link2 has a J-Link mode which is also supported by µVision. You are able to incorporate CMSIS-DAP debugger on your own board. See https://github.com/ARM-software/CMSIS 5. You do not need an external debugger such as a ULINK2 to do this lab. If you use an external debugger, you must populate SWD J6 connector with a 10 pin CoreSight connector made by Samtec or equivalent FTSH-105-01-L-D-K. 4) Install Keil MDK Software: 1. Download MDK 5.38a from my Google Drive 2. Install MDK into the default folder. You can install into any folder, but this lab uses the default C:\Keil_v5 3. We recommend you use the default folders for this tutorial. We will use C:\00MDK\ for the examples. 4. If you install MDK into a different folder, you will have to adjust for the folder location differences. 5. You do not need an external debug adapter: just the KL25Z board, a USB cable and MDK installed on your PC. 6. You do not need a Keil MDK license for this tutorial. All examples will compile within the 32 K limit. NXP Cortex-M0+ Lab with ARMⓇ KeilTM MDK 5 toolkit 3 Download MDK Coro Version 5 Copyright © 2017 Arm Ltd. All rights reserved www.keil.com (5) Install µVision Software Packs and Examples: (1) Start µVision and open Pack Installer: 1. Connect your computer to the internet. This is needed to download the Software Packs. 2. Start µVision by clicking on its desktop icon. 3. Open the Pack Installer by clicking on its icon: This window opens up: Select the Packs tab: Note "ONLINE” is displayed at the bottom right. If "OFFLINE” is displayed, connect to the Internet before continuing. 4. 5. 6. If there are no entries shown because you were not connected to the Internet when Pack Installer opened, select Packs/Check for to refresh once you have Updates or connected to the Internet. Pack Installer - C:\Keil_v5\ARM\PACK File Packs Window Help 4 2 Board: FRDM-KL25Z (Rev. B) Devices Boards Search kl25 Board Output A Pack Installer Welcome screen will open. Read and close it. Ready NXP Cortex-M0+ Lab with ARMⓇ KeilTM MDK 5 toolkit Boards FRDM-KL25Z (Rev. B) TWR-KL28Z72M (Rev. A) Compatible Devices KL2x - X Summary 18 Devices MKL252128xxx4 MKL287512xxx7 3 Devices 3 Devices ▷ 4 Packs Examples Pack E-Device Specific +-Keil::Kinetis_KLxx_DFP 4) Install the RTX5_Blinky and DSP5 Examples from Keil.com: Skip this step, as the PHW1-code.zip provides the code. 4 Install 10 Packs Up to date +-ARM::CMSIS-Driver_Vali... Install -ARM::CMSIS-FreeRTOS Up to date +-ARM::CMSIS-RTOS_Valid... Install Generic +-ARM::CMSIS Action 1 Pack (2) Install The KL25 Software Pack: 1. Go to my Google Drive and download the file Keil.Kinetis_KLxx_DFP.1.15.0.pack 2. Use Pack Installer program to import that file using the File->Import... commands. 3. On the left pane, select "Boards" and All Boards->FRDM-KL25Z. Pack Installer - C:\Keil_v5\ARM\PACK File Packs Window Help Description FRDM-KL25Z selected NXP Kinetis KLXX Series Device Support a CMSIS (Cortex Microcontroller Software I CMSIS-Driver Validation Bundle of FreeRTOS for Cortex-M and Co CMSIS-RTOS Validation DOX 3) Install the RTX_Blinky Example: Use the code from Blackboard Homework > PHW #1 > PHW1-code.zip and unzip in the folder C:\00MDK\ You should see two projects there, Blinky and Blinky_BM. Copyright © 2017 Arm Ltd. All rights reserved www.keil.com ONLINE CMSIS Pack MKL25Z128xxx4 Tame Kinetis_KLxx_DFP Download Recommended Pack 1 kl25 ▷ plinkos -OX 6) Programming the KL25Z with OpenSDA: an on-board Debug Adapter: This document will use OpenSDA as a SWD Debug Adapter. Target connection by µVision will be via a standard USB cable connected to SDA J7. The on-board Kinetis K20 acts as the debug adapter. Micro Trace Buffer frames can be displayed. This Step MUST be done ! at least once... Program the K20 with the CMSIS-DAP application file CMSIS-DAP.S19: 1) Locate the file CMSIS-DAP.S19: 1. CMSIS-DAP.S19 is located in the OpenSDA directory in MDK KL25 projects. Using Windows Explorer navigate to Blinky_BM\OpenSDA or Blinky\OpenSDA. CMSIS-DAP.S19 is located here. The other projects also contain this file. You will copy this file into the Freedom board USB device as described below. 2) Put the Freedom Board into Bootloader: Mode: 2. Hold RESET button SW1 on the Freedom board down and connect a USB cable to J7 SDA as shown here: When you hear the USB dual-tone, release RESET. 3. 4. The green led D4 will blink about once per second. The Freedom is now ready to be programmed with the CMSIS-DAP application. 5. The Freedom will act as a USB mass storage device called BOOTLOADER connected to your PC. Open this USB device with Windows Explorer. 3) Copy CMSIS-DAP.S19 into the Freedom Board: 6. Copy and paste or drag and drop CMSIS-DAP.S19 into this Bootloader USB device. 4) Exit Bootloader Mode: 7. Cycle the power to the Freedom board while not holding RESET button down. The green led will blink once and then stay off. 8. The Freedom board is now ready to be used with the µVision debugger and Flash programmer. TIP: The green led will indicate when µVision is in Debug mode and connected to the OpenSDA debug port SWD. Remember, JTAG is not used. The Kinetis Cortex-M0+ has only the SWD port. You can do everything with the SWD port as you can with a JTAG port. SWD is referenced as SW in the µVision configuration menu. 7) Testing The OpenSDA Connection: (Optional Exercise) 1. Start µVisions if it is not already running. Select Project/Open Project. 2. Select the Blinky or Blinky_BM project. 3. Select "CMSIS-DAP" in the Select Target menu. If you do not have this entry – select anything. CMSIS-DAP TIP: This application will remain in the U6 K20 Flash each time the board power is cycled with RESET off. The next time board is powered with RESET held on, it will be erased. CMSIS-DAP.S19 is the CMSIS DAP application in the Motorola S record format that loads and runs on the K20 OpenSDA processor. TIP: To refresh the SW Device box, in the Port: box select JTAG and then select SW again. You can also exit then re-enter this window. CMSIS-DAP will not work with JTAG selected, only SW. But this is a useful way to refresh the SW setting. 4. Select Target Options or ALT-F7 and select the Debug tab: 5. Select CMSIS-DAP Debugger as shown here: 6. Click on Settings: and the window below opens up: If an IDCODE and Device name is displayed, OpenSDA is working. You can continue with the tutorial. Click on OK twice to return to the µVision main menu. 7. If nothing or an error is displayed in this SW Device box, this must be corrected before you can continue. TIP: You can use this test to confirm the operation of any debug adapter selected in the Debug tab as shown above right. Cortex-M Target Driver Setup Debug Flash Download -CMSIS-DAP - JTAG/SW Adapter- OpenSDA CMSIS-DAP Serial No: A000000001 Firmware Version: 1.0 NXP Cortex-M0+ Lab with ARMⓇ KeilTM MDK 5 toolkit 5 Linker Debug Utilities SWJ Port: SW Max Clock: 1MHz Use: CMSIS-DAP Debugger -SW Device IDCODE SWDIO Ox0BC11477 Automatic Detection Manual Configuration 1 Date Settings 390 Device Name ARM Core Sight SW-DP GRY ID CODE: Device Name: Copyright © 2017 Arm Ltd. All rights reserved www.keil.com X Screenshot #1 must show IDCODE AD.

Fig: 1