View
215
Download
0
Tags:
Embed Size (px)
Citation preview
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?
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
2 / 28
To be tackled today
Lab. 2 – Concepts to be understood and demonstrated Test driven development approach
Design the tests THEN the code
Overview of Lab. 2 Details of Lab. 2 Task 1
Setting up the SMALLEST TV IN THE WORLD – MANUALLY OPERATED
Details of Lab. 2 Task 2 Setting up the testing environment for Lab. 2
Details of Lab. 2 Task 3 Test Last Approach to check that Task 1 functions really work
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
3 / 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
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
4 / 28
Demonstration of these concepts - 1
1. 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
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
5 / 28
Demonstration of these concepts - 2
4. 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
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
6 / 28
Small TV in the world – white picture
This slide is brought to you by the letter “M”
Pixels become activated as the electron gun “paints” the various pixels on the screen
Repainted every 1/30 s
Persistence of vision makes it appear “there all the time”
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
7 / 28
Small TV in the world
This slide is brought to you by the letter “M”
7 rows of pixels
Pixels become activated as the electron gun “paints” the various pixels on the screen
Repainted every 1/30 s
Persistence of vision makes it appear “there all the time”
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
8 / 28
Small TV in the world – SW1
This slide is brought to you by the letter “M”
7 rows of pixels
MANUAL TV
PRESS SW1
to clear screen
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
9 / 28
Small TV in the world – Press SW2
This slide is brought to you by the letter “M”
7 rows of pixels
MANUAL TV
PRESS SW2to display each line
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
10 / 28
SMALLEST TV IN THE WORLD –
This slide is brought to you by the letter “M”
1 row of pixels
PRESS SW1
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
11 / 28
SMALLEST TV IN THE WORLD – PRESSING SW2
This slide is brought to you by the letter “M”
7 rows of pixels
PRESS SW2
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
12 / 28
ENOUGH PRESSES ALREADY
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
13 / 28
Lab. 2 Task 1 – Basic hardware test
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
14 / 28
L2 T1 – Code for the “TV frame buffer”
Displayed usingWriteLEDASM( )
This slide is brought toyou by the letter “A”
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
15 / 28
L2 T1 – Final main( )Press SW1 to clear the screen
APPARENTINFINITE LOOP
INFINITE LOOP AVOIDED SINCEVOLATILE VARIABLE start_picture_again
IS BEING CHANGED ELSE WHERE
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
16 / 28
L2 T1 – Final main( )Press SW2 repeatedly to display “picture”
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
17 / 28
Lab. 2 Task 1 – New Code needed
void StartPictureCommand(void); changes the volatile variable
start_picture_again defined in main.cpp (meaning its external to this file) to 1 when switch 1 is held down and then released.
void NextLineCommand(void); changes the volatile variable next_line to 1
when switch 2 is held down and then released.
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
18 / 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
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
19 / 28
L2 T2 – Setting up test environment
This test environment is automated Makes it easy for you to run the tests often
Many provided testing files that you can just download Only work if you have called the functions you develop exactly
what is specified in the web pages Imagine that this is in industry, and you are working with a
colleague (“me”) as part of the team. This is meant to be a supportive relationship.
Expect an occasional typo in the test or test documentation. These occur when I make some minor changes to the pages during the laboratory development.
Get a model in your head of what is “supposed to happen next”. That model will often get you past an apparent road block in the web pages
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
20 / 28
L2 T2 – Setting up test environment
I will be providing you with project files to download (.prj) to download and automatically link to your code and tests Only works if you have called the files you develop
exactly what is specified in the web pages. There are simple “work arounds” supplied by the
VisualDSP tool functionality to overcome this problem – which would be fairly common industry. Learn to use this feature.
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
21 / 28
Required LAB Directory Environment
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
22 / 28
Required Files From Lab. 1 and Lab1Tests
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
23 / 28
Required Files – Lab2 and Lab2Testsand GUI set-up
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
24 / 28
Lab. 2 Task 3 Test 1 -- SW1 control Testing StartPictureCommand()
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
25 / 28
Lab. 2 Task 3 Test 2 -- SW1 control Testing StartPictureCommand()
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
26 / 28
Lab. 2 Task 3 Test 3 -- SW1 control REFACTORING StartPictureCommand()
Problems like this being found and solved
P0.H = hi(_name); P0.L = hi(_name);
TEMPORARY DEBUG FIX -- REMOVE WHEN PROBLEM SOLVED
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
27 / 28
Lab. 2 Task 3 Tests for SW2 control NextLineCommand()
You are responsible for setting up these test
Basically a cut-and-paste job of the tests for SW1
This is where I expect you to be when you come into the Lab. 2
Also see “Assignment 3” which combines “practice for post-lab Quiz 1” and getting ready for Lab. 2 Effectively Assignment is worth around 2% of the course
(because of the Lab. 2 component) when handed in as part of Lab. 2. However there are no marks directly associated with Assignment 3.
04/18/23 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada
28 / 28
Tackled today
Lab. 2 – Concepts to be understood and demonstrated Test driven development approach
Design the tests THEN the code
Overview of Lab. 2 Details of Lab. 2 Task 1
Setting up the SMALLEST TV IN THE WORLD – MANUALLY OPERATED
Details of Lab. 2 Task 2 Setting up the testing environment for Lab. 2
Details of Lab. 2 Task 3 Test Last Approach to check that Task 1 functions really work