10
Freescale Semiconductor © 2014 Freescale Semiconductor, Inc. All rights reserved. 1 Purpose This Sample Code Guide will familiarize you with the TWR-KV10Z32 board and development tools. You will learn the features of the TWR-KV10Z32 board, the features of the OpenSDA standard, and how to access the source code examples using MDK-ARM version 5.0.1 or newer. In addition, instructions are provided to download a precompiled binary file to your board. 2 Getting to know the board The Tower board (TWR-KV10Z32) features the Kinetis MKV10Z32VLF7 microcontroller and comes with the following features (which are highlighted in the figure below): 48-LQFP MKV10Z32 MCU (75MHz ARM Cortex-M0+ CPU, 32KB Flash, 8KB RAM, 3 Flextimers, 2x16-bit ADCs (conversion time > 800nS), PDB, 12-bit DAC, ACMP with 6-bit DAC, etc.) On board OpenSDA with USB connection used to debug code without external debug interface Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 Contents 1. Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2. Getting to know the board . . . . . . . . . . . . . . . . . . . . . 1 3. OpenSDA Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 3 4. Download and Install Software and Tools . . . . . . . . . 3 5. Freescale Sample Code . . . . . . . . . . . . . . . . . . . . . . . . 4 6. Configure Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . 7 7. Terminal Program Configuration . . . . . . . . . . . . . . . . 7 8. Loading and Running the Demos into MDK-ARM 5.0.1 7 9. Flashing the Pre-compiled Binary onto your Board . . 8 TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARM Board configuration, software, and development tools by Freescale Semiconductor, Inc.

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

Embed Size (px)

Citation preview

Page 1: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

Freescale Semiconductor

© 2014 Freescale Semiconductor, Inc. All rights reserved.

1 PurposeThis Sample Code Guide will familiarize you with the TWR-KV10Z32 board and development tools. You will learn the features of the TWR-KV10Z32 board, the features of the OpenSDA standard, and how to access the source code examples using MDK-ARM version 5.0.1 or newer. In addition, instructions are provided to download a precompiled binary file to your board.

2 Getting to know the boardThe Tower board (TWR-KV10Z32) features the Kinetis MKV10Z32VLF7 microcontroller and comes with the following features (which are highlighted in the figure below):

• 48-LQFP MKV10Z32 MCU (75MHz ARM Cortex-M0+ CPU, 32KB Flash, 8KB RAM, 3 Flextimers, 2x16-bit ADCs (conversion time > 800nS), PDB, 12-bit DAC, ACMP with 6-bit DAC, etc.)

• On board OpenSDA with USB connection used to debug code without external debug interface

Doc Num: TWRKV10Z32KEILUGRev. 0.1, 01/2014

Contents1. Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12. Getting to know the board . . . . . . . . . . . . . . . . . . . . . 13. OpenSDA Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 34. Download and Install Software and Tools . . . . . . . . . 35. Freescale Sample Code . . . . . . . . . . . . . . . . . . . . . . . . 46. Configure Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . 77. Terminal Program Configuration . . . . . . . . . . . . . . . . 78. Loading and Running the Demos into MDK-ARM 5.0.1

79. Flashing the Pre-compiled Binary onto your Board . . 8

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMBoard configuration, software, and development toolsby Freescale Semiconductor, Inc.

Page 2: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARM, Rev. 0.1

2 Freescale Semiconductor

Getting to know the board

• Header for standard mini Cortex SWD connector used to debug code on either OpenSDA or KV10Z32 with external debug interface

• Power indication LED• 10MHz crystal on board for the microcontroller• MMA8451Q Accelerometer connected to I2C channel• 8 LEDs connected with buffers to PWM channels for dimming• 2 Push buttons for user input or interrupts to the microcontroller• 4 Thermistors for single ended or differential analog inputs• Reset push button for MKV10• Elevator signal supporting TWR-MCLV3PH• Header to connect to APMOTOR56F800E motor board and TWR-MCLV3PH motor Tower board

Page 3: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARM, Rev. 0.1

Freescale Semiconductor 3

OpenSDA Overview

3 OpenSDA OverviewOpenSDA is an open-standard serial and debug adapter. It bridges serial and debug communications between a USB host and an embedded target processor. OpenSDA features a mass storage device bootloader that offers a quick and easy mechanism for loading applications such as flash programmers, run-control debug interfaces, serial-to-USB converters, and more, onto your Tower or Freedom board. Currently, P&E Micro offers two different applications: an MSD application and a debug application.

3.1 MSD ApplicationThis OpenSDA application was developed by P&E Micro and allows the Tower or Freedom board to instantiate as a mass storage device on your computer. Once this application properly enumerates, you may program the KV10Z32 on your board with a binary or SREC file by simply dragging and dropping one of these files into TWR-KV10Z32 drive that is installed when your board enumerated. In addition, you will have serial communication with the KV10Z32.

3.2 Debug ApplicationThis OpenSDA application was also developed by P&E Micro and allows you to program and debug your KV10Z32 on your tower board just as any other debugger module would allow. With this applica-tion loaded onto your tower board, you will also have serial communication with the KV10Z32 available.

4 Download and Install Software and Tools

4.1 Downloading and Installing OpenSDA DriversBefore you begin, you will need the latest OpenSDA serial drivers installed on your development computer and on your TWR-KV10Z32. The latest OpenSDA drivers should already be installed, and your computer system should be able to automatically find the latest Windows CDC drivers (as they should be pre-installed on the TWR-KV10Z32 board). If they are not, navigate to www.pemicro.com/opensda/index.cfm and follow the directions on this page to download the correct OpenSDA files. You may also refer to the OpenSDA user’s guide which can be found in your Quick Start Package.

4.2 Downloading and Installing MDK-ARM 5.0.1

4.2.1 Downloading and Installing the KEIL MDK-ARM 5.0.1To download the MDK-ARM v5 (or latest version), follow these instructions:

1. Open https://www.keil.com/download/product/ and download MDK-ARM v5 from this page.2. Follow ARM’s downloading and licensing instructions.3. To install software tools, follow the installer package instructions once you receive your

download.

Page 4: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARM, Rev. 0.1

4 Freescale Semiconductor

Freescale Sample Code

4.2.2 Downloading and Installing the OpenSDA patch for KEIL MDKTo download and install the OpenSDA patch for the KEIL MDK-ARM 5.0.1, follow these instructions:

1. Navigate to the Freescale Kinetis OSJTAG Drivers V1.16 download page at http://www.keil.com/download/docs/408.asp.

2. At the Freescale Kinetis OSJTAG Drivers V1.16 download page, click on the FSLKINETISDRIVERSV116.EXE link and follow the on screen instructions to save the file to your computer.

3. Next, navigate to the location at which your file is saved and double-click the executable. Then follow the on-screen instructions to install these files.

5 Freescale Sample CodeThe Freescale sample code provided for KV10Z32 is a baremetal code with most key peripheral drivers.

5.1 Baremetal Sample Code (kvxx_drv_lib)

5.1.1 Baremetal Sample Code Folder StructureThe Baremetal sample code folder contains three folders at the top level: a build folder, a src (source) folder and CMSIS library folder.

Page 5: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARM, Rev. 0.1

Freescale Semiconductor 5

Freescale Sample Code

The source folder structure is as follows:

Page 6: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARM, Rev. 0.1

6 Freescale Semiconductor

Freescale Sample Code

5.1.2 Using the Freescale Baremetal Sample Code to Jumpstart your Design

The KV10Z32 sample code is provided as a jump start for your design, and contains code examples. We have provided a script that will copy our platinum project and rename it to your desired project name. This script is a single executable, make_new_project_kv10.exe that resides in the \build\keil\kv10 folder.

Double-click this file and a command prompt pop-up window will prompt you for a project name. Copy the platinum project and rename all of the necessary files for your new project to work correctly.

Page 7: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARM, Rev. 0.1

Freescale Semiconductor 7

Configure Hardware

6 Configure Hardware1. Using a Mini-B to A USB cable, connect your TWR-KV10Z32 board to your computer. Be sure

to plug the Mini-B connection into the OpenSDA port of the TWR-KV10Z32 board. 2. No special hardware configuration is necessary to run the demo applications in the code examples

unless otherwise specified by the readme.txt file located in the project source folder.

