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.

Slides:



Advertisements
Similar presentations
JED Microprocessors Pty Ltd Presenting the JED T430 low-cost Projector Controllers Nov 22nd, 2009.
Advertisements

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.
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.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
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.
Lab 3 Details. Lab 3 Develop a bio-feedback system based on a PWM (pulse width modulated) thermal sensor Use temperature setting to control the delays.
Peripherals and their Control An overview of industrially available “peripheral devices” Some ideas for Laboratories and Quiz / Exam questions.
Boot Issues Processor comparison TigerSHARC multi-processor system Blackfin single-core.
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.
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.
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.
Getting the O in I/O to work on a typical microcontroller Ideas of how to send output signals to the radio controlled car. The theory behind the LED controller.
Getting the O in I/O to work on a typical microcontroller Activating a FLASH memory “output line” Part 1 Main part of Laboratory 1 Also needed for “voice.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
HD44780 LCD programming From the Hardware Side
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.
1 Lecture on Lab 6 Lab 7 Lab 8. 2 Lab 6: Open Loop Controller As you learned in lab 5, there are two kinds of control systems: open loop and closed loop.
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. Echo Switches to LED Lab1 Task 7 12/4/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 2 / 28.
Over-view of Lab. 1 See the Lab. 1 web-site and the lecture notes for more details.
Multi-threaded projects Services and Drivers Alternate ways of doing Labs 1, 2, 3 and 4.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
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.
Lab3 -- Lab 4 Design and implementation details on the way to a valid SPI-LCD interface driver.
Lab. 2 Overview – Earlier Tasks Prelaboratory T1, T3, T4 and T5
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 -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Thermal arm-wrestling
Lab. 4 – Part 1 Demonstrating and understanding multi-processor boot
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
HD44780 LCD programming From the Hardware Side
General purpose timers
Getting serious about “going fast” on the TigerSHARC
Thermal arm-wrestling
Explaining issues with DCremoval( )
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.
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
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system.
Thermal arm-wrestling
Post Lab Quiz 3 Review Assignment 2 Help
Presentation transcript:

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. When the code is run, some special characteristics of the processor are examined Watchdog timer in a video game Power management (speed) optional 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 2 / 28

Assignment 3 Labs. 2, 3 and 4 require the “true” speed of the processor to be known. Download C++ code to “flash” the LED and then adjust a constant to get 1 second flash Need to count “Processor cycles” with Blackfin 64-bit system register (CYCLES (low-32) / CYCLES2 (high 32)) StartCyclesCountASM( ) and StopCyclesCountASM( ) provided You provide ReadCyclesCounterASM( ) 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 3 / 28

Lab. 2 Task 1 Retest equipment and code Project is provided that will retest Lab. 1 code and the Blackfin. Reuses your Lab. 1 code and your Lab. 1 Tests Project is provided that will retest your Assignment 3 code Reuses your Assignment 3 code. Assignment 3 tests are provided 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 4 / 28

Task 2 – 6-pixel Video Game void ExplainGame(void) { puts("\nWhen LED 1 is blinking, the aeroplane is under Blackfin control"); puts("\nTo show that the aeroplane crew is still awake"); puts("They must match the lights (LED 4, 3 and 2) on the LED panel"); puts(" by pushing the corresponding switches"); puts("LED 1 is ignored so you don't need to use SW1\n"); } 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 5 / 28

Task 2 – Video “game” Demonstrates the concept of “waiting for input” and associated problems Main problem – other tasks can’t be done will processor waits for your input Tests your reaction time Download C++ code main( ) and watchdog timer code (Friday’s lecture) No new code needs to be developed Makes use of your Lab. 1 and Assignment 3 code 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 6 / 28

Task 2 main( ) WatchDogTimerHowled = 0; ActivateWatchDogTimer( ); // Background interrupt task while (WatchDogTimerHowled != 1) { ResetWatchDogTimer( ); GoControlTheAeroPlane( ); // Shown by blinking LED 1 CheckIfCrewAreAwake( ); // Test response time } // Should never get here unless Watch Dog Timer 'Howled' StopWatchDogTimer( ); WriteFlashLEDASM(0); CrewErrorOccurred( ); 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 7 / 28

Task 3 -- OPTIONAL Important to be able to set microprocessor into low power mode (while waiting) and then back to high speed mode (while doing things) Dynamic Power Management (Chapter 8) means that can be done by software and not hardware changes. (Good Final Exam Q9) SO important that can be done as a “build option” when setting up your project. 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 8 / 28

Interrupt Handling – Chief issues Interrupts occur “randomly” The hardware must work to accept interrupts. The interrupt service routine must work to process the interrupts and perform the correct action The processor must be told how to handle this random event 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 9 / 28

