Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


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

1 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 LEDs in Lab. 2

2 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 2 Tackled today  What is the final laboratory product? Each Laboratory re-uses the code from the previous laboratoryEach Laboratory re-uses the code from the previous laboratory Test driven developmentTest driven development  Tests enable you to check that your code meets the “minimum customer requirements” Lab. 2 detailsLab. 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/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 3 Long term Laboratory interfacing goals  Lab. 1 – VisualDSP++ development environment Simple “C++” and “.asm” function formatsSimple “C++” and “.asm” function formats Develop, code, compile / assemble, link and runDevelop, code, compile / assemble, link and run Test Driven Development, testing of assignment 1 code for re- use in other labs.Test Driven Development, testing of assignment 1 code for re- use in other labs.  Lab. 2 – Simple Temperature sensor Input – programmable flag pins – PF pinsInput – programmable flag pins – PF pins Output – LED connected to parallel interface on FLASH memoryOutput – LED connected to parallel interface on FLASH memory Uses andUses ConvertTemperature( ) and UseFixedTimeASM( )  Lab. 3 – More accurate Temperature sensor Cycle accurate Timer interrupts, PF interruptsCycle accurate Timer interrupts, PF interrupts  Lab. 4 – Controlling LCD screen SPI – serial parallel interfaceSPI – serial parallel interface Simple graphics program on LCD screenSimple graphics program on LCD screen  Lab. 5 – Thermally controlled musical instrument One of many options – the ThereminOne of many options – the Theremin

4 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 4 Lab. 5 Final product Blackfin BF533 Evaluation Board Assembly code (Driving the hardware) “C++” code (Handling the data management) 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

5 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 5 Lab. 2 Final product 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/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 6 Need to control in Lab. 2 Two stages  Output Activate Flash memory parallel interface – External device to ADSP-BF533Activate Flash memory parallel interface – External device to ADSP-BF533 Use Flash parallel interface to control LEDs – part of user interfaceUse Flash parallel interface to control LEDs – part of user interface  Input Activate programmable flag (PF) interface – Internal part of ADSP-BF533Activate programmable flag (PF) interface – Internal part of ADSP-BF533 Use PF pins + switches to control program – part of user interfaceUse PF pins + switches to control program – part of user interface Use PF pins + temperature sensor – input transducer – sensorUse PF pins + temperature sensor – input transducer – sensor

7 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 7 Laboratory interface PF Interface SPI Interface GND Pins Flash Memory Interface Also needed ADSP-BF533 microcontroller EZ-LITE Kit with protection interface added VisualDSP++ Development Environment In circuit emulator (ICE) – USB or JTAG Logic Lab station (Switches and LEDs) Analog Devices TMP03 temperature sensor Wires, student common sense and a willingness to believe that it can be done REMEMBER – you MUST come to the laboratory with draft versions of the code worked out and ready for testing

8 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 8 Laboratory interface PF Interface SPI Interface GND Pins Flash Memory Interface Logic Lab station Logic Lab Station MAKE SURE THAT YOU CONNECT WIRES CORRECTLY TO AVOID DESTROYING ADSP-BF533 7 WIRES NEEDED LEDS

9 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 9 The “real interface” Blackfin Board Clamping circuit – an attempt to protect the 3V Blackfin pins The interface you’ll see 4 PF input pins 4 SPI pins (I/O) 4 GROUND PINS 6 LED output pins LOGIC LAB LED LOGIC LAB LED INPUT PINS LOGIC LAB GROUND PIN GROUND WIRE

10 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 10 Code Interface  Customer Test Suite CustomerTestFlashMemoryInterface.dojCustomerTestFlashMemoryInterface.doj  Code interface void ActivateFlashLEDOutputASM(void); void WriteLEDASM(unsigned short int);void ActivateFlashLEDOutputASM(void); void WriteLEDASM(unsigned short int);  Step 1 Develop the ASM stubs so that you can compile, link, and run the tests linked to flashtest.doj (These stubs can be built by cut-and-pasting from the file containing UseFixedTimeASM( ) )Develop the ASM stubs so that you can compile, link, and run the tests linked to flashtest.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.Since only stubs – expect that all the tests will fail. This is just a test that the calls and the interface are correct.

