Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 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?

2 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?

3 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

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

5 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 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”

7 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

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

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

10 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 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.

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

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

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

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

15 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

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

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

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

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

20 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

21 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

22 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

23 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

24 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

25 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

26 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

27 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

28 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?


Download ppt "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."

Similar presentations


Ads by Google