Timers and Timing Signals Tutorial. 6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 2 / 31 Temperature Sensor -- Lab 3.

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

Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
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.
Boot Issues Processor comparison TigerSHARC multi-processor system Blackfin single-core.
The planned but unexpected Program Sequencer controls program flow and provides the next instruction to be executed Interrupt – causing and handling.
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.
Developing a bicycle speed-o-meter Part 2 A comparison between the Analog Devices ADSP-BF533 (Blackfin) and Motorola MC68332.
Review of Blackfin Syntax Moves and Adds 1) What we already know and have to remember to apply 2) What we need to learn.
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.
LCD programming Design and implementation details on the way to a valid SPI-LCD interface driver.
Developing a bicycle speed-o-meter A comparison between the Analog Devices ADSP-BF533 (Blackfin) and Motorola MC68332.
Understanding the Blackfin ADSP-BF5XX Assembly Code Format
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.
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.
System Clocks.
Blackfin Timers Independent timers build into the processor Watchdog Timer is a major part of Lab. 2 (Code provided to you to use)
M. Smith University of Calgary.  Many people like to sing in the shower.  However, its rather boring as there is no accompaniment.  The McVASH device.
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.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
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.
8254 Timer.
The right and wrong ways for constructing tasks for the Labs and Assignment.
Handling multiple input signals Version #2 – co-operative scheduler Version #3 – pre-emptive scheduler.
A first attempt at learning about optimizing the TigerSHARC code TigerSHARC assembly syntax.
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.
A Play Core Timer Interrupts Acted by the Human Microcontroller Ensemble from ENCM415.
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.
Programmable Interval Timer 8254 LECTURE 3
Developing a bicycle speed-o-meter
Lab. 2 Overview.
A Play Core Timer Interrupts
Thermal arm-wrestling
Programmable Interval timer 8253 / 8254
The planned and expected
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
Programmable Interval timer 8253 / 8254
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.
General purpose timers
Thermal arm-wrestling
Blackfin Timers Independent timers build into the Blackfin
Independent timers build into the processor Basis for Lab. 2
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
Lab. 2 Overview Move the tasks you developed in Lab. 1 into the more controllable TTCOS operating system.
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
Post Lab Quiz 3 Review Assignment 2 Help
Blackfin Syntax Moves and Adds
Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps
Presentation transcript:

Timers and Timing Signals Tutorial

6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 2 / 31 Temperature Sensor -- Lab 3 “event driven Schedule. How can you time “High” time? ANALOG DEVICES TMP03 Temperature Sensor +5V GROUND SIGNAL TO BLACKFIN -- hook into PF8 (SW1). Check using the same “when switch SW1 pressed, when released” code as in Lab. 1 SIGNAL FROM TMP03 has this shape HIGH LOW

6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 3 / 31 Counting amount of time thermal sensor signal is high while (1) { int countHigh = 0; // Why must this be inside and not outside the loop int countLo = 0; while (SW1 is high) /* do nothing */; while (SW1 is low) / * do nothing */; // Get to the START of the low-to-high transition while (SW1 is high) { // Relative time high UseUpTime( ); countHigh++; } while (SW1 is low) { // Relative time high UseUpTime( ); countLo++; } int temperature = CalculateTemperature(countHigh, countLow); DisplayTemperatureOnLEDs(temperature); } Uses same ASM files For reading PF flags as in Lab. 1 Uses WriteLEDASM( ) 4 while loops needed – NOT 2 (key lab / exam concept)

6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 4 / 31 A C++ version of code -- based on “ (interval counter) Develop a routine UseUpFixedAmountTimeCPP( ) that uses up a fixed amount of time Use ReadLEDASM( ) to find when input signal goes high When input goes high, call this Interval Counter routine Keep calling the Interval counter until the input goes low Count how many times this routine must be called from main( ) while the temperature signal is HIGH Could be constructed using “for-loop” construct void UseUpFixedAmoutTimeCPP(unsigned long int timeToUse) { unsigned short int counter = 0; for (int num = 0; num <= timeToUse; num ++) { counter = counter; // Waste time } // Spin the wheels on the processor Post Lab. 1 Question – how would you use ReadLEDASM( ) to wait until the input signal goes high – Do in either C++ or assembly code.

6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 5 / 31 Core Timer You set Core timer register TSCALE to 0 (decrement by 0 + 1) You set register TPERIOD to 0x2000 You set register TCOUNT to 0x4000 You enable timer using control register TCNTL TCOUNT is decreased by 1 until it reaches 0 (0x4000 system clock ticks) When TCOUNT reaches 1, interrupt is caused and TCOUNT is reloaded with TPERIOD (0x2000) – counts down again

6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 6 / 31 Improved “more accurate” Timer to provide “more accurate” Temperatures void UseUpFixedAmountTime(unsigned long int timeToUse) { 1.Load the core timer counter register with parameter “time_to_use” 2.Start the core timer – which causes the core-timer register to count down to zero 3.While the core timer counter register ! = 0 continue counter 4. When the core timer count register equals 0 -- Return } Core timer changes at 500 MHz – so can get very accurate timing values

6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 7 / 31 TCOUNT and TPERIOD registers

6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 8 / 31 Improved “more accurate” Timer to provide “more accurate” Temperatures void UseUpFixedAmountTime(unsigned long int timeToUse) { 1.Load the core timer counter register with parameter “time_to_use” 2.Start the core timer – which causes the core-timer register to count down to zero 3.While the core timer counter register ! = 0 continue counter 4. When the core timer count register equals 0 -- Return } Core timer changes at 500 MHz – so can get very accurate timing values