ECE 254/MTE241 Lab1 Tutorial Keil IDE and RL-RTX Last updated: 2012/09/25

Similar documents
CMPE3D02/SMD02 Embedded Systems

Lab 3a: Scheduling Tasks with uvision and RTX

Lab 3b: Scheduling Multithreaded Applications with RTX & uvision

ECE254 Lab3 Tutorial. Introduction to MCB1700 Hardware Programming. Irene Huang

Keil TM MDK-ARM Quick Start for. Holtek s HT32 Series Microcontrollers

A brief intro to MQX Lite. Real work: hands-on labs. Overview, Main features and Code Size

NXP LPC4300: Cortex -M4/M0 Hands-On Lab

EPM900 - Overview. Features. Technical Data

ECE254 Lab3 Tutorial. Introduction to Keil LPC1768 Hardware and Programmers Model. Irene Huang

Introduction to uvision and ARM Cortex M3

Migrating to Cortex-M3 Microcontrollers: an RTOS Perspective

Lab 3-2: Exploring the Heap

Project Debugging with MDK-ARM

ARM RTX Real-Time Operating System A Cortex-M Optimized RTOS that Simplifies Embedded Programming

NXP LPC4000: Cortex -M4/Cortex-M0 Lab

Cortex -M3 Hands-On LAB featuring Serial Wire Viewer

COEN-4720 Embedded Systems Design Lecture 9 Real Time Operating Systems (RTOS) Part 1: Processes/Tasks and Threads

NXP LPC4000: Cortex -M4/M0 Lab

NXP lab: Cortex-M3 Training with Serial Wire Viewer LPC1768/65: Keil MCB1700 evaluation board

AGH University of Science and Technology Cracow Department of Electronics

Getting Started in C Programming with Keil MDK-ARM Version 5

STMicroelectronics: Cortex -M4 Training STM32F407 Discovery evaluation board using ARM Keil MDK Toolkit

Tools Basics. Getting Started with Renesas Development Tools R8C/3LX Family

embos Real Time Operating System CPU & Compiler specifics for ARM core with ARM RealView Developer Suite 3.0 Document Rev. 1

Tutorial. How to use Keil µvision with Spansion templates Spansion Inc.

VORAGO VA108xx FreeRTOS port application note

Building a Salvo Application with Keil's CARM C Compiler and µvision IDE

MDK-ARM Version 5. ULINK Debug Adapters. Microcontroller Development Kit.

Getting Started in C Programming with Keil MDK-ARM Version 5

Getting Started in C Programming with Keil MDK-ARM Version 5

Evaluation board for NXP LPC2103. User Guide. Preliminary Version updated 27 th Aug TechToys Company All Rights Reserved

Freescale Kinetis L Series: Cortex-M0+ Training Using the Freedom KL25Z

Application Note 112 version 1.1 Installing a User program in EPROM on the Intel 8x930 4 Port USB Evaluation Board

Evaluation board for NXP LPC2103 USE GNU ARM UNDER KEIL IDE

STM32L100C-Discovery Board Projects

Freescale Kinetis: Cortex -M4 Training Lab

EKK-LM3S811 QUICKSTART

STMicroelectronics STM32: Cortex -M4 Lab

ARM. Architecture, Programming and Development Tools

Freescale Kinetis: Cortex -M4 Training Lab

Getting Started in Assembly Programming with Keil uvision and MSP432

Starting Embedded C Programming CM0506 Small Embedded Systems

SKP16C26 Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

RVDS 3.0 Introductory Tutorial

μez Software Quickstart Guide

Getting Started with MDK. Create Applications with µvision for ARM Cortex -M Microcontrollers

Tutorial to Import DAVE version 3 Generated Library Sources to ARM MDK Using CMSIS PACK. Version 3, July, 2015

Getting Started with Red State

Application Note: 207

RVDS 4.0 Introductory Tutorial

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

μez Software Quickstart Guide

STMicroelectronics: Cortex -M7 Training STM32 F7 Discovery evaluation board using ARM Keil MDK 5 toolkit

NEW CEIBO DEBUGGER. Menus and Commands

Micrium OS Kernel Labs

