Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Getting Started with Micriμm’s μC/OS-III Kernel © 2012 Renesas Electronics America Inc. All rights reserved.2 Renesas Technology & Solution Portfolio Company Logo HERE © 2012 Renesas Electronics America Inc. All rights reserved.3 Agenda Introduction Lab 1 Foreground/Background Systems Kernel-Based Applications Initiating Multitasking Lab 2 Scheduling and Context Switches Lab 3 Additional Kernel Services Lab 4 Conclusion 3 © 2012 Renesas Electronics America Inc. All rights reserved.4 Introduction 4 © 2012 Renesas Electronics America Inc. All rights reserved.5 Class Objectives Understand what services a real-time kernel provides Learn how to make use of kernel services Learn how kernels are implemented Gain experience with an actual kernel 5 © 2012 Renesas Electronics America Inc. All rights reserved.6 Labs Based on µC/OS-III Real-time kernel from Micriµm Concepts underlying the labs are not µC/OS-III-specific Step-by-step instructions are provided for each lab 6 © 2012 Renesas Electronics America Inc. All rights reserved.7 A µC/OS-III-Based Application 7 Application Code Micriµm’s Modules (Portable Code) Micriµm’s Modules (Hardware-Specific Code) Hardware © 2012 Renesas Electronics America Inc. All rights reserved.8 µC/LIBµC/CPUµC/OS-III A µC/OS-III-Based Application (Cont.) 8 Application Code µC/CPUµC/OS-III BSP Hardware © 2012 Renesas Electronics America Inc. All rights reserved.9 Directory Structure 9 Workspace files © 2012 Renesas Electronics America Inc. All rights reserved.10 e 2 Studio IDE supporting Renesas MCUs Based on Eclipse A variety of debugging features 10 [...]...Lab 1 11 © 2012 Renesas Electronics America Inc All rights reserved 11 Lab 1 Summary The kernel is built alongside application code A kernel- based application looks much like any other C program Application code interacts with the kernel through API functions 12 © 2012 Renesas Electronics America Inc All rights reserved 12 Foreground/Background Systems 13 ©... All rights reserved 14 Foreground/Background Benefits No upfront cost Minimal training required Developers don’t need to learn a kernel s API No need to set aside memory resources to accommodate a kernel There is a small amount of overhead associated with a kernel 15 © 2012 Renesas Electronics America Inc All rights reserved 15 Foreground/Background Drawbacks Difficult to ensure that each... (Cont.) Problems with multiple developers Developers’ efforts must be closely coordinated Difficult expansion, even with one developer Changes to one portion of the application may negatively impact the remainder of the code 18 © 2012 Renesas Electronics America Inc All rights reserved 18 Kernel- Based Applications 19 © 2012 Renesas Electronics America Inc All rights reserved 19 A Kernel- Based Example... Electronics America Inc All rights reserved 23 Initializing and Starting the Kernel Application code must initialize the kernel µC/OS-III is typically initialized in main() Initialization accomplished through kernel API functions 24 © 2012 Renesas Electronics America Inc All rights reserved 24 OSInit() Must be invoked before any kernel services are used Initializes data structures Creates internal... Application code creates tasks by calling kernel API functions Each task has its own stack A priority must be assigned to each task 32 © 2012 Renesas Electronics America Inc All rights reserved 32 Scheduling and Context Switches 33 © 2012 Renesas Electronics America Inc All rights reserved 33 Two Types of Multitasking Scheduling differs from kernel to kernel There are two common approaches to... interrupt; Signal USB Task; } void AppTaskUSB (void *p_arg) { while (1) { Wait for signal from ISR; USB_Packet(); } } 20 © 2012 Renesas Electronics America Inc All rights reserved 20 Kernel Basics Application is divided into tasks Kernel shares CPU amongst tasks Developer may assign importance, or priority, to each task 21 © 2012 Renesas Electronics America Inc All rights reserved 21 Template Task static... 2012 Renesas Electronics America Inc All rights reserved 25 µC/OS-III Internal Tasks Always present Optional Idle Task Statistics Task Automatically given lowest priority Tick Task Synchronized with a periodic interrupt Allows µC/OS-III to provide time delays 26 © 2012 Renesas Electronics America Inc All rights reserved Monitors resource usage ISR Handler Task Facilitates deferred interrupt... 35 © 2012 Renesas Electronics America Inc All rights reserved 35 Preemptive Scheduling Interrupt signals the availability of the highpriority task’s data ISR The high-priority task is scheduled by the kernel High-Priority Task Low-Priority Task Time 36 © 2012 Renesas Electronics America Inc All rights reserved 36 . America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Getting Started with Micriμm’s μC/ OS-III Kernel © 2012 Renesas Electronics America Inc. All rights reserved.2 Renesas. Understand what services a real-time kernel provides Learn how to make use of kernel services Learn how kernels are implemented Gain experience with an actual kernel 5 © 2012 Renesas Electronics. reserved.12 Lab 1 Summary The kernel is built alongside application code A kernel- based application looks much like any other C program Application code interacts with the kernel through API functions 12 ©