Lab. 2 – More details – Later tasks

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

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.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Embedded System Timers Details of independent timers build into the Blackfin Assignment 2-- Watchdog Timer can be used to prevent the OS system from locking.
Thermal arm-wrestling Design of a video game using two programmable flags (PF) interrupts Tutorial on handling 2 Hardware interrupts from an external device.
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.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
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.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Blackfin Timers Independent timers build into the processor Watchdog Timer is a major part of Lab. 2 (Code provided to you to use)
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.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
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.
Mistakes, Errors and Defects. 12/7/2015Mistakes, Errors, Defects, Copyright M. Smith, ECE, University of Calgary, Canada 2 Basic Concepts  You are building.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
12/14/2015 Concept of Test Driven Development applied to Embedded Systems M. Smith University of Calgary, Canada 1 Automated Testing Environment Concepts.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
“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,
Developing Tasks to use with a co-operative scheduler Ideas for Assignment 2 Lab. 2, 3 and 4 Review for Midterm on Lab. 2 Ideas of defects, errors and.
Computer Architecture
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Lab. 2 Overview – Earlier Tasks Prelaboratory T1, T3, T4 and T5
Interrupts, Tasks and Timers
Software and Hardware Circular Buffer Operations
Lab. 2 Overview.
Generating the “Rectify” code (C++ and assembly code)
Generating “Rectify( )”
A Play Core Timer Interrupts
Automated Testing Environment
Thermal arm-wrestling
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
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.
A Play Lab. 2 Task 8 Core Timer Interrupts
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.
* M. R. Smith 07/16/96 This presentation will probably involve audience discussion, which will create action items. Use PowerPoint.
HD44780 LCD programming From the Hardware Side
HD44780 LCD programming From the Hardware Side
General purpose timers
Getting serious about “going fast” on the TigerSHARC
Thermal arm-wrestling
Concept of TDD Test Driven Development
Blackfin Timers Independent timers build into the Blackfin
Lab. 4 – Part 2 Demonstrating and understanding multi-processor boot
Independent timers build into the processor Basis for Lab. 2
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
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
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system.
Thermal arm-wrestling
Mistakes, Errors and Defects
Post Lab Quiz 3 Review Assignment 2 Help
Working with the Compute Block
Blackfin Syntax Moves and Adds
Presentation transcript:

Lab. 2 – More details – Later tasks What concepts are you expected to understand after the Lab. 2 is finished? How do you demonstrate that you have that knowledge?

Show understanding of what concepts? How to write up a “valid” (working) “C++” interrupt service routine for the timers on a microcontroller. How to set up a timer to be able to cause an interrupt. How to set-up the “C++” to handle a new interrupt without crashing Demonstrate “multi-tasking” – a main program and a background “interrupt” routine Using a test driven development approach to demonstrate validation of the other concepts 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

To be tackled today Lab. 2 – Concepts to be understood and demonstrated TDD – develop the tests THEN the code Overview of Lab. 2 – Tasks 1, 3, 4 and 5 – Prelab. TDD development of CORETIMER Initialize the core timer registers -- Task 7 Start and stop function for core timer – Task 8 How to “software test” a hardware interrupt – Task 9 Task 10 -- Learning how to get the processor to “walk and chew gum” at the same time Foreground task – display the movie Background task – demonstrate the VCR operation under interrupt control of the core timer Application stream only – use large TV screen Tasks 6, 11 and 12 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Recap of what has been discussed Prelaboratory T1, T3, T4 and T5 Download the "Watchdog Timer" Video Game T1 - Video Game Do not do Task 2 as part of Lab. 2 pre-laboratory exercises Generate and use your ASM functions to control WatchDog interrupts T2 - My WatchDog Control Functions Task 2 is meant as a practice exercise for the Midterm Exam Build a simple timer T3 --Non interrupt driven timer Watch a movie T4 - on a small movie screen Setting up E-TDD environment (Assignment 1 and 2) T5 - Automated tests for Lab. 2 Application stream only tasks (not prelab) Watch a sailing movie  T6 - using a LARGE movie screen Watch a sailing movie with the help of the T11 -- Snoopy and Red Baron 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

SMALLEST TV IN THE WORLD – PRESSING SW2 This slide is brought to you by the letter “M” PRESS SW1 Clears the screen PRESS SW2 7 rows of pixels 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

ERRORS AND DEFECTS We have some new functions developed in Task 1 TLD - Test last development Need a systematic way to ensure that those functions work now “Regression Testing” and a systematic way to ensure that they work in the future after modification “Defect free” development environment By discovering all the mistakes (called ERRORS) before developing any further code based on these functions we can ensure that no hidden mistakes (CALLED DEFECTS) are present Errors are easier, and less costly, to fix as you are in that part of the code where they have been introduced – you know where to look 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

