280 likes | 313 Views
Micrium’s μ C/OS for Makers A Hands-on Course. Class 1: Introduction to μ C/OS II/III. January 30, 2017 Charles J. Lord, PE President, Consultant, Trainer Blue Ridge Advanced Design and Automation. This Week’s Agenda. 1/30 Introduction to μ C/OS II/III 1/31 The Micrium Maker Program
E N D
Micrium’s μC/OS for Makers A Hands-on Course Class 1: Introduction to μC/OS II/III January 30, 2017 Charles J. Lord, PEPresident, Consultant, TrainerBlue Ridge Advanced Design and Automation
This Week’s Agenda 1/30 Introduction to μC/OS II/III1/31 The Micrium Maker Program 2/1 Setting up our Development System 2/2 Writing Our Tasks and Establishing Scheduling 2/3Mutexes, Messages, and Semaphores, Oh My!
This Week’s Agenda 1/30 Introduction to μC/OS II/III1/31 The Micrium Maker Program 2/1 Setting up our Development System 2/2 Writing Our Tasks and Establishing Scheduling 2/3Mutexes, Messages, and Semaphores, Oh My!
Real-Time Operating Systems • We hear a lot about the proliferation of RTOS on myriad processors, even some 8-bit machines, but when do we need a real-time operating system (RTOS)? • Just how critical is timing and interoperation? • Cost of chip size, power consumption • “small ARM” vs 8/16 bit • “Free” RTOS and many paid ones, plus alternatives (kernels, etc) Question 1 – Experience with RTOS? Which one(s)?
RTOS Tasks • A Task in an RTOS is a self-contained process that is called by the OS • Each task has its own stack and may have dedicated RAM (at least for the duration of its active time) • Tasks run for a finite time and then go back to an inactive state • Tasks can send and receive messages
Scheduling Tasks • An RTOS (or multi-tasking system) uses either one or both of the following methods to switch between tasks: • Event-driven – switches tasks only when an event of higher priority needs servicing; called preemptive priority, or priority scheduling. • Time-sharing – switches tasks on a regular clocked interrupt, and on events; called round robin.
Simplest Round Robin for (;;) { taskA(); taskB(); taskC(); //etc } // Note that this gives each task the opportunity to take over! Very simple but also dangerous!
Reasons for Round Robin • Assures every task gets a chance to run • Time slots are a simple way to prevent runaway • Early microprocessors took a ‘long’ time to switch tasks • Appearance that all tasks are running concurrently
Reasons for Preemptive Priority • Not all tasks need a time slot • RR takes time from high-priority tasks • Totally priority (and time ready) driven • More complex • Sometimes you need both…
μC/OS • Like much of great software, was written by an engineer who needed a better tool • Written by Jean Labrosse ca 1991 • Original version – 64 tasks, fairly core-specific • μC/OS II – 255 tasks, purely preemptive, one task per priority level • μC/OS III – unlimited tasks and priorities, added round robin capabilities (and more)
Complete Family RTOS
https://doc.micrium.com/display/osiiidoc/uC-OS-III+Documentation+Homehttps://doc.micrium.com/display/osiiidoc/uC-OS-III+Documentation+Home
Freescale FRDM-K64 • K64 Cortex-M4 • 120 MHz • 1 MB flash • 256 KB RAM • mbed • Arduino™ R3 pin layout - we can add shields Debug connector – next to RESET Question 3 – Will you be doing the ‘hands on’ part? What board?
Board Pinout NOTE – our Arduino shield only uses the outside rows!
Update the MBED driver if needed • Connect your FRDM-K64F board via the programming USB connector (next to the reset button) • Once Windows recognizes it, you should have a new drive called MBED. Open this folder. • If there is a DETAILS.TXT file on the MBED device, read it. Otherwise open mbed.htm with a text editor and look for the version number. It should be 0226. • If not, follow the directions at: http://developer.mbed.org/handbook/Firmware-FRDM-K64Fhttps://developer.mbed.org/media/uploads/sam_grove/0226_k20dx128_k64f_0x5000.bin
Install the Windows Driver if Needed NOT NEEDED FOR WIN 10 • Plug the FRDM board into the PC • Open Device Manager • Check ports – if you don’t see a mbed port, you need to install the Windows driver
Installing the Driver • http://developer.mbed.org/handbook/Windows-serial-configuration • Follow the directions on steps 1 and 2 • Note that this installer needs to be run for every mbed board that you use – it sets up a device driver for each individual serial number
After installing the serial port driver, you should see these four devices
References • Jean Labrosse’s CEC on Micrium μC/OS II/IIIhttps://www.designnews.com/continuing-education-center/introduction-real-time-kernels • My CEC on Multitaskinghttps://www.designnews.com/continuing-education-center/multitasking-scratch • My CEC on MQXhttps://www.designnews.com/continuing-education-center/hands-on-develop-rtos-application-using-freescale-mqx • My CEC on FreeRTOShttps://www.designnews.com/continuing-education-center/hands-on-develop-rtos-application-using-freertos
This Week’s Agenda 1/30 Introduction to μC/OS II/III1/31 The Micrium Maker Program 2/1 Setting up our Development System 2/2 Writing Our Tasks and Establishing Scheduling 2/3Mutexes, Messages, and Semaphores, Oh My!
Please stick around as I answer your questions! • Please give me a moment to scroll back through the chat window to find your questions • I will stay on chat as long as it takes to answer! • I am available to answer simple questions or to consult (or offer in-house training for your company)c.j.lord@ieee.orghttp://www.blueridgetechnc.comhttp://www.linkedin.com/in/charleslordTwitter: @charleslordhttps://www.github.com/bradatraininghttps://www.charleslord.info (bio and what I’m up to)