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.

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

Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Assignment Overview Thermal oscillator One of the ENCM415 Laboratory 2 items Oscillator out GND +5V.
Boot Issues Processor comparison TigerSHARC multi-processor system Blackfin single-core.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Daddy! -- Where do instructions come from? Program Sequencer controls program flow and provides the next instruction to be executed Straight line code,
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.
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.
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.
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.
Developing a bicycle speed-o-meter A comparison between the Analog Devices ADSP-BF533 (Blackfin) and Motorola MC68332.
Timers and Timing Signals Tutorial. 6/18/2015 Timer Control Copyright M. Smith, ECE, University of Calgary, Canada 2 / 31 Temperature Sensor -- Lab 3.
6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 1 Laboratories in ENCM415 Also tackled Controlling.
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.
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.
Laboratory 1 – ENCM415 Familiarization with the Analog Devices’ VisualDSP++ Integrated Development Environment.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
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.
Blackfin BF533 EZ-KIT Control The O in I/O
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.
Input Laboratory: GPIO Pin control needed to have the Blackfin accept your commands Re-uses information from ENEL353 and ENCM369 courses and text books.
Blackfin Timers Independent timers build into the processor Watchdog Timer is a major part of Lab. 2 (Code provided to you to use)
Over-view of Lab. 1 See the Lab. 1 web-site and later lecture notes for more details.
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
Lab. 1 – Required Tasks. For more details – see the Lab. 1 web-site.
Over-view of Lab. 1 See the Lab. 1 web-site and the lecture notes for more details.
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. 1 – GPIO Pin control Using information ENEL353 and ENCM369 text books combined with Blackfin DATA manual.
Over-view of Lab. 1 See the Lab. 1 web-site and latter lecture notes for more details.
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.
See the Lab. 1 web-site and later lecture notes for more details
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.
SPI Compatible Devices
Thermal arm-wrestling
DMA example Video image manipulation
The planned and expected
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.
Thermal arm-wrestling
Using Arrays Completion of ideas needed for a general and complete program Final concepts needed for Final.
See the Lab. 1 web-site and later lecture notes for more details
Moving Arrays -- 2 Completion of ideas needed for a general and complete program Final concepts needed for Final DMA.
Expand on these ideas for Q9 question and answer on the final
Thermal arm-wrestling
Concept of TDD Test Driven Development
Blackfin Timers Independent timers build into the Blackfin
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
Input Laboratory: GPIO Pin control needed to have the Blackfin accept your commands Re-uses information from ENEL353 and ENCM369 courses and text books.
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
Developing a reliable communication between Blackfin and Slave device
Blackfin Syntax Stores, Jumps, Calls and Conditional Jumps
Presentation transcript:

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 the Programmable Flags Interface Oscillator out GND +5V

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada2 / 26 Tackled today What is the final laboratory product? Each Laboratory re-uses the code from the previous laboratory Test driven development Tests enable you to check that you code meets the “customer requirements” Lab. 2 details Flash Memory interface – parallel port to control system mode display (LED) Programmable Flags – parallel port for temperature sensor and system mode control (switches) Code needed (Re-used and new)

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada3 / 26 Lab. 2 Part 1 Blackfin BF533 Evaluation board Assembly code UseFixTimeASM( ) ActivateFlashASM() WriteLEDASM( ) ResetPFASM( ) ReadPF8to11ASM( ) ReadPFButtonsASM( ) “C++” code UseFixTime( ) ConvertTemperature( ) FlashLED( ) Determine HighTime( ) Determine LowTime( ) MeasureTemperature( ) Volume Control (Thermal sensor) Frequency Control (Thermal sensor) LCD screen (Notes and Tempo) Mode control (Switches) Mode information (LEDs) Audio In (Synthesizer) Audio Out (Ear-phones) PF Pins (Programmable Flags) Timer Interrupt Flash Memory Parallel Port SPI – Serial Parallel Interface CODEC Input And Output

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada4 / 26 Need to control in Lab. 2 Two stages Output – Lab. 2 Part 1 Activate Flash memory parallel interface – External device to ADSP-BF533 Use Flash parallel interface to control LEDs – part of user interface Input – Lab. 2 Part 2 Activate programmable flag (PF) interface – Internal part of ADSP-BF533 Use PF pins + switches to control program – part of user interface Use PF pins + temperature sensor – input transducer – sensor

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada5 / 26 Lab. 2 Part 2 Blackfin BF533 Evaluation board Assembly code UseFixTimeASM( ) ActivateFlashASM() WriteLEDASM( ) ResetPFASM( ) ReadPF8to11ASM( ) ReadPFButtonsASM( ) “C++” code UseFixTime( ) ConvertTemperature( ) FlashLED( ) Determine HighTime( ) Determine LowTime( ) MeasureTemperature( ) Volume Control (Thermal sensor) Frequency Control (Thermal sensor) LCD screen (Notes and Tempo) Mode control (Switches) Mode information (LEDs) Audio In (Synthesizer) Audio Out (Ear-phones) PF Pins (Programmable Flags) Timer Interrupt Flash Memory Parallel Port SPI – Serial Parallel Interface CODEC Input And Output

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada6 / 26 Laboratory interface PF Interface SPI Interface GND Pins Flash Memory Interface Logic Lab station LEDS SWITCHES TEMP SENSOR TMP03

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada7 / 26 Code Interface Customer Test Suite CustomerTestPFInterface.doj Code interface ushort ResetPF8to11ForInputASM(bool activeHigh); ushort ReadPF8to11ASM(void); ushort ReadButtonsASM(void); void FlashLEDAndWasteTimeDemo(void); unsigned int WaitTillHigh( ), unsigned int WaitTillLow( ) unsigned MeasureHighTime( ), unsigned MeasureLowTime( ) temperature4 MeasureTemperature(const unsigned short) Step 1 Develop the ASM stubs so that you can compile, link, and run the tests linked to PFtest.doj (These stubs can be built by cut-and-pasting from the file containing UseFixedTimeASM( ) ) Since only stubs – expect that all the tests will fail. This is just a test that the calls and the interface are correct.

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada8 / 26 Temperature Sensor ANALOG DEVICES TMP03 Temperature Sensor +5V GROUND SIGNAL TO BLACKFIN HIGH LOW

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada9 / 26 ConvertTemperature(LOW, HIGH, CorF) Need to know how long the temperature sensor is low unsigned MeasureLowTime( ) Need to know how long the temperature sensor is high unsigned MeasureHighTime( ) Need to develop two routines ushort WaitTillLow( ) – this returns the time until the temperature sensor voltage level goes low ushort WaitTillHigh( ) – this returns the time until the temperature sensor voltage level goes low These routines use the routine UseFixedTime( ) you developed in Lab. 1

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada10 / 26 Pseudo code for ushort WaitTillLow( ) ushort WaitTillLow( ) { ushort count = 0; ushort value; value = Read VoltageLevel of Temperature Sensor ( ); while (value = = High Voltage) { count++; UseFixedTime( SOMEVALUE); // Use this routine to use up fixed time value = Read VoltageLevel of Temperature Sensor ( ); } return count; } HIGH LOW

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada11 / 26 WRONG Pseudo code for unsigned MeasureLowTime ( ) ushort MeasureLowTime( ) { ushort count = 0; ushort value; WaitTillLow( ); count = WaitTillHigh( ); return count; } HIGH LOW RIGHT ANSWER IF START MEASURING HERE WRONG ANSWER IF START MEASURING HERE

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada12 / 26 RIGHT Pseudo code for unsigned MeasureLowTime ( ) ushort MeasureLowTime( ) { ushort count = 0; ushort value; WaitTillHigh( ); WaitTillLow( ); count = WaitTillHigh( ); return count; } HIGH LOW RIGHT ANSWER IF START MEASURING HERE RIGHT ANSWER IF START MEASURING HERE

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada13 / 26 Code Interface Customer Test Suite CustomerTestPFInterface.doj Code interface ushort ResetPF8to11ForInputASM(bool activeHigh); ushort ReadPF8to11ASM(void); void FlashLEDAndWasteTimeDemo(void); unsigned int WaitTillHigh( ), unsigned int WaitTillLow( ) unsigned MeasureHighTime( ), unsigned MeasureLowTime( ) temperature4 MeasureTemperature(const unsigned short)

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada14 / 26 Laboratory interface PF Interface SPI Interface GND Pins Flash Memory Interface SWITCHES TEMP SENSOR TMP03 Switches used to select Centigrade or Fahrenheit or when to stop the program

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada15 / 26 Programmable Flags Series of 16 lines that connect DIRECTLY to the Blackfin CORE processor – input, output or inactive PF11 – used to read the temperature sensor voltage PF10 – used to signal “quit” the program (+5V is quit) PF09 – used to signal choice of “Centigrade / Fahrenheit (+5V is centigrade) PF08 – used to signal “read new temperature” (one reading every time the switch is set to +5V – not multiple readings. Other PF pins are in use (some as input and some as output) to control the video and audio devices etc on the board. These bit values must be left UNCHANGED

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada16 / 26 Registers used to control PF pins ushort ResetPF8to11ForInputASM(bool activeHigh); Flag Direction register (FIO_DIR) Used to determine if the PF bit is to be used for input or output If handled incorrectly – can burn out the processor Flag Input Enable Register Only activate the pins you want to use (saves power in telecommunications situation) Flag Polarity Register (FIO_POLAR) Flag Interrupt Sensitivity Register (FIO_EDGE) Flag Mask Interrupt Registers (8 of these) Warning – there is a latency of 3 system clock cycles before any changes in PF pins can be detected by the processor (important for very fast signals (200 MHz)

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada17 / 26 Registers used to control PF pins Flag Direction register (FIO_DIR) Used to determine if the PF bit is to be used for input or output Need to set pins PF11 to PF8 for input, leave all other pins unchanged

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada18 / 26 Registers used to control PF pins Flag Input Enable Register Only activate the pins you want to use (saves power in telecommunications situation) Need to activate pins PF11 to PF8 for input, leave all other pins unchanged

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada19 / 26 Registers used to control PF pins Flag Polarity Register (FIO_POLAR) Set pins PF11 to PF8 for active HIGH, leave all other pins unchanged

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada20 / 26 Typical code Set index register P0 to point to memory mapped register Read the value of the register Make bits 11, 10, 9, 8 zero but leave all other bits unchanged (AND MASK operation) Set bits 11, 10, 9, 8 to the correct values but leave all other bits unchanged (OR MASK operation) Write back the value of the register Remember the wrong values into the register can cause the processor core to be destroyed – so check your code carefully

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada21 / 26 Example code using masks P0.H = hi(FIO_POLAR) P0.L = lo(FIO_POLAR) // Get the address into P0 R1 = W[P0] (Z); // Read the 16-bit FIO_POLAR Register // Why use R1 and not R0? #define PF8to11_PolarClearMask 0xF0FF R2 = PF8to11_PolarClearMask (Z) R1 = R2 & R1 // Now PF8 to PF11 = 0, nothing else changes // R0 (in-param) contains whether active High or active low is needed #define PF8toPF11_ActiveHIGH 0x0000 #define PF8toPF11_ActiveLOW 0x0F00 CC = R0 = = 1 IF CC R2 = PF8toPF11_ActiveHIGH IF !CC R2 = PF8toPF11_ActiveLOW R1 = R1 | R2; // Set PF8 to PF11, nothing else changes W[P0] = R1.L // Reset the register SSYNC

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada22 / 26 Registers used to control PF pins Flag Data register (FIO_FLAG_D) Used to read the PF bits (1 or 0) Need to read pins PF11 to PF8, ignore all other pins values

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada23 / 26 ushort ReadPF8to11ASM(void); This routine reads the value of all the pins Discard (mask out) all the values other than PF8 to PF11 Shift the bit values down by 8 bits so that the 4 bits PF8 to PF11 form a 4-bit number (Bits 3,2, 1, 0) that you can use as a value

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada24 / 26 Tackled Today -- Code Interface Customer Test Suite CustomerTestPFInterface.doj Code interface ushort ResetPF8to11ForInputASM(bool activeHigh); ushort ReadPF8to11ASM(void); ushort ReadButtonsASM(void); void FlashLEDAndWasteTimeDemo(void); unsigned int WaitTillHigh( ), unsigned int WaitTillLow( ) unsigned MeasureHighTime( ), unsigned MeasureLowTime( ), temperature4 MeasureTemperature(const unsigned short)

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada25 / 26 Problems -- key for mid-term and final when dealing with switching levels ushort MeasureLowTime( ) { ushort count = 0; ushort value; WaitTillHigh( ); WaitTillLow( ); count = WaitTillHigh( ); return count; } HIGH LOW RIGHT ANSWER IF START MEASURING HERE RIGHT ANSWER IF START MEASURING HERE

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada26 / 26 Sample mid-term problem To come

6/2/2015 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada27 / 26 Information taken from Analog Devices On-line Manuals with permission 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.