CORE TIMER MMR Memory Mapped Registers Registers BELONG to the CORE TIMER not the processor The Core timer is a programmable interval timer which can generate periodic interrupts. Blackfin Hardware pages 15-45 onwards. The Core timer runs at the core clock (CCLK) rate. The timer includes four core Memory-Mapped Registers (MMRs), the Timer Control register (TCNTL) p 15-47, the Timer Count register (TCOUNT) p 15-47, the Timer Period register (TPERIOD) p 15-48, and the Timer Scale register (TSCALE) p 15-49. 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Write a test to check stub works Init_CoreTimer06ASM( ) 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

TDD for the control of the TCOUNT core timer register - 2 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

TDD FOR TCOUNT and TSCALE 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Full Test for Init_CoreTimerASM( ) 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Tasks 10 -- Concept main( ) Set up LED and PF operation Set up Timer Interrupts and THEN activate them Show the picture using C++ wait loop Demonstration stream SMALL SCREEN 4,3,2,1,0 Application stream LARGE SCREEN 14 …. 0) Interrupt service routine in the background suspends operation of main( ) at certain time intervals When CORE-TIMER expires – unpredictable when it will occur Task 10 – flashes LED 5 – SMALLEST (UNSET) VCR Application stream Flash LED 15 for larger VCR (or do something more fancy with interrupts 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Task 5 details 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Stop and start timer code TDD 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

How do you clear a sticky bit How do you clear a sticky bit? Very carefully – apparent documentation error W1C IF THE PROCESSOR SETS THE STICKY BIT DURING AN INTERRUPT W0C IF YOU (accidentally) SET THE STICKY BIT BY POOR PROGRAMMING 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Build the C++ ISR routine -- TLD LEARN THE KEY ELEMENTS OF C++ ISR CODING 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Key components of C++ ISR -- 1 SPECIAL C++ HEADER FILES VOLATILE VARIABLES FOR PASSING INFORMATION STORED IN MEMORY – NOT SUBROUTINE PARAMETERS IN REGISTERS 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Key components of C++ ISR -- 2 SPECIAL “TYPE” THIS SPECIAL NAME IS DEFINED IN THE SPECIAL HEADER FILES MANY ERROR MESSAGES IFHEADER NOT INCLUDED 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Know the error messages in case you make this mistake THE LIST GOES ON FOR ABOUT TWO PAGES FIX THE PROBLEM YOURSELF Don’t ask T.A. for help 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Key components of C++ ISR -- 3 MUST CLEAR INTERRUPT FLAG – W1C IF THE INTERRUPT FLAG IS NOT CLEARED – THEN INTERRUPT SERVICE ROUTINE WILL IMMEDIATELY RESTART 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Testing of C++ ISR -- 2 Big Problem The ISR is called (works) ONLY when the core timer counts down to zero We don’t know when that will happen because that is a hardware issue. Hardware driven interrupts are “unpredictable” and therefore it is difficult to test that the ISR works as required! THIS IS A PROBLEM MUST BE SOLVED OFTEN IN INDUSTRY (AND ALWAYS IN 415 MIDTERM and FINALS) 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Solution for Testing ISR -- 1 Make sure that no CORETIMER interrupt can accidentally occur Tell the operating system that when the core timer causes the special core timer bit (related to ik_timer) in the ILAT register to be set then the ISR called TIMER_ISR (our chosen name) should be called NOTE: The register-handler C++ instruction just sets up the INTERRUPT VECTOR – it does not start the interrupt 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Solution of Testing ISR -- 2 Set KNOWN CONDITIONS Use “raise( )” to “raise bit_IVTMR” which (by software) forces the CORE TIMER interrupt to occur. SOFTWARE INTERRUPT Then check that 1) volatile variable led_toggle changed 2) The correct value was output on the LED lights 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

FOUR STEPS NEEDED for setting up and then activate the CORE TIMER ISR Now back in Lab. 2 project and NOT in Lab2Tests – all the tests are automatically disconnected VCR light should now BLINK void ActivateMovie(void) { The four steps IN THIS ORDER AVOID RACE CONDITIONS interrupts going off when not expected 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada

Tasks 10 -- Foreground task (Walk) ISR – Background task (and Chew gum) main( ) Set up LED and PF operation Set up Timer Interrupts and THEN activate them Show the picture using C++ wait loop Demonstration stream SMALL SCREEN 4,3,2,1,0 Application stream LARGE SCREEN 14 …. 0) Interrupt service routine in the background suspends operation of main( ) at certain time intervals When CORE-TIMER expires – unpredictable when it will occur Task 10 – flashes LED 5 – SMALLEST (UNSET) VCR Application stream Flash LED 15 for larger VCR (or do something more fancy with interrupts 12/29/2018 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada