Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system.

Slides:



Advertisements
Similar presentations
Real-Time Library: RTX
Advertisements

CSCC69: Operating Systems
Lab. 2 Overview. Lab. 2 and Assignment 3 Many Lab. 2 and Assignment 3 tasks involve “downloading” provided code, compiling and linking into a project.
A look at interrupts What are interrupts and why are they needed.
Boot Issues Processor comparison TigerSHARC multi-processor system Blackfin single-core.
Review of Blackfin Syntax Moves and Adds 1) What we already know and have to remember to apply 2) What we need to learn.
Lab. 2 – More details – Tasks 4 to 6 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
A look at interrupts What are interrupts and why are they needed in an embedded system? Equally as important – how are these ideas handled on the Blackfin.
Lab. 2 Overview 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have that knowledge?
Timers and Timing Signals Tutorial. 6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 2 / 31 Temperature Sensor -- Lab 3.
A look at interrupts What are interrupts and why are they needed.
Tutorial Essentially all the Blackfin instruction you need for all of ENCM511. The instructions are easy. Its knowing when to use them that is the difficult.
EEE527 Embedded Systems Lecture 8: Practical Interrupts Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site:
HD44780 LCD programming From the Hardware Side
M. Smith University of Calgary.  Many people like to sing in the shower.  However, its rather boring as there is no accompaniment.  The McVASH device.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM511.
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system Manual control of RC car.
Lab. 4 Demonstrating and understanding multi-processor boot TigerSHARC multi-processor system.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Support Across The Board ™ Visual DSP Kernel (VDK)
Lab. 2 Overview. Echo Switches to LED Lab1 Task 7 12/4/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 2 / 28.
Multi-threaded projects Services and Drivers Alternate ways of doing Labs 1, 2, 3 and 4.
The right and wrong ways for constructing tasks for the Labs and Assignment.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
Assignment 4 / Lab. 3 Convert C++ ISR to ASM AND GET IT TO WORK Doing Assignment 4 / Lab. 3 the Test Driven Development way.
“Lab. 5” – Updating Lab. 3 to use DMA Test we understand DMA by using some simple memory to memory DMA Make life more interesting, since hardware is involved,
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
See the Lab. 1 web-site and later lecture notes for more details
VDK Concepts and Features How to Create a Project with VDK support
Lab. 2 Overview – Earlier Tasks Prelaboratory T1, T3, T4 and T5
Lab. 2 Overview.
A Play Core Timer Interrupts
Thermal arm-wrestling
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
TigerSHARC processor and evaluation board
Lab. 2 – More details – Later tasks
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Understanding the TigerSHARC ALU pipeline
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Thermal arm-wrestling
Using Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Lab. 4 – Part 1 Demonstrating and understanding multi-processor boot
A Play Lab. 2 Task 8 Core Timer Interrupts
See the Lab. 1 web-site and later lecture notes for more details
General purpose timers
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
HD44780 LCD programming From the Hardware Side
Implementing Mutual Exclusion
General purpose timers
Getting serious about “going fast” on the TigerSHARC
Thermal arm-wrestling
Concept of TDD Test Driven Development
Explaining issues with DCremoval( )
Blackfin Timers Independent timers build into the Blackfin
Lab. 4 – Part 2 Demonstrating and understanding multi-processor boot
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Independent timers build into the processor Basis for Lab. 2
Implementing Mutual Exclusion
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Blackfin Timers Independent timers build into the processor
Independent timers build into the processor
VDK Concepts and Features How to Create a Project with VDK support
Thermal arm-wrestling
VDK Concepts and Features How to Create a Project with VDK support
Post Lab Quiz 3 Review Assignment 2 Help
Blackfin Syntax Moves and Adds
Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps
ECE 3567 Microcontrollers Lab
Presentation transcript:

Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system

Lab. 2 – Task 1 Echo Switches to LED (Lab1 Task 7) 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

How would you handle a more complex set of embedded tests Echo switches 1 and 2 in LED’s 1 and 2 Flash LED 3 every 2 seconds Flash LED 4 every 1 second Flash LED 5 every ½ second Flash LED 6 every ¼ second Etc etc 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