IAR EWARM Quick Start for. Holtek s HT32 Series Microcontrollers

Code::Blocks Student Manual

MDK-Professional Middleware Components. MDK-ARM Microcontroller Development Kit MDK-ARM Version 5. USB Host and Device. Middleware Pack.

Red Suite 4 Getting Started. Applies to Red Suite 4.22 or greater

Chapter 4. Enhancing ARM7 architecture by embedding RTOS

CPE 323: Laboratory Assignment #1 Getting Started with the MSP430 IAR Embedded Workbench

Changing the Embedded World TM. Module 3: Getting Started Debugging

Application Note: 200

Start a New Project with Keil MDK-ARM Version 5 and ST Micro Nucleo-F446RE

AN316 Determining the stack usage of applications

Supplement: Visual C++ Debugging

Programming the Siemens C167CR CAN Interface: A Real Life Case: Constructing the Hardware. Introduction. The Keil Tool Chain - an overview

2 TUTORIAL. Overview. VisualDSP Getting Started Guide 2-1 for SHARC DSPs

Getting Started with Keil µvision 3 and C51

M16C/62P QSK QSK62P Plus Tutorial 1. Software Development Process using HEW4

Experiment 1. Development Platform. Ahmad Khayyat, Hazem Selmi, Saleh AlSaleh

Getting Started with MCUXpresso SDK CMSIS Packs

Keil uvision development story (Adapted from (Valvano, 2014a))

HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

UM1862 User manual. Getting started with STM32F411E Discovery software Development Tools. Introduction

Installation and Quick Start of isystem s winidea Open in DAVE. Tutorial Version 1.0, May, 2014

PPC Multicore example with Cosmic Tools:

Code::Blocks Student Manual

Microsemi (Actel) SmartFusion: Cortex -M3 Lab: ARM Keil MDK toolkit featuring Serial Wire Viewer

ARM HOW-TO GUIDE Interfacing GLCD with LPC2148 ARM

embos Real-Time Operating System embos plug-in for IAR C-Spy Debugger Document: UM01025 Software Version: 3.0 Revision: 0 Date: September 18, 2017

Evaluation Board. For NXP - Philips LPC All rights reserved

LPC2300/LPC2400 TCP/IP Overview Fall of Chris Wright TCP/IP and LPC2300/LPC2400 Family October 2007

AN1369 APPLICATION NOTE

Kinetis SDK Freescale Freedom FRDM-KL03Z Platform User s Guide

Fujitsu 2010 FAE Training Lab Sunnyvale, CA

ECE2049 Embedded Computing in Engineering Design. Lab #0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

Heterogeneous multi-processing with Linux and the CMSIS-DSP library

embos Real Time Operating System CPU & Compiler specifics for Texas Instruments MSP430 CPUs and Rowley compiler for MSP430 Document Rev.

TN0132 Technical note

MODEL-BASED DEVELOPMENT -TUTORIAL

Embedded System Curriculum

embos Real Time Operating System CPU & Compiler specifics for RENESAS M16C CPUs and IAR compiler Document Rev. 5

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

MDK-ARM. Microcontroller Development Kit

5/11/2012 CMSIS-RTOS. Niall Cooling Feabhas Limited CMSIS. Cortex Microcontroller Software Interface Standard.

Component validity and internal error checking functionality to ensure reliable operation

Figure 1. Simplicity Studio

Introduction to Computation and Problem Solving

Getting Started with Red Trace

Transcription:

