Upload
tatyana-sutherby
View
225
Download
5
Tags:
Embed Size (px)
Citation preview
1
Stellaris® Robotic Evaluation Board and Micriµm µC/OS-III
Dexter Travis, Stellaris ARM® Cortex™-M3 Applications Engineering
Jean J. Labrosse, Founder, President and CEO of Micriµm
Introductions
•Jean J. Labrosse –Founder, President and CEO of Micriµm
•Dexter Travis–Stellaris® ARM® Cortex™-M3 Applications Engineering
2
Find the right ARM® Solution for you
32-bit ARMCortex™-M3
MCUs
DSPDSP+ARM
ARM Cortex-A8 &
ARM9™ MPUs
Stellaris®
ARM Cortex-M3
Sitara™
ARM Cortex-A8& ARM9
C6000™
DaVinci™
Digital Media processors
Integra™
Up to 80 MHz
Flash8 KB to 256 KB
USB, ENET MAC+PHY CAN, ADC, PWM, SPI
Connectivity,Security,Motion Control, HMI,Industrial Automation
$1.00 to $8.00
32-bit ARM MCU for
Safety-Critical Applications
TMS570ARM
Cortex-R4™
Up to 250 DMIPS/ 160 MHz
2 MB Flash, 160 KB RAM
FPU, ECC, Timer/PWM Co-Proc, 12bit ADCs, CAN,
EMIF, LIN, SPI, Flexray
Transportation, Motor Control, Certified for use in safety critical (SIL3) systems
$7.00 to $18.00
375MHz to >1GHz
Cache, RAM, ROM
USB, CAN, SATA,SPI, PCIe, EMAC
Industrial automation, POS & portable
data terminals
$5.00 to $25.00
300MHz to >1Ghz +Accelerator
Cache RAM, ROM
USB, ENET, PCIe, SATA, SPI
Floating/Fixed PointVideo, Audio, Voice,
Security, Conferencing $5.00 to $200.00
Comprehensive developer ecosystemS
oftw
are
supp
ort
Developm
ent tools
Responsive design support
Agenda
• RTOSs and Real-Time Kernels– A brief introduction
• Micriµm - µC/OS-III– Summary of features
– Scheduling and Context Switching
– Synchronization
– Message Passing
– Other Services
• Texas Instruments - EVALBOT– Features
– Examples
– Demo
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
Displaywith optional
Touch Interface
DisplayController
Touch ScreenController
GraphicalUser
Interface
FileSystem
MediaController
Media(SD)
(MMC)(NAND Flash)(NOR Flash)
(CF)(RAM Disk)
Other
AudioI2S
Controller
KeyboardKeyboardController
CPU
Timer
InterruptController
Real-TimeKernel
EthernetController(MAC/PHY)
TCP/IPStack
USB(Host)
(Device)
USBStacks
CANController
CAN
RS-232CRS-485
Modbus
Other(Shell)(Clk)
(CRC)(etc.)
TCP/IPApps
Application
RTOS
RTOS vs Real-Time KernelsRTOS vs Real-Time Kernels
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
What is a Real-Time Kernel?What is a Real-Time Kernel?
Software that manages the time of a CPU Performs multitasking
– ‘Switches’ the CPU between tasks– Highest priority task runs on the CPU– Round-robins tasks of equal priority
Provides valuable services to an application:– Task management– Synchronization– Mutual exclusion management– Message passing– Memory management– Time management– Soft-timer management– Other
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
What is a Real-Time Kernel?What is a Real-Time Kernel?
Task
Event Event
Each Task
Infinite Loop
Task
High Priority Task
Low Priority Task
Task
Task
Task
Task
Task
Importance Task Task
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
ISR
Low-priority task
High-priority task
ISR
Preemptive KernelsPreemptive Kernels
Interrupt occurs
ISR completes and the kernel switches to the high-priority task
© 2009, Micriµm, All Rights Reserved www.Micrium.com
Via a kernel call, the ISR makes the high priority task ready
The kernel switches to the low-priority task
Time
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
What is µC/OS-III?What is µC/OS-III?
A third generation Real-Time Kernel– Has roots in µC/OS-II, the world’s most popular Real-Time Kernel
µC/OS-II’s internals were described in the book: “MicroC/OS-II, The Real-Time Kernel” (1998)
A new 850+ page book:– “µC/OS-III, The Real-Time Kernel”– Describes µC/OS-III’s internals– The book comes with:
A Cortex-M3 based evaluation board– Featuring TI’s LM3S9B92
Links to download:– Sample code to run µC/OS-III– IAR’s 32K KickStart tools– A trial version of µC/Probe
– Companion EVALBOT 5 Example projects
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
µC/OS-IIISummary of Key FeaturesµC/OS-IIISummary of Key Features
Preemptive Multitasking– Round-robin scheduling of equal-priority tasks
ROMable Scalable
– Adjustable footprint
– Compile-time and run-time configurable
Portable– All µC/OS-II ports can be adapted to µC/OS-III
Rich set of services– Task Management, Time Management, Semaphores, Mutexes, Message
Queues, Soft Timers, Memory Management, Event Flags and more
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
µC/OS-IIISummary of Key FeaturesµC/OS-IIISummary of Key Features
Real-Time, Deterministic– Reduced interrupt and task latency
Built-in Performance Measurement– Measures interrupt disable time on a per-task basis
– Measures stack usage for each task
– Keeps track of the number of context switches for each task
– Measures the ISR-to-Task and Task-to-Task response time
– And more
Cleanest source code in the industry Consistent API Run-Time argument checking
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
void MyTask (void *p_arg){ Do something with ‘argument’ p_arg; Task initialization; for (;;) { Wait for event; /* Time to expire ... */ /* Signal/Msg from ISR ... */ /* Signal/Msg from task ... */ /* Processing (Your Code) */ }}
Typical µC/OS-III TasksTypical µC/OS-III Tasks
Task(Priority)
Stack(RAM)
CPURegisters
VariablesArrays
Structures
I/ODevices
(Optional)
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
You create a task by calling a service provided by the kernel:
OSTaskCreate(OS_TCB *p_tcb, CPU_CHAR *p_name, OS_TASK_PTR p_task, void *p_arg, OS_PRIO prio, CPU_STK *p_stk_base, CPU_STK *p_stk_limit, OS_STK_SIZE stk_size, OS_MSG_QTY q_size, OS_TICK time_slice, void *p_ext, OS_OPT opt, OS_ERR *p_err);
‘Creating’ a Task‘Creating’ a Task
Task Control Block
Task Name
Task Start Address
Priority
Stack
Stack Size
Stack Limit
Time Slice
Options
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
The µC/OS-III Scheduler Using Count Leading Zeros (CLZ)The µC/OS-III Scheduler Using Count Leading Zeros (CLZ)
The Cortex-M3 has a CLZ instruction– Makes scheduling much faster … ex. with 64 priorities
0 0 0 0 0 0 00 0 0 0 0 0 0 00
310
0 0 0 0 1 1 00 1 1 1 0 1 1 11
[0]
[1]
32
5
Ready Priority = 37
32 63
if (ReadyTbl[0] == 0) Prio = CLZ(ReadyTbl[1]) + 32;else Prio = CLZ(ReadyTbl[0]);
#Zeros
ReadyTbl[]
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
The µC/OS-III Ready ListThe µC/OS-III Ready List
EntriesTail
Head
ReadyList[MAX_PRIO]
1Tail
Head
EntriesTail
Head
EntriesTail
Head
EntriesTail
Head
EntriesTail
Head
EntriesTail
Head
[MAX_PRIO-1]
[4]
[3]
[2]
[1]
[0]
[5]
Prev Next
- Other Fields -
Prev Next
- Other Fields -
Prev Next
- Other Fields -
Prev Next
- Other Fields -
0
0
00
0
0
00
00
00
00
Idle Task's TCB
TCBTCB
TCB
Highest Priority
Lowest Priority
Multiple TasksAt
Same Priority
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
Context SwitchARM Cortex-M3 for µC/OS-IIIContext SwitchARM Cortex-M3 for µC/OS-III
(1): Current task’s CPU registers are saved on current task’s stack
(2): CPU’s SP register is saved in current task’s TCB
(3): New task’s SP is restored from the new task’s TCB
(4): CPU registers are restored from the new task’s stack
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
Resource Management(Mutual Exclusion Semaphore)Resource Management(Mutual Exclusion Semaphore)
Delta TS
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
Synchronization(Semaphores)Synchronization(Semaphores)
Delta TS
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
Synchronization(Event Flags)Synchronization(Event Flags)
Delta TS
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
Message Passing(Message Queues)Message Passing(Message Queues)
Delta TS
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
Other µC/OS-III FeaturesOther µC/OS-III Features
Task Management– Suspend/Resume a task
– Delete a task
Time Management
Software Timers
Fixed-Size Memory Partitions
Pending on Multiple Objects
And more.
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
µC/Probe
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
What is µC/Probe?What is µC/Probe?
‘Windows’ application to display/change target data:– ANY variable– ANY memory location– ANY I/O port
Works with ANY processor– 8-, 16-, 32-, 64-bit or DSP
Works with ANY compiler– Compiler/linker needs to generate an ELF/DWARF file such as Embedded
Workbench Supports many interfaces
– RS-232C– USB– TCP/IP (Ethernet)– J-Link– SWD (Cortex-M3) … NO target resident coded needed!– Others
Target doesn’t need an RTOS– Works with or without an RTOS
© 2010, Micriµm, All Rights Reserved© 2010, Micriµm, All Rights Reserved www.Micrium.comwww.Micrium.com
µC/ProbeµC/OS-III Task AwarenessµC/ProbeµC/OS-III Task Awareness
Task Name
Task Priority
% CPUUsage
Max Interrupt Disable Time
Stack Usage
ISR to TaskResponse
ISR to TaskResponse
#ContextSwitches
To run the book examples … you will need:
• The µC/OS-III book
• The TI EVALBOT– http://www.ti.com/evalbot
• Download and install the IAR 32K edition of Embedded Workbench for the ARM (V5.5)– http://supp.iar.com/Download/SW/?item=EWARM-KS32– You will need to install the J-Link driver
• Download and unzip the µC/OS-III book examples:– http://www.Micrium.com/Books/Micrium-uCOS-III
• Download and install the non-time limited TRIAL version of µC/Probe:– http://www.Micrium.com/Books/Micrium-uCOS-III
Texas Instruments EVALBOT unassembled
26
Texas Instruments EVALBOT
Bumpers(2)
96x6 OLEDDisplay
Motor/Wheel(2) Batteries
(3 AA)
ON/OFFSwitch
User Switches(2)
StellarisLM3S9B92
MicroSDSocket
RJ45 10/100Ethernet
USB-DeviceConnector
USB-HostConnector
In-CircuitDebug Interface
Speaker
Examples
• Example 1: Simple Display– Rotates a series of messages on the Display
– Blinks LEDS on the board
• Example 2: Using Audio– Bump sensors select next or previous wav track
– SWITCH2 begins audio playback, SWITCH1 stops playback
• Example 3: Simple Control– Manual start/stop of the motor via SWITCH1, SWITCH2 and bump sensors
• Example 4: Autonomous Control– EVALBOT moves randomly and reacts to sensor inputs.
28
Autonomous EVALBOT Control
29
Input Monitor Task posts flags to Control Task
Control Task queues commands to motor tasks
If Timer expires a random turn is initiated
Motor Tasks receives command, interprets and
posts to PID Task
PID Task closes motor control loop based on feedback from speed
sensor interrupt handlers
speed sensor interrupts relay data back to PID Task
buttons and Bump Sensor trigger Input monitor task