11 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 11 ActivateFlashLEDOutputASM(void);  This is always the same code At this point in time, cut and paste code from Analog Devices Examples found atAt this point in time, cut and paste code from Analog Devices Examples found at C:\Program Files\Analog Devices\VisualDSP 3.5 16- Bit\Blackfin\EZ-Kits\ADSP-BF533\Examples\Blink\ASM Warning – more information than you need in these files so use the following link http://www.enel.ucalgary.ca/People/Smith/2004webs/encm415_04/ 04Labs/Lab2/LowLevelInformation/T3_ActivateFlashLEDOutput.htm

12 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 12 Key code elements  Need to understand the concept of what is happening Format of codeFormat of code New instructionsNew instructions What is happeningWhat is happening  Later need to understand the details of what is happening

13 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 13 Header information  #include  #include .global Flash_Setup;  /*****************************/  #define CFG_FLASH 0x1 // configure flash flag  #define en_async_mem 0xf // field in asynch mem ctrl reg  #define amb0_timing 0x7bb0  #define amb1_timing 0x7bb0  #define amb2_timing 0x7bb0  #define amb3_timing 0x7bb0  #define flashA_sram 0x20240000// base addr  #define flashA_csio 0x20270000// base addr  #define portA_data_out 0x04// offset  #define portB_data_out 0x05// offset  #define portA_data_dir 0x06// offset  #define portB_data_dir 0x07// offset   This include file contains important defines of the Blackfin Memory Mapped Registers and other important stuff   Various flash memory specific information   Starting address of the 2 components of the flash memory   Offsets to specific internal registers of the flash memory parallel ports – note DATA REGISTER DATA DIRECTION REGISTER

14 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 14 Words used that we need to understand in detail later  Starting address of a device Absolute addressAbsolute address Why needed?Why needed? How is it determined in “real life”?How is it determined in “real life”?  Device register offset Relative addressRelative address Why needed?Why needed? How is it determined in “real life”?How is it determined in “real life”?

15 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 15 Next part of cut-and-paste code Flash_Setup: // set asynch mem timing registers p0.h = hi(EBIU_AMBCTL0); p0.l = lo(EBIU_AMBCTL0); r0.l = amb0_timing; r0.h = amb1_timing; [p0] = r0; ssync; p0.h = hi(EBIU_AMBCTL1); p0.l = lo(EBIU_AMBCTL1); r0.l = amb2_timing; r0.h = amb3_timing; [p0] = r0; ssync;   Establish the high and low values of an address in an index register Same concept as on a MIPs processor except that detail in different   Note Set the high and low parts of the data register to different values (2 16-bit operations) Then store the whole 32-bit register at one go -- fast   New instruction Ssync   System synchronization -- We must make sure that the instruction is completed to the hardware before making further changes

16 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 16 More concepts in code // set asynch mem global ctrl reg p0.h = hi(EBIU_AMGCTL); p0.l = lo(EBIU_AMGCTL); r0.l = w[p0]; r1 = en_async_mem; r0 = r0 | r1; w[p0] = r0; // enable asynch mem ssync;  New instruction Read a 16-bit value  New instruction Logical OR of two data registers together – same format as C++ NOTE – for some reason this is done in 32-bit format and NOT 16-bit format – WHY?  New instruction Write a 16-bit value

17 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 17 Further info  This code looks specific to the LED control // initialize flash A csio regs (port A and B) // clear data registers // clear data registers p1.h = hi(flashA_csio); p1.l = lo(flashA_csio) + portA_data_out; r0 = 0x0; w[p1] = r0; ssync; // direction control registers // direction control registers p1.h = hi(flashA_csio); p1.l = lo(flashA_csio) + portA_data_dir; r0 = 0xFFFF(Z); // set dir=output w[p1] = r0; ssync;   Another new instruction   We want to put the 32- bit value 0x0000FFFF into the data register R0 BUT WE ONLY CAN USE INSTRUCTION CONTAINING 16-bit CONSTANTS – JUST LIKE MIPs R0 = 0xFFFF (Z) ZERO EXTEND R0 = 0x0000FFFF R0 = 0xFFFF(X) SIGN EXTEND R0 = 0xFFFFFFFF

