Thermal arm-wrestling

Slides:



Advertisements
Similar presentations
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Advertisements

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 1 Temperature Sensor Laboratory 2 Part 2 – Developing.
Thermal arm-wrestling Design of a video game using two programmable flags (PF) interrupts Tutorial on handling 2 Hardware interrupts from an external device.
Building a simple loop using Blackfin assembly code M. Smith, Electrical and Computer Engineering, University of Calgary, Canada.
Specialized Video (8-bit) and Vector (16-bit) Instructions on the Blackfin There is always a “MAKE-UP-YOUR-QUESTION-AND-ANSWER-IT” Question on a Dr. Smith.
Developing a bicycle speed-o-meter Part 2 A comparison between the Analog Devices ADSP-BF533 (Blackfin) and Motorola MC68332.
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.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Core Timer Code Development How you could have done the Take- Home Quiz using a test driven development (TDD) approach.
Specialized Video (8-bit) and Vector (16-bit) Instructions on the Blackfin Expand on these ideas for Q9 question and answer on the final.
LCD programming Design and implementation details on the way to a valid SPI-LCD interface driver.
Timers and Timing Signals Tutorial. 6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 2 / 31 Temperature Sensor -- Lab 3.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Laboratory 1 – ENCM415 Familiarization with the Analog Devices’ VisualDSP++ Integrated Development Environment.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
Developing a bicycle speed-o-meter Midterm Review.
Peripherals and their Control An overview of industrially available “peripheral devices” that use “pulse-width modulation” for information passing. Review.
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);
Mistakes, Errors and Defects. 12/7/2015Mistakes, Errors, Defects, Copyright M. Smith, ECE, University of Calgary, Canada 2 Basic Concepts  You are building.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
Building a simple loop using Blackfin assembly code If you can handle the while-loop correctly in assembly code on any processor, then most of the other.
“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.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
Developing a bicycle speed-o-meter
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
A Play Core Timer Interrupts
SPI Compatible Devices
Thermal arm-wrestling
DMA example Video image manipulation
The planned and expected
Handling Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
CSCI1600: Embedded and Real Time Software
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.
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
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
Expand on these ideas for Q9 question and answer on the final
General purpose timers
Getting serious about “going fast” on the TigerSHARC
Thermal arm-wrestling
Concept of TDD Test Driven Development
Explaining issues with DCremoval( )
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.
DMA example Video image manipulation
Developing a bicycle speed-o-meter
Blackfin Timers Independent timers build into the processor
Independent timers build into the processor
Developing a bicycle speed-o-meter
Developing a bicycle speed-o-meter
Thermal arm-wrestling
Building a simple loop using Blackfin assembly code
Developing a bicycle speed-o-meter Part 2
Mistakes, Errors and Defects
Developing a reliable communication between Blackfin and Slave device
Post Lab Quiz 3 Review Assignment 2 Help
Working with the Compute Block
Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps
Presentation transcript:

Thermal arm-wrestling Design of a video game using two programmable flags (PF) interrupts Testing using “software interrupts”

To be tackled today Customer requirements for a video game Need to tackle 4 tasks at the same time – can’t afford to wait for one task to complete – must do all tasks at the same time Have certain tasks generate interrupts when they occur; rather than waiting for them to occur 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Customer game concept I WIN YOU WIN Has two sensors and a ready signal At the ready signal – the two players have to use bio-feedback to move the cursor into the winning area Three play modes One person player – moves the cursor with one sensor One person player – moves the cursor with the other sensor Game mode – two players Sensor reading is determined by the difference in the temperature NOW being sensed compared to the average temperature during the time just before the ready signal 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Customer game plan Declare variables Player1_TemperatureNow Player1_TemperatureStart Ditto player 2 While not started { Determine Player1 Temperature, Player2 temperature Set start temperatures Update Game Screen with start information } Cursor is centered – update Game screen While nobody has won { Determine Player1 Temperature, Player2 temperature Determine Player1, player2 difference in temperature IF player1 difference larger then decrement cursor OTHERWISE cursor ++ Update Game screen Determine if somebody has won } Display winning message 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Issues Need to continually calculate and update cursor on the display screen Need to update Display Simple Display – 5 LED lights + game underway LED LCD screen (get credit during Lab. 5) Need to measure 2 temperatures at the same time. Possibly 60 averages every second – frequency of temperature sensors is 33 Hz – 2 seconds of processing needed every 1 second if use WaitTillHigh( ) and WaitTillLow( ) function call approach MINIMUM requirements for Lab. 4 – show that you can handle each component of the game, even if the complete game is not provided. 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Concept for a possible solution Use TDD approach Main task – calculating / updating cursor and display 2nd task -- 1 sensor on PF11 – 33 Hz signal – need to measure periods of high and low signal to determine temperature. 3rd task -- Second sensor on PF10. Long term goal -- average of 30 values every second. That’s 2 seconds of processing every second if done by normal programming Possible solution – use the PF signals to generate interrupts on high/low and low/high transitions and read core time values into array. Use the core timer values to determine a temperature Discussed and tested in the next lecture class – handling the two PF signals which both cause the SAME interrupt signal 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Tests needed Show we can link thermal test code to main( ) Show CoreTimer and LED functions are still working. Show we can handle a single PF interrupt (software interrupt) Show we can use a single PF interrupt to calculate a temperature. Do same thing for other PF interrupt Handle two PF interrupts at the same time to calculate temperature Show how we can set up the PF interrupts in hardware Demo full solution using LED display to show cursor movement – but code so that can upgrade to more lights or LCD screen when becomes available. Show we can store a series of time readings in an array Show we can calculate the temperature from timer reading array – calculate average of 30 on each sensor Demo final version 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

