Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


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

1 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

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

3 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

4 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

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

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

8 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

9 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

10 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

11 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

12 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

13 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)

14 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

15 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

16 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)

17 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

18 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

19 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

20 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

21 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

22 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

23 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

24 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)

25 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

26 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

27 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 http://www.analog.com/processors/resources/technicalLibrary/manuals/ 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.


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

Similar presentations


Ads by Google