18 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 18 Testing this code  Very difficult to do You are changing internal registers – either you are changing them correctly or else you are notYou are changing internal registers – either you are changing them correctly or else you are not  Instructor tests These are tests developed by an instructor (experienced developer) “who knows the details” and can check to see if you are making the correct changesThese are tests developed by an instructor (experienced developer) “who knows the details” and can check to see if you are making the correct changes Not clear if these tests would have real functionality “outside of an academic lab”Not clear if these tests would have real functionality “outside of an academic lab”

19 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 19 Writing a value to LED pins void short int); void WriteLEDASM(unsigned short int);  Key elements Have an input parameterHave an input parameter  What is the parameter size?  How is it stored – C++ conventions? Must output a “6-bit value” since we only have 6 output pins – other 2 bits are used for something else on the evaluation board and MUST not be destroyedMust output a “6-bit value” since we only have 6 output pins – other 2 bits are used for something else on the evaluation board and MUST not be destroyed How do you “output” a value – need to change certain bits and keep other (unknown values) unchanged?How do you “output” a value – need to change certain bits and keep other (unknown values) unchanged?

20 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 20 Output a LED value – general idea #include #include #define LED_PATTERN 0x6 // flash A csio reg (portB data reg) p1.h = hi(flashA_csio); p1.l = lo(flashA_csio) + portB_data_out; p1.l = lo(flashA_csio) + portB_data_out; r4 = b[p1](z); // read portB r3 = 0xc0; // mask of bits 5-0 %11000000 r3 = 0xc0; // mask of bits 5-0 %11000000 r4 = r4 & r3; // preserve bits 7-6 in r4 r4 = r4 & r3; // preserve bits 7-6 in r4 r3 = 0x3f; // mask of bits 7-6 %00111111 r2 = LEDPATTERN; // set initial LED pattern r2 = LEDPATTERN; // set initial LED pattern r2 = r2 & r3; // mask of bits 7-6 r2 = r2 & r3; // mask of bits 7-6 r2 = r4 | r2; // set portB content in r2 r2 = r4 | r2; // set portB content in r2 b[p1] = r2; // write flash A portB b[p1] = r2; // write flash A portB ssync; ssync;  New instruction Read an 8-bit value from memory and zero extend it  New instruction AND operation used as MASK to force bits 5-0 to 0 but keep bits 7 and 6 unchanged Combined AND with OR operations – permits the changing of bits 5-0 but keep bits 7 and 6 unchanged

21 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 21 New concepts to understand  AND operation used as MASK to permit clearing certain bits of a register and keeping other bits unchanged.  Binary values and Hex value patterns  AND and OR operation combined to permit setting of certain bits without destroying other bits

22 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 22 New instructions  Byte size read and write operations (8-bits) R0 = B[P0]; B[P0] = R0  Word size read and write operations (8-bits) R0 = W[P0]; W[P0] = R0  May need to add sign and zero extension during read operations

23 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 23 A final part of this lab section   Need to write a C++ program main( ) that calls ActivateFlashLEDOutputASM(void);   Write a C++ program that flashes the LEDs in a controlled pattern (delayed using UseFixedTimeASM( )) void ShowLEDPattern(void) No lights LED 0 (labeled LED4 on the board) LED 1 (labeled LED5 on the board) LED 2 (labeled LED6 on the board) LED 3 (labeled LED7 on the board) LED 4 (labeled LED8 on the board) LED 5 (labeled LED9 on the board) LED 4 (labeled LED8 on the board) LED 3 (labeled LED7 on the board) LED 2 (labeled LED6 on the board) LED 1 (labeled LED5 on the board) LED 0 (labeled LED4 on the board) No lights

24 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 24 Tackled today Lab. 5 Final product Blackfin BF533 Evaluation Board Assembly code (Driving the hardware) “C++” code (Handling the data management) 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

25 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 25 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

26 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 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

27 6/19/2015 Labs in ENCM415. Laboratory 2 LED control, Copyright M. Smith, ECE, University of Calgary, Canada 27 Tackle in Tutorial on Friday  Make sure that you bring the instruction reference manual Will also be a short quiz based on the information you need to understand during laboratory 2 – come preparedWill also be a short quiz based on the information you need to understand during laboratory 2 – come prepared  Overview of Blackfin logical operations (OR and AND)


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

Similar presentations


Ads by Google