background image

Listing 1-3. Exercise 1, Part 3

1-28

Getting Started with ADSP-BF537 EZ-KIT Lite

/* command to terminate the table */
{ADI_PWR_CMD_END,0 }

};

typedef struct
{

ADI_PWR_VLEV v;
const char *n;

} voltage_levels_type;

voltage_levels_type voltage_levels[] =
{

{ ADI_PWR_VLEV_085, "0.85" },
{ ADI_PWR_VLEV_095, "0.95" },
{ ADI_PWR_VLEV_105, "1.05" },
{ ADI_PWR_VLEV_125, "1.25" },

};

void main ()
{

unsigned long long cycles_begin, cycles_end;
unsigned long seconds_begin, seconds_end;
unsigned long display_cycles_end;
volatile unsigned int time_end;
int i, v;

adi_pwr_Init(ezkit_init);

srand ( 22 );

printf("%20s%20s%20s\n","Voltage","Seconds","Cycles (x 1m)");

for ( v = 0; v < sizeof ( voltage_levels ) / sizeof ( 

voltage_levels_type ); ++v )

{

adi_pwr_SetMaxFreqForVolt ( voltage_levels[ v ].v );

start_real_time_clock ();
cycles_begin = clock ();

www.BDTIC.com/ADI

Summary of Contents for EZ-KIT Lite ADSP-BF537

Page 1: ...Getting Started with ADSP BF537 EZ KIT Lite Revision 1 2 November 2007 Part Number 82 000865 02 Analog Devices Inc One Technology Way Norwood Mass 02062 9106 a www BDTIC com ADI ...

Page 2: ...without prior notice Information furnished by Analog Devices is believed to be accurate and reliable However no responsibility is assumed by Analog Devices for its use nor for any infringement of patents or other rights of third parties which may result from its use No license is granted by impli cation or otherwise under the patent rights of Analog Devices Inc Trademark and Service Mark Notice Th...

Page 3: ...e ADSP BF537 EZ KIT Lite has been appended to Analog Devices Inc Technical Construction File TCF referenced DSPTOOLS1 dated December 21 1997 and was awarded CE Certification by an appointed European Competent Body as listed below Technical Certificate No Z600ANA1 021 Issued by Technology International Europe Limited 60 Shrivenham Hundred Business Park Shrivenham Swindon SN6 8TY UK The EZ KIT Lite ...

Page 4: ...www BDTIC com ADI ...

Page 5: ...ort xiv Supported Processors xv Product Information xv MyAnalog com xv Processor Product Information xvi Related Documents xvi Online Technical Documentation xviii Printed Manuals xix Notation Conventions xxi PROGRAMMING ADSP BF537 EZ KIT LITE WITH VISUALDSP Installing VisualDSP and ADSP BF537 EZ KIT Lite 1 2 Starting VisualDSP and Connecting to ADSP BF537 EZ KIT Lite 1 3 www BDTIC com ADI ...

Page 6: ...eads and Semaphores and Sockets API 2 2 Part 2 Creating a TCP IP Application and Connecting to a DHCP Server 2 3 Part 3 Communicating with Sockets API 2 6 Listing 2 1 Caesar_Cipher_ThreadType Run Implementation 2 10 Listing 2 2 Caesar_Cipher_ThreadType Implementation 2 11 Listing 2 3 VDK Thread Implementation 2 11 Listing 2 4 lwip_sysboot_threadtype_RunFunction Implementation 2 12 CONTROLLING A RE...

Page 7: ...ext 3 21 CREATING A TCP IP APPLICATION TCP IP Framework A 1 TCP IP Communications A 2 VisualDSP Kernel VDK Overview A 3 BSD Socket API A 3 1 Create Sockets A 4 2 Host Waits for Client A 4 3 Client Connects with Host A 4 4 Host Acknowledges Client A 5 5 Inter Process Communications A 5 6 Close Connection A 5 INDEX www BDTIC com ADI ...

Page 8: ...CONTENTS viii Getting Started with ADSP BF537 EZ KIT Lite www BDTIC com ADI ...

Page 9: ...su alDSP development environment to test the capabilities of ADSP BF537 Blackfin processors The VisualDSP development envi ronment gives you the ability to perform advanced application code development and debug such as Create compile assemble and link application programs written in C C and ADSP BF537 assembly Load run step halt and set breakpoints in application programs Read and write data and ...

Page 10: ...n The EZ KIT Lite is a licensed product that offers an evaluation temporary license Once the evaluation license expires VisualDSP restricts simulator and emulator con nections and limits the size of a user program to 20 KB of internal memory The board features Analog Devices ADSP BF537 Blackfin processor D Core performance up to 600 MHz D External bus performance to 133 MHz D 182 pin mini BGA pack...

Page 11: ...ational Laboratory Virtual Instrumen tation Suite ELVIS interface D LabVIEW based virtual instruments D Multifunction data acquisition device D Bench top workstation and prototype board Universal asynchronous receiver transmitter UART D ADM3202 RS 232 line driver receiver D DB9 female connector LEDs D 10 LEDs 1 power green 1 board reset red 1 USB red 6 general purpose amber and 1 USB monitor amber...

Page 12: ...e driver and a DB9 female connector providing an interface to a PC or other serial device Additionally the EZ KIT Lite board provides access to all of the proces sor s peripheral ports Access is provided in the form of a three connector expansion interface For information about the hardware components of the EZ KIT Lite refer to the ADSP BF537 EZ KIT Lite Evaluation System Manual Purpose of This M...

Page 13: ...P on page 1 1 Provides instructions for connecting the EZ KIT Lite to a PC and writing a C program to perform two sorting algorithms Exercise 2 Running a TCP IP application on an ADSP BF537 EZ KIT Lite on page 2 1 Provides instructions for creating a TCP IP application using the open source LwIP stack and VisualDSP Kernel Exercise 3 Controlling a real time application via TCP IP on page 3 1 Provid...

Page 14: ...ng and DSP products Web site at http www analog com processors technicalSupport E mail tools questions to processor tools support analog com E mail processor questions to processor support analog com World wide support processor europe analog com Europe support processor china analog com China support Phone questions to 1 800 ANALOGD Contact your Analog Devices Inc local sales office or authorized...

Page 15: ...hat allows customization of a Web page to display only the latest information on products you are interested in You can also choose to receive weekly e mail notifications containing updates to the Web pages that meet your interests including documentation errata against all manuals You can also choose to receive weekly e mail notifications containing updates to the Web pages that meet your interes...

Page 16: ...for information to processor support analog com World wide support processor europe analog com Europe support processor china analog com China support Fax questions or requests for information to 1 781 461 3010 North America 49 89 76903 157 Europe Related Documents For information on product related development software and hardware see these publications Table 1 Related Processor Publications Tit...

Page 17: ... BF537 EZ KIT Lite Evaluation System Manual Description of the ADSP BF537 EZ KIT Lite hardware and software components VisualDSP Assembler and Preprocessor Man ual Description of the assembler function and commands VisualDSP C C Complier and Library Manual for Blackfin Processors Description of the complier function and com mands for Blackfin processors VisualDSP Linker and Utilities Manual Descri...

Page 18: ...unning the Tools installation Access the online documentation from the VisualDSP environment Windows Explorer or the Analog Devices Web site Accessing Documentation From VisualDSP To view VisualDSP Help click on the Help menu item or go to the Windows task bar and navigate to the VisualDSP documentation via the Start menu To view ADSP BF537 EZ KIT Lite Help which is part of the Visu alDSP Help sys...

Page 19: ...ace These help files provide information about VisualDSP and the ADSP BF537 EZ KIT Lite evaluation system Accessing Documentation From Web Download manuals at the following Web site http www analog com processors technicalSupport technicalLi brary Select a processor family and book title Download archive zip files one for each manual Use any archive management software such as Win Zip to decompres...

Page 20: ...ach manual Data Sheets All data sheets preliminary and production may be downloaded from the Analog Devices Web site Only production final data sheets Rev 0 A B C and so on can be obtained from the Literature Center at 1 800 ANALOGD 1 800 262 5643 they also can be downloaded from the Web site To have a data sheet faxed to you call the Analog Devices Faxback System at 1 800 446 6212 Follow the prom...

Page 21: ... an ellipse read the example as an optional comma separated list of this SECTION Commands directives keywords and feature names are in text with letter gothic font filename Non keyword placeholders appear in text with italic style format Note For correct operation A Note provides supplementary information on a related topic In the online version of this book the word Note appears instead of this s...

Page 22: ...Notation Conventions xxii Getting Started with ADSP BF537 EZ KIT Lite L Additional conventions which apply only to specific chapters may appear throughout this document www BDTIC com ADI ...

Page 23: ...cessor s performance and learn how the pro gram s placement within the processor memory hierarchy impacts performance Finally you will study the processor performance in terms of speed and voltage trade offs In the exercise you will learn about the following concepts VisualDSP sessions and target types Plot windows Project configurations Benchmarking code with a Blackfin processor s cycle counter ...

Page 24: ...hen install VisualDSP by follow ing instructions in the VisualDSP Installation Quick Reference Card steps 1 to 3 Connect the EZ KIT Lite to the PC with the provided USB cable Once the installation is complete the amber LED labeled USB_MONITOR found near the USB jack is illuminated indicating a successful physical connection between the PC and EZ KIT Lite Install your license following instructions...

Page 25: ...to ADSP BF537 EZ KIT Lite From the Start menu navigate to the VisualDSP environment via the Programs menu After a second or two the main VisualDSP window appears on the screen When VisualDSP first launches it is discon nected from your EZ KIT Lite or any debugging session Figure 1 1 Figure 1 1 VisualDSP Main Window www BDTIC com ADI ...

Page 26: ...offer unique advantages the first being that no external hardware is required a great benefit when using VisualDSP on the road Furthermore simulators offer a deep insight to the internal work ings of the processor pipelines caches and more which is not possible with hardware based sessions The downside is that a sim ulator is several orders of magnitude slower than actual hardware The software mod...

Page 27: ... a separate module that provides a high bandwidth USB or PCI connection between the PC and the target device An emulator is required to connect to a non EZ KIT Lite target Legacy target This is a target created in VisualDSP 4 0 or a prior version Throughout this tutorial we will use the EZ KIT Lite connection To tell VisualDSP that your target is an ADSP BF537 processor on an EZ KIT Lite you must ...

Page 28: ...IT Lite via Debug Agent Specify your own Session name for your session or accept the default name Click Next 5 On the Finish page check the presented information and click Finish VisualDSP creates the new session and connects to the ADSP BF537 EZ KIT Lite Once connected the main window s title is changed to include the session name set is step 4 Figure 1 2 Session Wizard www BDTIC com ADI ...

Page 29: ...Started Examples Part_1_1 subdirectory The default install_path is C Program Files Analog Devices VisualDSP 5 0 Open the project file for the first part of Exercise 1 by selecting File Open Project browsing to the exercise directory and selecting the Sorts_1_1 dpj project file1 Once the project is opened you can view its source code by double clicking the Sorts c label in the Project window expand...

Page 30: ...t windows are created adjust them to comfortable sizes Your plot windows look similar to those in Figure 1 3 Note that both line plots are flat at zero because the data arrays are zero initialized by VisualDSP We will see VisualDSP update the windows as we step into the program Issue the Debug Step Over com mand or use the F10 hotkey three times to highlight the call to the bubble_sort function as...

Page 31: ...ovides for projects You can create more configurations A configuration is a set of project build options similar in concept to a makefile target It is often desirable to maintain different types of configurations for your system For example while debugging you may want to include trace or Figure 1 3 Plot Window Figure 1 4 Project Debug Configuration www BDTIC com ADI ...

Page 32: ...nctional debugging of your system Compiler optimizations are off giving you and the debugger the most linear and easily debugged code Release Used for your production system Compiler optimizations are on and maximally aggressive sacrificing readability and some debugger support At this point feel free to experiment further with the debugger familiariz ing yourself with the windows and basic mechan...

Page 33: ...t istall_path Blackfin Examples ADSP BF537 EZ Kit Lite Getting Started Examples Part_1_2 Sorts_1_2 dpj The part 2 project builds on the program discussed in the previous exer cise Listing 1 2 Exercise 1 Part 2 on page 1 21 includes some new lines of code delineated in italics This example s code has been placed for now into external SDRAM to demonstrate the effects of memory placement Since the ex...

Page 34: ...rofiler The statistical profiler is a unique tool that polls the Blackfin processor hundreds of times per a second The data is used to paint a statistical view of the program to deter mine where the program spends the majority of its time The statistical profiler has a distinct advantage over traditional pro filing techniques because it operates non intrusively tradition profiling techniques requi...

Page 35: ...Figure 1 6 When the program completes the Console page of the Output window displays an informative message in green text similar to xx seconds in approx xxxx cycles The message is the output of the printf call placed at the end of the main function Take note of the timing pre sented Now look at the Statistical Profiling window Figure 1 7 L Results may vary slightly on your computer Not surprising...

Page 36: ...al worse case conditions The program s code has been placed into external SDRAM while internal memory of the Blackfin processor remains com pletely unused The next steps demonstrate how the proper utilization of the memory hierarchy of the Blackfin processor can improve dramatically the program performance The easiest way to improve the performance is to enable the instruction cache1 of the Blackf...

Page 37: ...mory Protection under Startup Code Settings Figure 1 8 3 In the Instruction cache memory drop down box select Enable instruction cache 4 Click OK to set the new project option VisualDSP will regener ate the necessary files to enable the instruction case when the program runs 5 Rebuild the project by selecting Project Rebuild All or by right clicking the project name in the Project window and selec...

Page 38: ...he bubble_sort function into L1 internal memory 1 In the Project Project Options navigate to the Startup Code Settings Cache and Memory Protection page and change Instruction cache memory to Disable cache and disable memory protection 2 In the sorts c file go to the declaration of bubble_sort and add the section qualifier to place this function and this function only into internal L1 memory sectio...

Page 39: ...pplication where the techniques utilized in this exercise come into play The optimal memory configuration varies from an application to application possibly involving a blend of caching and direct L1 placement Exercise 1 Part 3 Working with Blackfin Voltage Regulator All Blackfin processors including the ADSP BF537 include an on chip voltage regulator that allows you to control the processor s pow...

Page 40: ...the previous exercise but now with the entire application loading into the L1 memory of the ADSP BF537 processor Listing 1 3 Exercise 1 Part 3 on page 1 25 delineates the new lines of code in italics Significantly the bulk of the main function is placed in a loop The goal is to run the previous exercise at four differ ent voltages see the voltage_levels struct declared above main You again use the...

Page 41: ...itialize two arrays to the same set of random values void randomize_arrays int v1 int v2 unsigned int length unsigned int i for i 0 i length i v1 i v2 i rand 1024 A standard bubble sort algorithm O n 2 void bubble_sort int v unsigned int length unsigned int i j for i 0 i length 1 i for j i 1 j length j if v i v j int temp v i v i v j v j temp A standard quick sort algorithm O n log n void quick_so...

Page 42: ... v j x do i while v i x if i j int temp v i v i v j v j temp else q j break quick_sort v p q quick_sort v q 1 r int out_b ARRAY_LENGTH int out_m ARRAY_LENGTH void main int i srand 22 for i 0 i NUM_ITERATIONS i randomize_arrays out_b out_m ARRAY_LENGTH bubble_sort out_b ARRAY_LENGTH quick_sort out_m 0 ARRAY_LENGTH 1 www BDTIC com ADI ...

Page 43: ... h define NUM_ITERATIONS 5000 define ARRAY_LENGTH 128 void start_real_time_clock void unsigned int get_real_time_clock_in_seconds void Helper function to enable the real time clock and reset it to time zero define WAIT_FOR_RTC_WRITE_COMPLETE while pRTC_ISTAT 0x8000 void start_real_time_clock if pRTC_PREN pRTC_PREN 1 WAIT_FOR_RTC_WRITE_COMPLETE pRTC_STAT 0 WAIT_FOR_RTC_WRITE_COMPLETE Help function ...

Page 44: ... clock 0xfc0 6 return seconds Initialize two arrays to the same set of random values void randomize_arrays int v1 int v2 unsigned int length unsigned int i for i 0 i length i v1 i v2 i rand 1024 A standard bubble sort algorithm O n 2 section L1_code void bubble_sort int v unsigned int length unsigned int i j for i 0 i length 1 i for j i 1 j length j if v i v j int temp v i v i v j v j temp www BDT...

Page 45: ...ck sort algorithm O n log n void quick_sort int v unsigned int p unsigned int r if p r unsigned int x i j q x v p i p 1 j r 1 for do j while v j x do i while v i x if i j int temp v i v i v j v j temp else q j break quick_sort v p q quick_sort v q 1 r int out_b ARRAY_LENGTH int out_m ARRAY_LENGTH www BDTIC com ADI ...

Page 46: ...d int i srand 22 start_real_time_clock cycles_begin clock for i 0 i NUM_ITERATIONS i int j randomize_arrays out_b out_m ARRAY_LENGTH bubble_sort out_b ARRAY_LENGTH quick_sort out_m 0 ARRAY_LENGTH 1 cycles_end clock cycles_begin display_cycles_end unsigned long cycles_end 1000000 time_end get_real_time_clock_in_seconds printf Completed in d seconds and approx u million cycles n time_end display_cyc...

Page 47: ...time h include services adi_pwr h define NUM_ITERATIONS 50000 define ARRAY_LENGTH 128 Helper function to enable the real time clock and reset it to time zero define WAIT_FOR_RTC_WRITE_COMPLETE while pRTC_ISTAT 0x8000 void start_real_time_clock if pRTC_PREN pRTC_PREN 1 WAIT_FOR_RTC_WRITE_COMPLETE pRTC_STAT 0 WAIT_FOR_RTC_WRITE_COMPLETE Helper function to get the number of seconds since zero time On...

Page 48: ...6 return seconds Initialize two arrays to the same set of random values void randomize_arrays int v1 int v2 unsigned int length unsigned int i for i 0 i length i v1 i v2 i rand 1024 A standard bubble sort algorithm O n 2 void bubble_sort int v unsigned int length unsigned int i j for i 0 i length 1 i for j i 1 j length j if v i v j int temp v i v i v j v j temp www BDTIC com ADI ...

Page 49: ... int p unsigned int r if p r unsigned int x i j q x v p i p 1 j r 1 for do j while v j x do i while v i x if i j int temp v i v i v j v j temp else q j break quick_sort v p q quick_sort v q 1 r int out_b ARRAY_LENGTH int out_m ARRAY_LENGTH ADI_PWR_COMMAND_PAIR ezkit_init 600Mhz ADSP BF537 EZ KIT Lite ADI_PWR_CMD_SET_EZKIT void ADI_PWR_EZKIT_BF537_600MHZ www BDTIC com ADI ...

Page 50: ...95 0 95 ADI_PWR_VLEV_105 1 05 ADI_PWR_VLEV_125 1 25 void main unsigned long long cycles_begin cycles_end unsigned long seconds_begin seconds_end unsigned long display_cycles_end volatile unsigned int time_end int i v adi_pwr_Init ezkit_init srand 22 printf 20s 20s 20s n Voltage Seconds Cycles x 1m for v 0 v sizeof voltage_levels sizeof voltage_levels_type v adi_pwr_SetMaxFreqForVolt voltage_levels...

Page 51: ...IONS i randomize_arrays out_b out_m ARRAY_LENGTH bubble_sort out_b ARRAY_LENGTH quick_sort out_m 0 ARRAY_LENGTH 1 cycles_end clock cycles_begin display_cycles_end unsigned long cycles_end 1000000 time_end get_real_time_clock_in_seconds printf 20s 20u 20u n voltage_levels v n time_end display_cycles_end www BDTIC com ADI ...

Page 52: ...Listing 1 3 Exercise 1 Part 3 1 30 Getting Started with ADSP BF537 EZ KIT Lite www BDTIC com ADI ...

Page 53: ...thernet network receive an IP address from a Dynamic Host Configuration Protocol DHCP server and ping the EZ KIT from another computer Finally we will implement a simple Caesar Cipher program and run the program via telnet In the exercise you will learn about the following concepts TCP IP and the LwIP stack VDK and its relationship to LwIP TCP IP project type Determining Ethernet Media Access Cont...

Page 54: ... a hardware connection for TCP IP networking 1 The LwIP stack s interface to both VDK and the underlying EZ KIT Lite hardware is well abstracted into libraries with defined APIs This makes the EZ KIT Lite and VisualDSP a good test and evaluation vehicle for your application The application can be ported later to alternative hard ware and or operating systems without modifying the internals of the ...

Page 55: ...o your network s DHCP server and receives an IP address The IP address is used to connect to the target board 4 Continues running the application To start physically connect the ADSP BF537 EZ KIT Lite hardware to the 10 100 Mbits sec network the same network your PC connects to and then create the TCP IP support software application using the sup plied non cross over cable Close any open projects ...

Page 56: ...se the wizard L The LwIP stack as distributed with VisualDSP relies on the presence of a DHCP server on your network If your network does not support DHCP the LwIP library must be rebuilt using a static IP address assigned by the network administrator For details regarding rebuilding the LwIP library with a static IP address refer to the LWIP_UserGuide doc file in the install_path Black fin lib sr...

Page 57: ...the EZ KIT Lite running Now ping the EZ KIT Lite from your PC Open a Command Prompt window DOS application and type the following command using the IP address reported in the VisualDSP Output window ping xxx xxx xxx xxx Again the EZ KIT Lite s IP address is assigned by the DHCP server L Because network configurations are dynamic the IP address can change from run to run Remember to check the addre...

Page 58: ... functionality to the application The remainder of the source code is this file is beyond the scope of this book s exercises The code relies heavily on the system services library that is touched upon in the previous exercises Part 3 Communicating with Sockets API Now it is time to add functionality to the created application First you create a simple Caesar Cipher program then run the program and...

Page 59: ...ternatively the project install_path Blackfin Examples ADSP BF537 EZ Kit Lite Getting Started Examples Part_2_1 Caesar_Cipher dpj can be loaded to the PC if you are unconcerned about the details herein and want to avoid typing in source code If you load the project skip the following procedure To create a new thread type Caesar_Cipher_ThreadType 1 From the Kernel page of VisualDSP Project window n...

Page 60: ...ype Imple mentation on page 2 11 The new lines of code are delineated in italics 4 Open Caesar_Cipher_ThreadType h and add a few new member variables see Listing 2 3 VDK Thread Implementation on page 2 11 5 Go back to Caesar_Cipher_ThreadType cpp and add include lwip sockets h near the top of the file with the other include directives to make the sockets API known to this source file Figure 2 3 Ne...

Page 61: ...et application to connect to the EZ KIT Lite telnet xxx xxx xxx xxx Once connected you receive the welcome message implemented in Caesar_Cipher_ThreadType Run Type characters in the Output win dow the letters A through Z upper and lowercase are incremented by one while non letters are echoed back undisturbed see Figure 2 4 When finished close the telnet session with Ctrl then type quit at the teln...

Page 62: ...ill encrypt them xa xd if 0 send m_iSocket pszWelcome strlen pszWelcome 0 return while 1 int iCount if iCount recv m_iSocket m_vInBuf sizeof m_vInBuf sizeof char 0 1 int iCharNum char c for iCharNum 0 iCharNum iCount iCharNum c m_vInBuf iCharNum if c A c Y c a c y c else if c Z c z c Z A m_vOutBuf iCharNum x8 telnet back space control character to overwrite the character sent m_vOutBuf iCharNum iC...

Page 63: ... tcb VDK Thread tcb m_iSocket int tcb user_data_ptr Listing 2 3 VDK Thread Implementation class Caesar_Cipher_ThreadType public VDK Thread public Caesar_Cipher_ThreadType VDK Thread ThreadCreationBlock virtual Caesar_Cipher_ThreadType virtual void Run virtual int ErrorHandler static VDK Thread Create VDK Thread ThreadCreationBlock The following declarations are specific to this example protected i...

Page 64: ...p_sysboot_threadtype_RunFunction void inPtr char ip 32 Initializes the TCP IP Stack and returns if system_init 1 printf Failed to initialize system n return start stack start_stack For debug purposes printf IP address to the VisualDSP console window Likely not needed in final application memset ip 0 sizeof ip if gethostaddr 0 ip printf IP ADDRESS s n ip Add Application Code here www BDTIC com ADI ...

Page 65: ... saddr saddr sin_family AF_INET saddr sin_addr s_addr htonl INADDR_ANY saddr sin_port htons 23 listening on port 23 well known default telnet if 1 bind listenfd struct sockaddr saddr sizeof saddr printf Call to bind failed n abort if 1 listen listenfd 0 printf Call to listen failed n abort for struct sockaddr cliaddr int clilen int iSocket iSocket accept listenfd cliaddr clilen if 1 iSocket printf...

Page 66: ...ite VDK_ThreadCreationBlock TCB kCaesar_Cipher_ThreadType VDK_ThreadID 0 0 VDK_Priority 0 void iSocket 0 if UINT_MAX VDK_CreateThreadEx TCB printf Call to VDK_CreateThreadEx failed n abort Put the thread s exit from main HERE A thread is automatically Destroyed when it exits its run function www BDTIC com ADI ...

Page 67: ...ugh VDK threads that operate concurrently with and indepen dently from the stack Then you will modify the stack s functionality to change on the fly the audio pass through volume In this exercise you will learn How to manage an audio encoder and decoder with device drivers How to use VDK history views to examine and trace system behavior How thread priorities impact system behavior How threads com...

Page 68: ...audio stream performed While this basic program does not seem to have any practical application its source code can serve as a framework a useful starting point for creating a serious application In this exercise we start with a program that features the Caesar Cipher algorithm from page 2 6 and augment the program with an audio pass through that is running concurrently and independently from the ...

Page 69: ...connector on the EZ KIT Lite The connector is labeled LINE OUT Your completed hardware interconnections look similar to the diagram in Figure 3 1 Next load the project install_path Blackfin Examples ADSP BF537 EZ Kit Lite Getting Started Exam ples Part_3_1 TalkThrough_3_1 dpj to the EZ KIT Lite Build and run the application While the application is running enable the audio play Figure 3 1 EZ KIT L...

Page 70: ...he ADSP BF537 EZ KIT Lite Evaluation System Manual and confirm that all of the DIP switches are in the correct positions While the pass through application is running examine its relation to the existing Caesar Cipher application from Exercise 2 Switch to the Kernel page of the Project window to see three new thread types added to the Caesar Cipher Figure 3 2 These new thread types are Input to ma...

Page 71: ...the audio thread types and Ethernet thread types with the audio thread types being given a lower number higher priority Proper assignment of thread prior ity is a hallmark of a good application design and often is one of the most important system level design decisions In this case it is more important Figure 3 2 New Caesar Cipher Thread Types www BDTIC com ADI ...

Page 72: ...ing is done per data point within the Ethernet software If the Ethernet stack is given a higher priority the keystroke processing may take too much time leaving the audio stream un serviced for an appreciable amount of time Ultimately this can result in audible clicks in the final audio output whenever a key is pressed degrading the user experience The software interface to the DAC AD1854 and ADC ...

Page 73: ...ng Pass Through Volume via Telnet The example in its current state includes an audio pass through and a Caesar Cipher operating concurrently but independently The next step is to control the audio pass through via the Ethernet connection At this point we remove the Caesar Cipher algorithm and replace it with control code that allow you to change the output volume of the application via Ethernet Co...

Page 74: ... and run the project When the audio output starts telnet to the EZ KIT Lite and use the and on your keyboard to change the volume of the output Now you are running an interactive real time application audio pass through that communicates through a TCP IP connection Now we use monitoring and analysis tools to understand the application s behavior We already are familiar with the statistical profile...

Page 75: ... if you halt the EZ KIT Lite while connect ing via telnet Other threads kADI_TOOLS_IOEThreadType are unfamiliar to you These threads are maintained by the LwIP Ethernet library The graph in Figure 3 4 visualizes the statistical profiling data Green ver tical lines indicate a change between two threads the thread running at any given time is also green Thus we can see that the Idle Thread gets the ...

Page 76: ...he range Now zoom in on one of the bursts of audio thread activity to visualize the interaction between the audio threads a relevant portion shown in Figure 3 5 In the figure you can see a regular pattern in the dataflow from the Input thread through to the Attenuator thread to the Output thread and back to the Attenuator The colored arrows represent various VDK events refer to the legend for deta...

Page 77: ...the red circle placed in the gut ter bar of the editor window To reset your program choose the Debug Reset menu item then File Reload Program If you still are connecting via telnet terminate the session by pressing Ctrl and typing quit in the DOS window Run the program L After halting this application any application you may find it impossible to run the program again and pick up where you left of...

Page 78: ...to right can be interpreted as 1 The LwIP stack thread ID 4 then 2 receives the keystroke from the Ethernet peripheral 2 The stack s processing is interrupted temporarily by the processing of an audio block threads ID 5 7 This interruption occurs because the audio processing thread has a higher priority than the Ethernet threads After servicing the audio execution resumes in the Ethernet thread Fi...

Page 79: ...hread Our breakpoint was set just after this point Part 3 Tuning Application Although we have plenty of available spare capacity in the application as is it is worth revisiting optimization techniques introduced in the earlier chapters The three easy ways to performance tune this application are Turn on the compiler s optimizations Enable the ADSP BF537 processor s instruction cache Increase the s...

Page 80: ...7 EZ KIT Set Clock and power settings to Optimize for speed Click OK 3 Because we need to make VDK aware of the change from the Ker nel page of the Project window navigate to Kernel System Clock Frequency Change the clock frequency value to 600 MHz Build run listen and halt as before You can see a modest improvement in performance If you still have the Statistical Profiling window open you may hav...

Page 81: ...files are boot loadable files created from processor exe cutable dxe files The Project Options dialog box is used to specify the loader file settings To create a loader file for the TalkThrough example 1 Open the project file install_path Blackfin Exam ples ADSP BF537 EZ Kit Lite Getting Started Examples Part_3_2 TalkThrough_3_2 dpj 2 From the Project menu select Project Options In the Project tre...

Page 82: ...lace the file using the Flash Programmer 1 Select Flash Programmer from the Tools menu The Flash Pro grammer dialog box Figure 3 7 appears on the screen 2 On the Driver page click Browse to locate the driver file install_path Blackfin Examples ADSP BF537 EZ Kit Lite Flash Programmer BF537EzFlashDriver dxe 3 Click Load Driver to load the driver file 4 Click the Programming tab Figure 3 8 Figure 3 7...

Page 83: ...Browse to locate the loader file Blackfin Exam ples ADSP BF537 EZ Kit Lite Getting Started Examples Part_3_2 Debug TalkThrough_3_2 ldr 6 Click Program to load the program to the flash memory 7 Click OK to exit the Flash Programmer Figure 3 8 Flash Programmer Dialog Box Programming Tab www BDTIC com ADI ...

Page 84: ...lluminated lights of the Ethernet jack indicate that the TalkThrough application is running L You need to know the IP address of the board to run the applica tion If you use a DHCP router the IP address is most likely the one that was used in previous examples in this tutorial You can change the volume of the audio using a TCPIP connection via telnet when the application is running When the audio ...

Page 85: ...Press and to change volume level xa xd if 0 send m_iSocket pszWelcome strlen pszWelcome 0 return float volume 48 0 VDK MessageID msg VDK CreateMessage VOL_CHANGE volume NULL while 1 int iCount if iCount recv m_iSocket m_vInBuf sizeof m_vInBuf sizeof char 0 1 int iCharNum char c for iCharNum 0 iCharNum iCount iCharNum c m_vInBuf iCharNum if c c if c volume 1 0 else volume 1 0 Volume must in a range...

Page 86: ...posite of expected behavior so we inverse the argument here extern VDK ThreadID g_AttenuatorID float message_args 48 0 volume VDK SetMessagePayload msg VOL_CHANGE sizeof message_args sizeof float message_args VDK PostMessage g_AttenuatorID msg CONTROL_CHANNEL msg VDK PendMessage RETURN_BUFF_CHANNEL 0 sprintf m_vOutBuf xa xdVolume is now g of g xa xd volume 48 0 if send m_iSocket m_vOutBuf strlen m...

Page 87: ...some of the unique features of the Blackfin simulators The VisualDSP Getting Started Guide is available in the online Help under the Getting Started folder A PDF version of the book also is available in the Docs directory on the VisualDSP installation CD or on the Analog Devices Web site Users of the LabVIEW application from National Instruments can install a separate Analog Devices Blackfin Test ...

Page 88: ...What s Next 3 22 Getting Started with ADSP BF537 EZ KIT Lite www BDTIC com ADI ...

Page 89: ...amework The Ethernet Media Access Control MAC device of the ADSP BF537 processor provides a 10 100 Mbits s Ethernet interface between the Media Independent Interface MII and the processor s peripheral system You can create an embedded program taking advantage of the Ethernet MAC and using the TCP IP stack support provided by VisualDSP TCP IP is a communication protocol that allows applications to ...

Page 90: ...ysical connection between the processor and the Local Area Network LAN The software component is a set of libraries and device drivers to provide the communications between the application and hardware TCP IP Communications TCP IP communication occurs between a client application and a host application The host listens for a connection from the client application For each application the following...

Page 91: ...tured applications using frameworks of template files VDK allows more efficient use of hardware by enabling improved schedul ing of work as well as a development framework containing implementations of common synchronization and scheduling paradigms For more information see the VisualDSP Kernel VDK User s Guide BSD Socket API The TCP IP stack uses the standard Berkeley Sockets Interface or sockets...

Page 92: ... to instantiate the socket Next the bind command is used to specify the type and the addressing format of the socket The IP address contains the actual address assigned by the network as well as a port address the location on the actual machine where the application is running The server and client applications must create their own sockets 2 Host Waits for Client A host application is placed in l...

Page 93: ...ee to send and receive data using the socket API calls For more information on socket APIs refer to Exercise 2 on page 2 2 6 Close Connection When the applications complete the data exchange the sockets must be closed The client application closes the socket it has created The host on the other hand close its own socket and the socket created by the connect call Figure A 1 illustrates the flow of ...

Page 94: ... Host and Client Communication Control Flow INITIALIZE SOCKET AND LISTEN FOR CONNECTIONS ESTABLISH CONNECTION BETWEEN CLIENT AND HOST HOST AND CLIENT EXCHANGE DATA PACKETS HOST AND CLIENT CLOSE SOCKETS HOST APPLICATION INITIALIZE SOCKET CONNECT TO HOST CLIENT APPLICATION www BDTIC com ADI ...

Page 95: ...ctional compiled 1 4 bubble sort algorithm 1 7 1 16 build options 1 9 Build project command 1 7 2 5 built in cycle counters 1 12 C cache configuring 1 16 Cache and Memory Protection dialog box 1 15 1 16 Caesar Cipher algorithm 2 1 2 6 3 2 3 4 CAN interface xi transceiver devices xi client applications A 2 client host connections closing A 3 A 5 clock frequency 1 17 3 14 Close project file command ...

Page 96: ...s 2 3 Ethernet MACs 2 2 F features of this EZ KIT Lite x functional compiled simulators 1 4 H handshakes between client host A 5 headers of VDK messages 3 7 host applications A 2 host client interactions 2 7 A 2 A 4 I instruction cache memory 1 15 interfaces See audio CAN ELVIS Ethernet expansion SDRAM internal memory 1 16 inter process communications A 5 IP address 2 1 2 4 2 5 2 9 A 2 A 4 J JTAG ...

Page 97: ...ectories 1 7 TCP IP Stack application using LwIP and VDK 2 3 Project window 1 7 3 4 Q quick sort 1 7 1 17 R real time clock RTC 1 12 Rebuild All project command 1 12 release project configuration 1 10 1 12 RS 232 connectors J6 xii S SDRAM memory 1 14 segment qualifiers 1 16 simulators 1 4 sockets API 2 6 A 5 creating A 4 sorting algorithms 1 7 SPORT0 interface xii statistical profiling 1 12 1 16 3...

Page 98: ...tter See UART USB jack 1 2 USB_MONITOR LED 1 2 V VDK State History window 3 13 VisualDSP debug sessions 1 4 distribution CD 1 7 Kernel VDK 2 1 A 3 main window 1 3 program code placement 1 17 project configurations 1 9 simulators 1 4 TCP IP software stacks 2 2 voltage levels 1 18 www BDTIC com ADI ...

Reviews: