6/2/2015 labs in encm415. laboratory 2 pf control, copyright m. smith, ece, university of calgary,...
Post on 18-Dec-2015
212 views
TRANSCRIPT
04/18/23 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
2 / 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)
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
3 / 26
Lab. 2 Part 1Blackfin BF533
Evaluation board
Assembly codeUseFixTimeASM( )
ActivateFlashASM()WriteLEDASM( )
ResetPFASM( )ReadPF8to11ASM( )
ReadPFButtonsASM( )
“C++” codeUseFixTime( )
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 MemoryParallel Port
SPI – SerialParallel Interface
CODECInputAnd
Output
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
4 / 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
5 / 26
Lab. 2 Part 2Blackfin BF533
Evaluation board
Assembly codeUseFixTimeASM( )
ActivateFlashASM()WriteLEDASM( )
ResetPFASM( )ReadPF8to11ASM( )
ReadPFButtonsASM( )
“C++” codeUseFixTime( )
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 MemoryParallel Port
SPI – SerialParallel Interface
CODECInputAnd
Output
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
6 / 26
Laboratory interface
PF Interface
SPIInterface
GNDPins
FlashMemoryInterface
Logic Lab station
LEDS
SWITCHESTEMP
SENSORTMP03
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
7 / 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.
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
8 / 26
Temperature Sensor
ANALOG DEVICESTMP03
Temperature Sensor
+5V
GROUND
SIGNAL TO BLACKFIN
HIGH LOW
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
9 / 26
ConvertTemperature(LOW, HIGH, CorF)
Need to know how long the temperature sensor is lowunsigned MeasureLowTime( )
Need to know how long the temperature sensor is highunsigned 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
10 / 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
11 / 26
WRONGPseudo code for unsigned MeasureLowTime( )
ushort MeasureLowTime( ) {
ushort count = 0; ushort value;
WaitTillLow( ); count = WaitTillHigh( ); return count;}
HIGH LOW
RIGHT ANSWERIF START MEASURING HERE
WRONG ANSWERIF START MEASURING HERE
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
12 / 26
RIGHTPseudo code for unsigned MeasureLowTime( )
ushort MeasureLowTime( ) {
ushort count = 0; ushort value;
WaitTillHigh( ); WaitTillLow( );
count = WaitTillHigh( ); return count;}
HIGH LOW
RIGHT ANSWERIF START MEASURING HERE
RIGHT ANSWERIF START MEASURING HERE
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
13 / 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)
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
14 / 26
Laboratory interface
PF Interface
SPIInterface
GNDPins
FlashMemoryInterface
SWITCHESTEMP
SENSORTMP03
Switches used to selectCentigrade or Fahrenheit
or when to stop the program
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
15 / 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
16 / 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)
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
17 / 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
18 / 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
19 / 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
20 / 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
21 / 26
Example code using masksP0.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 0xF0FFR2 = 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 0x0F00CC = R0 = = 1IF CC R2 = PF8toPF11_ActiveHIGHIF !CC R2 = PF8toPF11_ActiveLOWR1 = R1 | R2; // Set PF8 to PF11, nothing else changesW[P0] = R1.L // Reset the registerSSYNC
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
22 / 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
23 / 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
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
24 / 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)
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
25 / 26
Problems -- key for mid-term and finalwhen dealing with switching levels
ushort MeasureLowTime( ) {
ushort count = 0; ushort value;
WaitTillHigh( ); WaitTillLow( );
count = WaitTillHigh( ); return count;}
HIGH LOW
RIGHT ANSWERIF START MEASURING HERE
RIGHT ANSWERIF START MEASURING HERE
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
26 / 26
Sample mid-term problem
To come
04/18/23 Labs in ENCM415. Laboratory 2 PF control, Copyright M. Smith, ECE, University of Calgary, Canada
27 / 26
Information taken from Analog Devices On-line Manuals with permission 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.