7 Terminal Program ConfigurationThe OpenSDA serial port is designed to enumerate just as any other USB to serial converter. Therefore, you will need to open a serial terminal utility (Tera Term, Hyperterm, etc.,) and configure your terminal as follows:

• 115200 baud • 8 data bits• 1 stop bit• no parity• no flow control

8 Loading and Running the Demos into MDK-ARM 5.0.1The following instructions describe how to build and flash the helloworld demo using KEIL 5.0.1. This document is targeted for users who choose to use the OpenSDA programming and debugging capabilities and it is assumed that you have loaded the P&E Micro Debug application onto your TWR-KV10Z32. If you need assistance in loading this application onto your TWR-KV10Z32, see the OpenSDA user’s guide provided in your Quick Start Package.

1. Double click the project at ..\ kvxx_drv_lib\build\keil\platinum\ platinum.uvproj This can be done by either dragging the platinum.uvproj icon into the KEIL Workspace or by selecting Project->Open Project and pointing KEIL to the project path through the dialog box that pops up.

2. Compile the project by clicking the Build icon or the Rebuild icon (or right clicking on the project and select Build or Rebuild).

3. After compilation completes, download the code to the board and start the debugger by pressing the Start/Stop Debug Session button.

4. The code will download, and the debugger screen will come up and pause at the first instruction. Hit the Run button to start running.

5. On the terminal you should see the following message:

Page 8: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARM, Rev. 0.1

8 Freescale Semiconductor

Flashing the Pre-compiled Binary onto your Board

6. Enter any character which will be echoed to the terminal.

9 Flashing the Pre-compiled Binary onto your BoardYour TWR-KV10Z32 board should come with the OpenSDA MSD application preprogrammed onto the K20 device. If this is the case, you should see the board enumerated as a USB mass storage device and the following icon should be present in your My Computer window as shown.

If the TWR-KV10Z32 icon is not available, see the OpenSDA User’s Guide to program the MSD application onto your board. Otherwise, follow these steps to load a pre-compiled binary onto your KV10Z32:

1. Navigate to the TWR-KV10Z32 drive in your file system (or you may double-click the TWR-KV10Z32 icon in the screen displayed above).

2. You should see the following files.

Page 9: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARM, Rev. 0.1

Freescale Semiconductor 9

Flashing the Pre-compiled Binary onto your Board

If you do not, reprogram your board with the MSD application. Otherwise, open a second explorer window and navigate to the location where your pre-compiled binary application is stored (…\build\binaries).

3. Drag and drop one of .srec files into the TWR-KV10Z32 drive and the KV10Z32 will be automatically programmed with the pre-compiled binary.

 

Page 10: TWR-KV10Z32 Sample Code Guide for KEIL MDK-ARMcache.freescale.com/files/soft_dev_tools/doc/user_guide... · Doc Num: TWRKV10Z32KEILUG Rev. 0.1, 01/2014 ... TWR-KV10Z32 Sample Code

Document Number: TWRKV10Z32KEILUGRev. 0.101/2014

Information in this document is provided solely to enable system and software

implementers to use Freescale products. There are no express or implied copyright

licenses granted hereunder to design or fabricate any integrated circuits based on the

information in this document.

Freescale reserves the right to make changes without further notice to any products

herein. Freescale makes no warranty, representation, or guarantee regarding the

suitability of its products for any particular purpose, nor does Freescale assume any

liability arising out of the application or use of any product or circuit, and specifically

disclaims any and all liability, including without limitation consequential or incidental

damages. “Typical” parameters that may be provided in Freescale data sheets and/or

specifications can and do vary in different applications, and actual performance may

vary over time. All operating parameters, including “typicals,” must be validated for

each customer application by customer’s technical experts. Freescale does not convey

any license under its patent rights nor the rights of others. Freescale sells products

pursuant to standard terms and conditions of sale, which can be found at the following

address: freescale.com/SalesTermsandConditions.

How to Reach Us:Home Page: freescale.com

Web Support: freescale.com/support

Freescale, the Freescale logo, and Kinetis are trademarks of Freescale

Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. Tower is a trademark of Freescale

Semiconductor, Inc. All other product or service names are the property of their

respective owners. ARM and Cortex are the registered trademarks of ARM Limited.

© 2014 Freescale Semiconductor, Inc.