4 things to tackle All 4 things must work the first time Highly “unlikely” Everybody using microprocessors must be able to handle interrupts and ISR Processors have special features to make the development easier Chief feature – software interrupts Temporarily remove the hardware from the development process 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 10 / 28

Task 4 – Set up a test for the software up interrupt // Hardware Manual Figure 4.5 // Get hardware interface ready // Step 1 -- set the core event (interrupt) vector table SetVectorTableLab2Task4CPP(); // Tells the processor which ISR when interrupt occurs // Step 2 -- set the SIC_IMASK -- system interrupt mask // Hardware Manual Fig PF Interrupt A SetSIC_IMASKLab2Task4ASM( ); // Step 3 -- set IMASK -- Core Interrupt Mask SetIMASKLab2Task4ASM( ); 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 11 / 28

Task 4 – Actual Test Code SetVectorTableLab2Task4CPP(); SetSIC_IMASKLab2Task4ASM( ); CHECK_VALUES(numberSW4Interrupts, ==, 0); SetIMASKLab2Task4ASM( ); StartCycleCOunterASM( ); unsigned long long int firstTimeMeasurement = ReadCycleCOunterASM( ); CauseSWI(PRETEND_GPIO_INTERRUPT); CHECK_VALUES(numberSW4Interrupts, ==, 1); 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 12 / 28

Interrupts Key issue to remember You can pass information to a subroutine using parameters passed in R0, R1, etc Passing parameters is possible as subroutines occur “when you want” as part of your code. You pass information into interrupt service routines using “semaphores” and “messages” These are “volatile” global variable 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 13 / 28

Semaphores and message to ISR extern volatile unsigned long int numberSW4Interrupts; extern volatile unsigned long long int ISRloggedTimeMeasurement[ ]; 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 14 / 28

Interrupt service routine in C++ EX_INTERRUPT_HANDLER(GPIO_INTERRUPT) { // Make the interrupt service routine software somewhat software testable by // counting the interrupts that have occurred // and, via the LED, show the "humans" that something has occurred numberSW4Interrupts = numberSW4Interrupts + 1; WriteFlashLEDASM(numberSW4Interrupts); } 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 15 / 28

Task 5 – Hardware interrupts InitGPIOFlags( ) -- Lab. 1 SetGPIOFlagsInterruptsASM( ) Modify the FIO_MASK_A register to allow interrupts to occur when you press SW4 and not when you press the other switches ClearIMASKLab2Task4ASM( ) is the opposite of SetIMask( ) – WHY NEEDED? The rest of the code uses Lab. 1 code and Task 4 code 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 16 / 28

Task 6 – Improved video game With the interrupt on SW4 working, we can now improve the “aircraft control” software to control the plane AND test the reaction time of the crew simultaneously Down load the code, and will it auto-link to Lab. 1, Assignment 3 and other tasks 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 17 / 28

Task 7 – Light sensor Wire up the 8 pin light sensor chip Info is printed in course notes Special Circuit Cellar magazine article on using light sensor for blood oxygen sensor Vcc (+5V), Ground and output Output connects to SW4 (PF11) Other pins control Light sensitivity (1, 10, 100) Frequency range 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 18 / 28

Task 7 – Light sensor Check light sensor is working using oscilloscope Light sensor outputs a +5V 50% duty cycle pulse whose frequency changes with light intensity Measure frequency at low and high light levels 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 19 / 28

Task 8 – Measure the light level Design part of the lab. We are going to display the light levels in the laboratory on a scale of 0 (dark) to 31 (brightest). The display has to respond to light levels, but the scale does not have to be linear. (Would take too long.). Your design to be done in C++ or ASM, your choice I provide a description of what I did Essentially a cut and paste job on the earlier tasks to change the names of functions from Lab2Task4XXXX( ) to Lab2Task8XXXX( ) and then change 11 lines 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 20 / 28

Task 9 – Does it really work Download the provided audio project Hook-up your ear phones and "music", and the light sensor to PF11 on the Blackfin breakout board Compile the project DoesYourLab2CodeReallyWork and run the code. You should be able to listen to the music and press switches at the same time -- same as Lab. 1 Task 9 You should be able to cover the light sensor and get the music to switch from the left channel to the right channel 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 21 / 28

Lab. 3 Replaces light sensor with temperature sensor Need to display temperature in C on the LED screen Need to print temperature every 5 seconds Treat as take-home lab. Quiz that is done during lab. Time One lab. Partner hooks sensor to PF10, and the other hooks sensor to PF9 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 22 / 28

Lab. 4 I understand what is going on at the “low level” when dealing with peripherals I would prefer NOT to code at a low level any more Using “drivers” and “services” to do DMA activity and then send message “MERRY CHRISTMAS” to an LCD screen over an SPI interface 4/25/2015 TDD-Core Timer Library, Copyright M. Smith, ECE, University of Calgary, Canada 23 / 28