1 -- Build test to show we can link to new project from main( ) If using your own tests, then you may need to change include paths Attempt to track down the reason for Tests being run when not planned int Connect_ThermalVideoGameTests(int level); static bool valid_test_request = false; static int wanted_test_level = 0; int Connect_ThermalVideoGameTests(int level) { valid_test_request = true; wanted_test_level = level; } 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

1 -- Build “code” to pass the test // Run all the required tests Connect_ThermalVideoGameTests(0x0); 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

2 -- Build test to show Core Timer and LED functions are still working Activate the Core Timer test code from before Activate LED test code from before (Lab. 2). Show only failed tests // Run all the required tests Connect_ClassTimerDemo(0xFF); Connect_ThermalVideoGameTests(0x0); Connect_instructortestsLED_Lab2Part1(0xFF); 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Issues when developing interrupt driven code All of the following must be working for your code to work Main task Interrupt task Setting up the interrupt hardware registers Connecting up the system to external events that cause interrupts All are interlinked – making it difficult to determine what part of the code (a DEFECT) is causing a problem. Need an approach to test each component separately 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Solution Software interrupt – which turns the signal coming from an external event into a signal that comes from an internal event. The internal event occurs exactly when you want it to -- rather than randomly as would happen with an external event. Later, when everything is working, connect to the hardware and test that component. PF interrupts occur via an “IVG12” core event – see hardware manual Table 4.6 Visual DSP++ help information – cause a software interrupt that produces the same internal interrupt signal as does the outside PF signals #include <signal.h> raise(ik_ivg12); The raise signal causes interrupt IVG12 to occur Question that needs answering after a “raise( )” of a software interrupt, do you have to do a “lower( )” to stop the software interrupt from continually happening? 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

3 – Test for handling a single PF interrupt using a software interrupt test Similar to Core timer Interrupt Syntax “raise( )” forces a software interrupt of type ik_ivg12 (PF) Will need to worry about hardware setup later 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Question that needed answering After a “raise( )” of a software interrupt, do you have to do a “lower( )” to stop the software interrupt from continually happening? Attempted test to get the answer We should get just one interrupt each time around the loop if “raise( )” is cleared automatically We will get 10 interrupts with zero times around the loop if “raise( )” must be followed by lower( ) 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

3 -- Build test to show we can handle single PF interrupt Same syntax as for Core timer Interrupt Actually same routine – Different names WRITE YOUR OWN CODE AROUND 5 lines Bring in the code and compare to expected solution Will have to repeat this test with the PF hardware set-up for causing interrupt 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Need to simulate the time period of a Temperature Sensor input signal HIGH LOW Generate (“raise”) software interrupts at time intervals separated by different calls to UseFixedTimeASM( ) 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Errors in test !!!! Do a code review -- can you spot them? 4 -- Concept – use PF interrupt to read Core Timer Values and place in array Errors in test !!!! Do a code review -- can you spot them? 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

4 -- Write the code to pass the test WRITE YOUR OWN CODE AROUND 5 lines Bring in the code and compare to expected solution 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

4 – Fixing the Test code error 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

4B “Calculate a temperature” test Fake the times when the up-down-up signals of temperature sensor occur Long times to make loop more accurate Expected accuracy issues Had to print out values to check YELLOW FLAG TEST TYPE – CLOSE ENOUGH BUT NEEDS MORE INVESTIGATING 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

5 – Need to handle the “true PF registers” to generate a hardware interrupt Functions needed unsigned long int SetPFInterruptsASM( ??) Returns old interrupt settings Set new settings void StartPFInterruptsASM(???) void StopPFSettingsASM(???) Hardware information Chapter 14 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

PF registers Direction, Data, Polarity and Enable all from Lab. 2 Flag Mask registers – 14-11 Flag mask Interrupt data register – basically which PF pin caused the interrupt Flag mask Interrupt Set register – which PF pin is allowed to cause an interrupt Flag Mask Interrupt Clear register– which PF pin is no longer allowed to cause an interrupt Flag interrupt Sensitivity register (FIO_EDGE) – set for edge-sensitive Possible other system interrupt registers Global interrupt masks Peripheral interrupt masks 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

5 – Need to handle the “true PF registers” to generate a hardware interrupt unsigned long int SetPFInterruptsASM ( ushort whichPFinterrupts) Returns old interrupt settings Sets PF pins can cause edge sensitive interrupts void StartPFInterruptsASM(void) already exists as register_handler(ik_ivg12, PFInterruptHandler); void StopPFSettingsASM(void) Lets just stop all interrupts When PF11 interrupt occurs – the PF11 bit in the PF data register (FIO_FLAG_D) is set – this must be cleared using FIO_FLAG_C (clear data register) Useful hint perhaps -- When PF10 interrupt occurs does the PF11 bit in the PF data register (FIO_FLAG_D) get set – so we can tell which interrupt occurred? 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Tackled today Customer requirements for a video game Need to tackle 4 tasks at the same time – can’t afford to wait for one task to complete – must do all tasks at the same time Used the core timer to measure accurate values of temperature sensor high and low times Used software interrupts (“raising an interrupt”) to simulate interrupt signals coming from the temperature sensor (PF interrupts – IVG12) Next step – understanding how to control the hardware interrupts 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada

Information taken from Analog Devices On-line Manuals with permission http://www.analog.com/processors/resources/technicalLibrary/manuals/ Information furnished by Analog Devices is believed to be accurate and reliable. However, Analog Devices assumes no responsibility for its use or for any infringement of any patent other rights of any third party which may result from its use. No license is granted by implication or otherwise under any patent or patent right of Analog Devices. Copyright  Analog Devices, Inc. All rights reserved. 1/11/2019 Thermal Arm Wrestling -- Software PF interrupts, Copyright M. Smith, ECE, University of Calgary, Canada