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.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Boot Issues Processor comparison TigerSHARC multi-processor system Blackfin single-core.
Thermal arm-wrestling Design of a video game using two programmable flags (PF) interrupts Tutorial on handling 2 Hardware interrupts from an external device.
Over-view of Lab. 1 For more details – see the Lab. 1 web-site There will be a 20 min prelab quiz (based on Assignment 1 and 2) at the start of the lab.
Review of Blackfin Syntax Moves and Adds 1) What we already know and have to remember to apply 2) What we need to learn.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Display Interrupt Service Routine for cargo monitoring system Overview of concepts demonstrated during Labs 3 and 4.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
Core Timer Code Development How you could have done the Take- Home Quiz using a test driven development (TDD) approach.
HD44780 LCD programming From the Hardware Side Design and implementation details on the way to a valid SPI-LCD interface driver.
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.
Over-view of Lab. 1 For more details – see the Lab. 1 web-site There will be a 20 min prelab quiz (based on Assignment 1 and 2) at the start of the lab.
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.
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
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.
Generating “Rectify( )” Test driven development approach to TigerSHARC assembly code production Assembly code examples Part 1 of 3.
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.
12/14/2015 Concept of Test Driven Development applied to Embedded Systems M. Smith University of Calgary, Canada 1 Automated Testing Environment Concepts.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
Lab. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
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,
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.
Lab. 2 Overview – Earlier Tasks Prelaboratory T1, T3, T4 and T5
Interrupts, Tasks and Timers
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.
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
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.
General purpose timers
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
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
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
Presentation transcript:

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 that knowledge?

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada2 / 28 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 to 3 Details of Lab. 2 Task 4 TDD development of CORETIMER setup, start and stop function Details of Lab. 2 Task 5 TDD development of CORETIMER interrupt routines Use of developed functions for “C++” interrupt routine to make SMALLEST VCR IN THE WORLD Details of Lab. 2 Task 6 Complete the task of combining SMALLEST VCR and SMALLEST TV code – automatic operation Your own approach – design – Also use TIMER0 interrupt?

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

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada4 / 28 Demonstration of these concepts Set up THE SMALLEST TV IN THE WORLD – manually operated by switches Two new functions (around 6 C++ lines) developed 2. Set up the “Testing environment” for Lab. 2. – basically downloading files 3. Use the “testing environment” (in a “test last approach”) to valid the new functions developed in Task. 1 above Mainly downloading files and modifying cut-and-pasted code (around 20 C++ lines modified) These concepts are done as Assignment 3 where Task 1 must be done in assembly code and tested (Task 3), making good practice for Post Lab. 1 Quiz and cutting down time spent during Lab. 2

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada5 / 28 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

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada6 / 28 L2 T1 – Final main( ) Press SW2 repeatedly to display “picture”

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada7 / 28 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

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada8 / 28 Lab. 2 Task 3 -- SW1 control Testing StartPictureCommand()

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada9 / 28 Demonstration of these concepts Use a test driven development approach to set up core timer to known values withy ability to stop-and-start the core time (C++ and ASM approach). 5. Use a test driven development approach to set up and test core timer interrupts. Demonstrate the SMALLEST VCR IN THE WORLD (C++ and ASM approach). 6. Put everything together so that the SMALLEST VCR (in the world) and the SMALLEST TV (in the world) work together with or without human intervention

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada10 / 28 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 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

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada11 / 28 TDD of Init_CoreTimerASM( ) - 1

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada12 / 28 TDD for TCOUNT - 2

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada13 / 28 TDD FOR TCOUNT and TSCALE

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada14 / 28 Full Test for Init_CoreTimerASM( )

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada15 / 28 Tasks 5 and 6 -- Concept main( ) Set up LED and PF operation Set up Timer Interrupts and THEN activate them Change volatile variables start_next_picture and next_line using SW1 and SW2 manually Interrupt service routine in the background suspends operation of main( ) at certain time intervals When CORE-TIMER expires – unpredictable when it will occur Task 5 – flashes LED 5 – SMALLEST (UNSET) VCR Task 6 -- Change volatile variables start_next_picture and next_line very quickly and automatically SMALLEST TV AND VCR

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada16 / 28 Task 5 details

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada17 / 28 Steps 1 to 3

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada18 / 28 Activate and Stop CORE TIMER

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada19 / 28 Build the C++ ISR routine -- TLD

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada20 / 28 Key components of C++ ISR -- 1 SPECIAL C++ HEADER FILES VOLATILE VARIABLES FOR PASSING INFORMATION – NOT SUBROUTINE PARAMETERS

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada21 / 28 Key components of C++ ISR -- 2 SPECIAL NAME THIS SPECIAL NAME IS DEFINED IN THE SPECIAL HEADER FILES MANY ERROR MESSAGES IF NOT INCLUDED

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada22 / 28 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

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada23 / 28 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 MUST BE SOLVED OFTEN IN INDUSTRY

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada24 / 28 Solution for Testing ISR -- 1 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: This just sets up the INTERRUPT VECTOR – it does not start the interrupt Make sure that no CORETIMER interrupt can accidentally occur

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

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

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada27 / 28 Task 6 – design component 5% The VCR light flashes in bit 0 -- but that bit is being used by the TV. Adjust the code so that LED 5 and not LED 0 flashes 10% If you push the buttons to make the TV work, then every time the LED VCR flashes -- you lose the picture Adjust the code so that when the VCR light flashes -- ONLY LED 5 changes Adjust the code so that when the TV is working -- ONLY LEDs 0 to 4 change 15% Finally, we have to get the CORETIMER ISR to not only flash the VCR light, but automatically display our initials on the SMALLEST TV in the world without any switch pressing. COULD USETIMER0 interrupt This means that the interrupt routine is modified so that over a period of time (about 40 or 50 interrupts). Turns start_picture_again = 1 briefly and then start_picture_again = 0 for about 5 seconds. Turns next_line = 1 very briefly and then next_line = 1 very briefly -- Total of 7 times

6/2/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada28 / 28 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 to 3 Details of Lab. 2 Task 4 TDD development of CORETIMER setup, start and stop function Details of Lab. 2 Task 5 TDD development of CORETIMER interrupt routines Use of developed functions for “C++” interrupt routine to make SMALLEST VCR IN THE WORLD Details of Lab. 2 Task 6 Complete the task of combining SMALLEST VCR and SMALLEST TV code – automatic operation Your own approach – design – Also use TIMER0 interrupt?