Temperature Sensor Laboratory 2 Part 2 Developing the

Temperature Sensor Laboratory 2 Part 2 – Developing the Programmable Flags Interface Oscillator out GND 10/18/2021 Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada +5 V 1

Tackled today l What is the final laboratory product? l l Each Laboratory re-uses the code from the previous laboratory Test driven development l l Tests enable you to check that you code meets the “customer requirements” Lab. 2 details l l l 10/18/2021 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) Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 2

Lab. 2 Part 1 Blackfin BF 533 Evaluation board Assembly code Use. Fix. Time. ASM( ) Activate. Flash. ASM() Write. LEDASM( ) Reset. PFASM( ) Read. PF 8 to 11 ASM( ) Read. PFButtons. ASM( ) “C++” code Use. Fix. Time( ) Convert. Temperature( ) Flash. LED( ) Determine High. Time( ) Determine Low. Time( ) Measure. Temperature( ) 10/18/2021 PF Pins (Programmable Flags) Volume Control (Thermal sensor) Frequency Control (Thermal sensor) Timer Interrupt Mode control (Switches) Flash Memory Parallel Port Mode information (LEDs) SPI – Serial Parallel Interface LCD screen (Notes and Tempo) CODEC Input And Output Audio In (Synthesizer) Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada Audio Out (Ear-phones) 3

Need to control in Lab. 2 Two stages l Output – Lab. 2 Part 1 l l l Activate Flash memory parallel interface – External device to ADSP-BF 533 Use Flash parallel interface to control LEDs – part of user interface Input – Lab. 2 Part 2 l l l 10/18/2021 Activate programmable flag (PF) interface – Internal part of ADSP-BF 533 Use PF pins + switches to control program – part of user interface Use PF pins + temperature sensor – input transducer – sensor Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 4

Lab. 2 Part 2 Blackfin BF 533 Evaluation board Assembly code Use. Fix. Time. ASM( ) Activate. Flash. ASM() Write. LEDASM( ) Reset. PFASM( ) Read. PF 8 to 11 ASM( ) Read. PFButtons. ASM( ) “C++” code Use. Fix. Time( ) Convert. Temperature( ) Flash. LED( ) Determine High. Time( ) Determine Low. Time( ) Measure. Temperature( ) 10/18/2021 PF Pins (Programmable Flags) Volume Control (Thermal sensor) Frequency Control (Thermal sensor) Timer Interrupt Mode control (Switches) Flash Memory Parallel Port Mode information (LEDs) SPI – Serial Parallel Interface LCD screen (Notes and Tempo) CODEC Input And Output Audio In (Synthesizer) Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada Audio Out (Ear-phones) 5

Laboratory interface PF Interface SPI Interface GND Pins Flash Memory Interface LEDS Logic Lab station TEMP SENSOR TMP 03 10/18/2021 SWITCHES Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 6

Code Interface l Customer Test Suite l l Code interface l l l Customer. Test. PFInterface. doj ushort Reset. PF 8 to 11 For. Input. ASM(bool active. High); ushort Read. PF 8 to 11 ASM(void); ushort Read. Buttons. ASM(void); void Flash. LEDAnd. Waste. Time. Demo(void); unsigned int Wait. Till. High( ) , unsigned int Wait. Till. Low( ) unsigned Measure. High. Time( ), unsigned Measure. Low. Time( ) temperature 4 Measure. Temperature(const unsigned short) Step 1 l l 10/18/2021 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 Use. Fixed. Time. ASM( ) ) Since only stubs – expect that all the tests will fail. This is just a test that the calls and the interface are correct. Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 7

Temperature Sensor +5 V GROUND SIGNAL TO BLACKFIN HIGH 10/18/2021 ANALOG DEVICES TMP 03 Temperature Sensor LOW Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 8

Convert. Temperature(LOW, HIGH, Cor. F) l Need to know how long the temperature sensor is low l l unsigned Measure. Low. Time( ) Need to know how long the temperature sensor is high unsigned Measure. High. Time( ) l Need to develop two routines l l 10/18/2021 ushort Wait. Till. Low( ) – this returns the time until the temperature sensor voltage level goes low ushort Wait. Till. High( ) – this returns the time until the temperature sensor voltage level goes low These routines use the routine Use. Fixed. Time( ) you developed in Lab. 1 Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 9

Pseudo code for ushort Wait. Till. Low( ) { ushort count = 0; ushort value; value = Read Voltage. Level of Temperature Sensor ( ); while (value = = High Voltage) { count++; Use. Fixed. Time( SOMEVALUE); // Use this routine to use up fixed time value = Read Voltage. Level of Temperature Sensor ( ); } return count; } 10/18/2021 HIGH LOW Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 10

WRONG Pseudo code for unsigned Measure. Low. Time( ) ushort Measure. Low. Time( ) { RIGHT ANSWER IF START MEASURING HERE ushort count = 0; ushort value; WRONG ANSWER IF START MEASURING HERE } HIGH 10/18/2021 Wait. Till. Low( ); count = Wait. Till. High( ); return count; LOW Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 11

RIGHT Pseudo code for unsigned Measure. Low. Time( ) ushort Measure. Low. Time( ) { RIGHT ANSWER IF START MEASURING HERE ushort count = 0; ushort value; Wait. Till. High( ); Wait. Till. Low( ); RIGHT ANSWER IF START MEASURING HERE count = Wait. Till. High( ); return count; } HIGH 10/18/2021 LOW Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 12

Code Interface l Customer Test Suite l l Customer. Test. PFInterface. doj Code interface l l l ushort Reset. PF 8 to 11 For. Input. ASM(bool active. High); ushort Read. PF 8 to 11 ASM(void); void Flash. LEDAnd. Waste. Time. Demo(void); unsigned int Wait. Till. High( ) , unsigned int Wait. Till. Low( ) unsigned Measure. High. Time( ), unsigned Measure. Low. Time( ) temperature 4 Measure. Temperature(const unsigned short) l 10/18/2021 Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 13

Laboratory interface PF Interface SPI Interface TEMP SENSOR TMP 03 10/18/2021 GND Pins Flash Memory Interface Switches used to select Centigrade or Fahrenheit or when to stop the program SWITCHES Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 14

Programmable Flags l Series of 16 lines that connect DIRECTLY to the Blackfin CORE processor – input, output or inactive l l l 10/18/2021 PF 11 – used to read the temperature sensor voltage PF 10 – used to signal “quit” the program (+5 V is quit) PF 09 – used to signal choice of “Centigrade / Fahrenheit (+5 V is centigrade) PF 08 – used to signal “read new temperature” (one reading every time the switch is set to +5 V – 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 Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 15

Registers used to control PF pins ushort Reset. PF 8 to 11 For. Input. ASM(bool active. High); • Flag Direction register (FIO_DIR) l l l Flag Input Enable Register l l l Used to determine if the PF bit is to be used for input or output If handled incorrectly – can burn out the processor 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) 10/18/2021 Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 16

Registers used to control PF pins l Flag l l 10/18/2021 Direction register (FIO_DIR) Used to determine if the PF bit is to be used for input or output Need to set pins PF 11 to PF 8 for input, leave all other pins unchanged Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 17

Registers used to control PF pins l Flag l l 10/18/2021 Input Enable Register Only activate the pins you want to use (saves power in telecommunications situation) Need to activate pins PF 11 to PF 8 for input, leave all other pins unchanged Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 18

Registers used to control PF pins l Flag l 10/18/2021 Polarity Register (FIO_POLAR) Set pins PF 11 to PF 8 for active HIGH, leave all other pins unchanged Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 19

Typical code l l l Set index register P 0 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 10/18/2021 Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 20

Example code using masks P 0. H = hi(FIO_POLAR) P 0. L = lo(FIO_POLAR) // Get the address into P 0 R 1 = W[P 0] (Z); // Read the 16 -bit FIO_POLAR Register // Why use R 1 and not R 0? #define PF 8 to 11_Polar. Clear. Mask 0 x. F 0 FF R 2 = PF 8 to 11_Polar. Clear. Mask (Z) R 1 = R 2 & R 1 // Now PF 8 to PF 11 = 0, nothing else changes // R 0 (in-param) contains whether active High or active low is needed #define PF 8 to. PF 11_Active. HIGH 0 x 0000 #define PF 8 to. PF 11_Active. LOW 0 x 0 F 00 CC = R 0 = = 1 IF CC R 2 = PF 8 to. PF 11_Active. HIGH IF !CC R 2 = PF 8 to. PF 11_Active. LOW R 1 = R 1 | R 2; // Set PF 8 to PF 11, nothing else changes W[P 0] = R 1. L // Reset the register Labs in ENCM 415. Laboratory 2 PF control, SSYNC 10/18/2021 Copyright M. Smith, ECE, University of Calgary, Canada 21

Registers used to control PF pins l Flag Data register (FIO_FLAG_D) l l 10/18/2021 Used to read the PF bits (1 or 0) Need to read pins PF 11 to PF 8, ignore all other pins values Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 22

ushort Read. PF 8 to 11 ASM(void); l This routine reads the value of all the pins l Discard (mask out) all the values other than PF 8 to PF 11 l Shift the bit values down by 8 bits so that the 4 bits PF 8 to PF 11 form a 4 -bit number (Bits 3, 2, 1, 0) that you can use as a value 10/18/2021 Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 23

Tackled Today -- Code Interface l Customer Test Suite l l Customer. Test. PFInterface. doj Code interface l l ushort Reset. PF 8 to 11 For. Input. ASM(bool active. High); ushort Read. PF 8 to 11 ASM(void); ushort Read. Buttons. ASM(void); void Flash. LEDAnd. Waste. Time. Demo(void); unsigned int Wait. Till. High( ) , unsigned int Wait. Till. Low( ) unsigned Measure. High. Time( ), unsigned Measure. Low. Time( ), temperature 4 Measure. Temperature(const unsigned short) 10/18/2021 Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 24

Problems -- key for mid-term and final when dealing with switching levels ushort Measure. Low. Time( ) { RIGHT ANSWER IF START MEASURING HERE ushort count = 0; ushort value; Wait. Till. High( ); Wait. Till. Low( ); RIGHT ANSWER IF START MEASURING HERE count = Wait. Till. High( ); return count; } HIGH 10/18/2021 LOW Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 25

Sample mid-term problem l To 10/18/2021 come Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 26

l Information taken from Analog Devices On-line Manuals with permission http: //www. analog. com/processors/resources/technical. Library/manuals/ l 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. 10/18/2021 Labs in ENCM 415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada 27
- Slides: 27