laboratory 1 – encm415 familiarization with the analog devices’ visualdsp++ integrated...
Post on 21-Dec-2015
219 views
TRANSCRIPT
Laboratory 1 – ENCM415
Familiarization with the Analog Devices’ VisualDSP++Integrated Development Environment
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
2 / 28
Lab. 1 -- this afternoon
Recipe for Just in time knowledge Need a dollop of “C++” code from
assignment 1 main( ), HelloWorldTest( ), MeasureTemperature( ) Hopefully you’ve just handed-in working code at the
start of the class A smizzen of knowledge to build the simplest
possible Blackfin assembly language for-loop A pinch of Window’s Experience And a bowl to put the ingredients in (a
computer account with password) and somebody else to do all the clean-up (a partner) and a desk in Labs ICT318 and 318.
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
3 / 28
VisualDSP++ IDE
Analog Devices’ integrated development environment (IDE) ENCM415 – Assembly language and interfacing (2004) ENCM491 – Real Time Systems (2003) ENCM505 – Multi-processor course (2004) ENCM515 – Comparative Processor Architectures for
DSP (Since 1999)
Dr. Smith has been awarded the Analog Devices’ University Ambassadorship for 2001/2002, 2002/2003, 2003/2004
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
4 / 28
Just enough to know
Build U:/ENCM415/Lab1 Directory Activate VisualDSP++ 16-bit processor Family
simulator session and activate a Blackfin simulator session
Build a Blackfin Project, add to your directory Add your Assignment1 C++ files to the project Compile, Link and Run using the equivalent
commands as with Microsoft Visual Basic, Visual Studio etc
If time today will do a demo.
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
5 / 28
Blackfin C++ code STUB
A function stub has just enough code to Compile, link and run
int main(void) { unsigned short int timeUsed1, timeUsed2;
HelloWorld(FRANCE); timeUsed1 = UseTime(0x5000);
timeUsed2 = UseTimeASM(0x5000);}
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
6 / 28
Valid main stub
int main(void);void HelloTest(const short int);
typedef unsigned short int ushort; // Define a variable typeushort UseTime (ushort int);extern “C” ushort UseTimeASM(ushort int);
#define FRANCE 5void int main(void) { ushort timeUsed1, timeUsed2; HelloTest(FRANCE); timeUsed1 = UseTime (0x5000); timeUsed2 = UseTimeASM(0x5000);}
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
7 / 28
HelloTest
You provide the stub needed for the “C++” function HelloTest( )
Note that you don’t need to know any details of the function (other than its prototype) to build a stub
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
8 / 28
ushort UseTime(ushort);
This routine is written in “C++” It must return a value
When first developing the code – return an error value
You write the stub
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
9 / 28
ushort UseTimeASM(ushort);
The customer wants this written (for some reason) in assembly code
It is “assembled” and not “compiled” However activating the compiler will cause the
assembler to be activated automatically Place in a file with extension “.asm” and
add to your project – UseTimeASM.asm Have you seen the expression “extern C”
used in a program before? What does the stub look like?
See Lab. 1 web pages for more detail Why does the stub look like that?
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
10 / 28
Assembly code Stub in file UseTimeASM.asm
#include <defBF533.h>#include <macros.h> .section program; .global _UseTimeASM; .align 2;#define UseTimeASMSTACK 16 _UseTimeASM: // unsigned short int UseTimeASM(unsigned short int timeToUse) { LINK UseTimeASMSTACK; // Code goes here and replaces next line R0 = 0; // return 0;
P0 = [FP + 4 ]; UNLINK; JUMP (P0); // }_UseTimeASM.end:
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
11 / 28
Code for ushort UseTime(ushort); First thing – compile and link the stubs, check that they work
(run). Provide the “C++” code for ushort UseTime(ushort);
It must return the parameter passed to it It must “waste time” accurately – meaning that
UseTime(2000) must take twice as long to execute as UseTime(1000) (to within a certain error limit)
Then develop the simplest code needed – get that to work How can you “check” that it works?
Then “refactor” the code -- and add quality to the code – check that still works
Don’t use a “for loop” – since we know from MIPS experience that assembly code does not support “for loops”
Actually the Blackfin BF5xx processor family DOES support a maximum of 2 hardware loops in assembly code – but that is not many
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
12 / 28
Code for ushort UseTimeASM(ushort);
First thing – compile and link the assembly code stubs, check that they work (run).
Get the “C++” code for ushort UseTime(ushort); to work
Now translate that code (one line at a time) into assembly code ushort UseTimeASM(ushort); using the “C++” code as “comments” . Techniques for Control Code (CC) Bit Management
are detailed in Section 6 of the Blackfin Processor Instruction Set Reference.
Arithmetic operations are detailed in Section 10 of the Blackfin Processor Instruction Set Reference.
More details can be found in Task 6 of Laboratory 1
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
13 / 28
VisualDSP – working example
Now lets put some of these ideas together as a working demo
Note – more slides walking you through setting up a VisualDSP session follow – your responsibility
A little hint for the laboratories Check the performance of the simulator before
and after code optimization – that is “DEBUG MODE” (before) and “RELEASE MODE with DEBUG information” (after)
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
14 / 28
Activating VDSP environment
Hold CONTROL key down while activating to ensure that you get a choice of session to use
Lab. 1 session – Blackfin Family simulator
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
15 / 28
Activate required session
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
16 / 28
Select new project, save .dpj file
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
17 / 28
Project Options
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
18 / 28
Say no here – or start again
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
19 / 28
Add your main.cpp file to the project
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
20 / 28
Display in window and set Editor tab
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
21 / 28
Build project
Build file in window, if the file is in the project
Build project (only changed files rebuilt and will cause load if successful)
Rebuild all files whether changed or not
Click here to jump to error in source file
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
22 / 28
Build, Load, Run
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
23 / 28
After running
NOTE: Disassembly window shows that program has found the C++ stop here optionDON’T ACTIVATE “RUN” AGAIN
String in output window
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
24 / 28
Mixed mode allows you to see “C++” source and equivalent assembly code
RIGHT-CLICK IN SOURCE WINDOW
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
25 / 28
Mixed mode allows you to see assembly source code and assembly
Debug assembler option must be ON
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
26 / 28
Other useful VisualDSP++ options
MEMORY DISPLAY
REGISTER DISPLAY
PLOT WINDOW
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
27 / 28
Tackled today
Just enough information to activate a simulator session for Lab. 1
M. Smith -- ENCM415 Assembly Language and Interfacing on the Blackfin ADSP-BF533 microcontroller
28 / 28
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.