Objective ECE 254/MTE241 Lab1 Tutorial Keil IDE and RL-RTX Last updated: 2012/09/25 This tutorial is to introduce the Keil µvision4 IDE and Keil RL-RTX. Students will experiment with inter-process communication by using the RTX task, mailbox and time management library function calls on MCB1768 evaluation board. After this lab, students will have a good understanding of the following: How to create a µvision project. How to configure µvision for RTX How to view and control the RTX operation in debug mode How to use the Watch Window and Memory Window How to set up Hardware breakpoints and Watch points How to use the Performance Analyzer (PA) to see where the program spends its time How to use the Execution Profiling (EP) to display how many times a function has been called and the total time spent in a function. How to use the RTX Task and System Window How to use the RTX Event View window Creating Your First Hello World Application The Keil µvision4 IDE getting started guide (posted on the lab web site) is the first documentation you may want to read. The IDE online help contains MDK-ARM Primer and µvision IDE Users Guide. These two documents contain more detailed examples of how to use the IDE. To create a simple application that displays Hello World! on the LCD screen, follow the steps below: 1. Create a folder for your new project on your computer. 2. Copy all file under GLCD folder to your project folder 3. Copy system_lpc17xx.c under Startup folder to your project folder 4. Creating a New Project in µvision Project New µvision Project NXP(Founded by Philips) LPC1768 Answer Yes to copy the startup files 5. Rename Target 1 to Hello World. 6. Rename Source Group 1 to Startup Code 7. Add a new source group and name it Source Code. 8. Add all LCD C supporting files to the Source Code source group 9. Create a new main.c file (see Listing 1 to print out a string to the LCD 10. Add the main.c file to the Source Code source group 11. Build by click the Rebuild All button

12. Download by clicking the Load button 13. Press the Reset button to run the application 1 #include <LPC17xx.h> 2 #include "GLCD.h" 3 4 int main() 5 { 6 SystemInit(); // Initialize the board 7 GLCD_Init(); // Initialize the LCD 8 GLCD_Clear(Yellow); // Clear LCD screen with yellow color 9 GLCD_DisplayString(0, 0, 1, "Hello World!"); 10 // row 0, col 0, fontsize 1 11 } Listing 1: Hello World main.c Creating an RL-RTX Application The RL-RTX is one of the components of RL-ARM, the RealView Real-Time Library (RL-ARM). The RTX kernel is a real time operating system (RTOS) that enables one to create applications that simultaneously perform multiple functions or tasks (statically created processes). Tasks can be assigned execution priorities. The RTX kernel uses the execution priorities to select the next task to run (preemptive scheduling). It provides additional functions for inter-task communication, memory management and peripheral management. RTX programs are written using standard C constructs and compiled with the RealView Compiler. The RTL.h header file defines the RTX functions and macros that allow you to easily declare tasks and access all RTOS features. To create an application that uses RL-RTX library, follow the steps below: 1. Create a new project for NXP LPC1768 processor. 2. Copy the RTX_Conf_CM.c (C:\Software\Keil\ARM\Startup) to the project folder and add it to your project. 3. Open the RTX_Conf_CM.c under the Configuration Wizard and set the CPU to 100000000. You need to set the total number of tasks the system can manage. The default value is 6 and normally is sufficient. 4. Open up the Target Option window and activate the Target tab. Choose RTX Kernel as the operating system (default is set to None). Click Use MicroLIB in the code- generation window. 5. Now you can start to develop an RTX application. Start with the os_tsk_*() function reference which is within the µvision Help File. Listing 2 shows you a simple RTX application that lights up the first LED when it starts and then displays the Hello World! string on the LCD screen. Then the system creates an initialization task named init which spawns three tasks task1, task2, task3, and task4. The task1 displays digit 0-9 in a round robin fashion. The task2 makes a LED blinks every one second. The task3 keeps incrementing a global counter. The task4 keeps decrementing a global counter. We will examine the global counter under the debug mode. 1 /** 2 * @brief: A Simple RL-RTX application to blink a LED and 3 display 0-9 in a round robin fashion on LCD 4 */ 5 6 #include <LPC17xx.h>

7 #include <RTL.h> 8 #include "GLCD.h" 9 #include "LED.h" 10 11 int g_counter=0; // a global counter 12 13 /** 14 * @brief: displays 0-9 in a round robin fashion. 15 */ 16 task void task1(void) 17 { 18 int i = 0; 19 GLCD_DisplayString(3, 0, 1, "Task 1:"); 20 21 for (;; i++) { 22 GLCD_DisplayChar(3, 7, 1, i+ 0 ); 23 os_dly_wait(100); 24 if (i == 9) { 25 i = -1 ; 26 } 27 } 28 } 29 30 /** 31 * @brief: toggles LED #7 at P2.6 every second 32 */ 33 task void task2(void) 34 { 35 for (;;) { 36 LED_on(7); 37 os_dly_wait(60); 38 LED_off(7); 39 os_dly_wait(40); 40 } 41 42 } 43 44 /** 45 * @brief: A dummy task that keeps incrementing a global counter 46 */ 47 task void task3(void) 48 { 49 for (;;) { 50 g_counter++; 51 } 52 } 53 54 /** 55 * @brief: A dummy task that keeps decrementing a global counter 56 */ 57 task void task4(void) 58 {

59 for(;;) { 60 g_counter--; 61 } 62 } 63 64 /** 65 * @brief: Initialization task that spawns all other tasks. 66 */ 67 task void init (void) 68 { 69 os_tsk_create(task1, 1); // task1 at priority 1 70 os_tsk_create(task2, 1); // task2 at priority 1 71 os_tsk_create(task3, 1); // task3 at priority 1 72 os_tsk_create(task4, 1); // task4 at priority 1 73 os_tsk_delete_self(); // must delete itself before exiting 74 } 75 76 int main (void) 77 { 78 SystemInit(); // initialize the LPC17xx MCU 79 LED_init(); // initialize the LED device 80 GLCD_Init(); // initialize the LCD device 81 82 LED_on(0); // turn on LED #0 at P1.28 83 84 GLCD_Clear(Yellow); // clear LCD screen with yellow color 85 GLCD_DisplayString(0, 0, 1, "Hello World!"); 86 // display a string at row 0 col 0 with 87 // font size 1. 88 os_sys_init(init); // initilize the OS & start the first task 89 } Listing 2: A Simple RL-RTX Application main.c View and Control the RTX Operation in Debug Mode [1] Watch window Click View Watch Windows Watch 1. Highlight the variable you want to watch and drag it to the Name column in the Watch 1 window. You can also just double click or use F2 to add by typing the variable name. Memory window Click View Memory Windows Memory 1. Highlight the variable and drag it to the Address text field. Add an & before the variable name. You can also just type &variable_name directly in the text field. Right click in the memory window and pick the data type you want to be displayed in the memory window. Hardware Breakpoints You can set up breakpoints next to the C statement that you want stop at by double clicking the left side of the line numbers Watch Points (also called Access Breaks) You can stop the program when a variable reaches a user defined value.

Notes Open Debug Breakpoints (or Ctrl-B). In the Expression text field, enter variable == value ( for example x==200) and select Write. Click on Define and then Close to close the window. Run the program and it will stop when the variable reaches the value. Performance Analzyer Click View Analysis Windows Performance Analyzer to open it. It is a tool to tell you where your program is spending its time. You can only use this in the simulator with the hardware we have in the lab. Execution Profiling Click Debug Execution Profiling Show Time/Calls. It can show how much time has been spent in a function or how many times a function has been called. RTX Tasks and System Window Click Debug OS Support RTX Tasks and Systems. This window updates as the RTX runs. You can watch task switching and various system and task related information in this window. RTX Event Viewer Click Debug OS Support Event Viewer. Event Viewer provides a graphical representation of how long and when individual tasks run. The Keil IDE does not tolerate space(s) in the path name. For example, a project in a directory which contains My Documents as part of the path name sometimes will give you error saying certain files could not be created. Do remember to configure the CPU speed to 100 MHZ through the RTX_Conf_CM.c configuration wizard. Otherwise you will get wrong timing result. The default stack size is 200 bytes. Using printf family functions such as sprintf can easily cause a stack overflow. You will encounter Hard Fault exception. Stack size can be configured through the configuration wizard in RTX_Conf_CM.c file. Normally 512B would be sufficient. If you are not tight on memory, 1 KB is safer. The os_tsk_delete only put the task as INACTIVE. It does not remove the task control block (TCB) entry from the TCB table. So it still counts as a task by the system after the function call. There is an OS idel demon task which runs at the lowest priority of zero. This task is also counted as one task by the system. The simulator cannot simulate the LCD. Use the hardware debugger to debug LCD. References [1] Robert Boys. Keil RTX RTOS: The Easy Way V0.4. 2010.