If we used the “super-loop idea” QUESTONS TO ASNWER We need the processor to switch LED every 2 seconds How do you handle the timing? How can you get the processor to go to sleep to save battery power at other times? int main( ) { InitLED( ); while (1) { if CorrectTIme(time1) then TaskFlashLED3( ); I if CorrectTIme(time 2) then TaskFlashLED3( ); value = ReadSwitches( ); WriteLED(value >> 8); } 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

From Pont’s book Control of an aeroplane 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Need a systematic way of programming such a system These ideas and the following slides are based on the book by M. J. Pont – “Patterns for Time-Triggered Embedded Systems” Down load a free copy from www.tte-systems.com/downloads/pttes_0408a.pdf The code in the book was for the 8051 processor and I have modified the code to run on Blackfin Processor 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Scheduler The idea is to make a list of all the tasks that you need to make the embedded system to work Then you use a “scheduler” to cause the tasks to run Pre-emptive scheduler -- discussed Friday Tasks run as random events Co-operative Scheduler -- discussed Friday Tasks run at predictable intervals 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Lab. 2 Task 2 – Download TTOS and validate the install Check the web pages for install details TTCOS511.h file all the prototypes for the TTCOS functions TTCOS511.dlb the TTCOS library for the Blackfin Example_TTCOSmain.c Use this as a template for all TTCOS programs in Labs, assignment and quizzes and exams) 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

The only lines of code that ever change 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

The total code for Lab. 2 Task 2 First task – name -- Task_SayGreeting Runs with no delay Runs only once Second task – name -- Task_SayHiOccasionally Runs with no delay Runs every 5 seconds, and then allows processor to sleep 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Lab. 2 – Task 3: Reuse Lab. 1 Functions within TTCOS Step 1 in process Recognize the tasks that are needed 3 RUN_ONCE 2 PERIODIC 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Can re-use of Lab. 1 Init functions as they have the form (prototype) void FooBar(void) 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

We need a RUN ONCE TASK to clear the LEDs We need a periodic task void Task_ReadSwitches (void) that gets the swiitch positions and stores the answer in a “shared variable” switch_result We need another periodic task void Task_WriteLED(void) that gets the value from the shared variable switch_result and displays it 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Rest of the code for Lab. 2 Task 3 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

ZOO Christmas Challenge 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Lab. 1 Task 4 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Lab 2 Task 5 – Add one line of code and a VDSP object file (.doj) Task 5 – Drive the car (manually) using switches 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Lab. 2 Task 6 – Use Lab. 1 Task 8 code to drive car using “stored values” 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

ENCM Real time course Pre-emptive scheduler Previous classes have used Analog Devices VDK Kernel which is a pre-emptive scheduler. Lab. 2 problems Task to Flash LED 3 every 2 seconds Task to Flash LED 4 every one second Both tasks want to use same resource What happens if one task starts to save something and gets interrupted? 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

What does code look like on pre-emptive scheduler? Problem is “what happens if both alarms ring at same time (with larger ISR code) Interrupt Service Routine “Subroutine activated by hardware” not by “code” -- unpredictable int main( ) { Setup LED, Switches Set Up interrupts( ) and start them while (1 ) { // Lab. 1 Task 7 Read Switches and Write to LED; } Timer1_ISR( ) { // Only happens when Timer1 alarm rings Flash LED 3( ); } Timer2_ISR( ) { // Only happens when Timer1 alarm rings Flash LED 4( ); } 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

ENCM Real time course Pre-emptive scheduler Lab. 2 problems Task to Flash LED 3 every 2 seconds Task to Flash LED 4 every one second Both tasks want to use same resource What happens if one task starts to save something and gets interrupted? 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

We think we can solve this problem using “locks” and “semaphores” #define UNLOCKED 0 #define LOCKED 1 Bit lock = UNLOCKED ; // Global Lock void LED3_Task( ) while (lock == LOCKED) /* Wait for lock to be released */ ; lock = LOCKED; // Indicate using LEDs WriteLEDASM(LED3_ON); lock = UNLOCKED; } void LED4_Task( ) while (lock == LOCKED) /* Wait for lock to be released */ ; WriteLEDASM(LED4_ON); 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Solve this problem using “lock” #define UNLOCKED 0 #define LOCKED 1 Bit lock = UNLOCKED ; // Global Lock void LED3_Task( ) while (lock == LOCKED) /* Wait for lock to be released */ ; lock = LOCKED; // Indicate using LEDs WriteLEDASM(LED3_ON); lock = UNLOCKED; } void LED4_Task( ) WriteLEDASM(LED4_ON); Suppose LED3_Task gets switched out here and LED4_Task runs LED4_Task thinks the resource is free to use 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Need to know in future lectures Need to understand “interrupts” on the Blackfin Need to understand how the “core timer” and “watch dog timer” work and are programmed. Useful to understand how the scheduler works – but not necessary unless we plan to change it 4/18/2019 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada