Getting Started with ADSP-BF548 EZ-KIT Lite® Revision 1.0, November 2007 Part Number 82-000206-02 Analog Devices, Inc. One Technology Way Norwood, Mass.
Copyright Information ©2007 Analog Devices, Inc., ALL RIGHTS RESERVED. This document may not be reproduced in any form without prior, express written consent from Analog Devices, Inc. Printed in the USA. Limited Warranty The EZ-KIT Lite evaluation system is warranted against defects in materials and workmanship for a period of one year from the date of purchase from Analog Devices or from an authorized dealer. Disclaimer Analog Devices, Inc. reserves the right to change this product without prior notice.
Regulatory Compliance The ADSP-BF548 EZ-KIT Lite is designed to be used solely in a laboratory environment. The board is not intended for use as a consumer end product or as a portion of a consumer end product. The board is an open system design which does not include a shielded enclosure and therefore may cause interference to other electrical devices in close proximity. This board should not be used in or near any medical equipment or RF devices.
CONTENTS PREFACE Purpose of This Manual ................................................................ xiii Intended Audience ........................................................................ xiii Manual Contents .......................................................................... xiii What’s New in This Manual ............................................................ xv Technical or Customer Support ....................................................... xv Supported Processors .........
CONTENTS Example 1: Sorts.c File .................................................................. 1-9 USING ADSP-BF548 EZ-KIT LITE TO INVESTIGATE PERFORMANCE FACTORS ADSP-BF548 Processor Memory Hierarchy .................................. 2-2 Example 2: Benchmarking the Relative Performance of Memories .. 2-4 Example 3: Using the Blackfin Processor Voltage Regulator ........... 2-8 USING ADSP-BF548 EZ-KIT LITE PERIPHERALS ADSP-BF548 Processor I/O Peripherals ........................................
CONTENTS Example 5: Running ..................................................................... 4-6 USING ADSP-BF548 EZ-KIT LITE HARD DISK AND LCD SCREEN SSL File System Service ................................................................. 5-2 Sharp LQ043T1DG01 LCD Device Driver ................................... 5-3 Example 6: Displaying a Bitmap File on the EZ-KIT Lite .............. 5-4 Example 6: Project Options ...........................................................
CONTENTS Writing a Loader File to Flash Memory ......................................... 7-5 Booting From Burst Flash Memory ............................................... 7-8 Example 8: Loading ...................................................................... 7-9 Epilogue .....................................................................................
PREFACE Thank you for purchasing the ADSP-BF548 EZ-KIT Lite®, Analog Devices, Inc. evaluation system for ADSP-BF548 Blackfin® processors. Blackfin processors are embedded processors that support a Media Instruction Set Computing (MISC) architecture. This architecture is the natural merging of RISC, media functions, and digital signal processing (DSP) characteristics towards delivering signal processing performance in a microprocessor-like environment.
faster communication between the host PC and target hardware. Analog Devices carries a wide range of in-circuit emulation products. To learn more about Analog Devices emulators and processor development tools, go to http://www.analog.com/dsp/tools/. The ADSP-BF548 EZ-KIT Lite provides example programs to demonstrate the capabilities of the evaluation board. ADSP-BF548 EZ-KIT Lite installation is part of the VisuL The alDSP++ installation.
Preface • SPI flash memory D ST Micro M25P16 – 16 Mb • Advanced technology attachment packet interface (ATAPI) D Toshiba 2.5” MK4032GAX – 40 GB HDD • Analog audio interface D Analog Devices AD1980 SoundMAX codec D 6 DAC channels for 5.1 surround D 1 input stereo MIC jack D 1 input stereo LINE D 1 output stereo LINE D 1 output stereo SURROUND jack D 1 output center and LFE jack IN jack OUT/ HEAD PHONE OUT jack • TFT LCD display with touchscreen D Sharp LQ043T1DG01 – 480 x 272, 4.
• Thumbwheel D CTS Corp rotary encoder • 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) • Push buttons D 5 push buttons: 1 reset, 4 programmable flags with debounce logic • Expansion interface: all ADSP-BF548 processor signals • Other features D JTAG ICE 14-pin header D USB OTG connector D HOST D interface co
Preface Purpose of This Manual The Getting Started with ADSP-BF548 EZ-KIT Lite familiarizes users with the hardware capabilities of the evaluation system and demonstrates how to access these capabilities in the VisualDSP++ environment. EZ-KIT Lite users should use this manual in conjunction with the ADSP-BF548 EZ-KIT Lite Evaluation System Manual, which describes the evaluation system’s components in greater detail.
Manual Contents the board and control the program execution. You will build and run the first example project using the VisualDSP++ debug and data display tools. • Chapter 2, “Using ADSP-BF548 EZ-KIT Lite to Investigate Performance Factors” on page 2-1 Explores the memory hierarchy of the EZ-KIT Lite and measures the ramifications of memory placement decisions.
Preface • Chapter 6, “Using ADSP-BF548 EZ-KIT Lite Keypad and LED Indicator” on page 6-1 Explores the keypad interface of the EZ-KIT Lite and introduces the VisualDSP++ real-time kernel (VDK). You will use the LEDs to communicate the application status. • Chapter 7, “Creating A Bootable Application” on page 7-1 Finally, you will construct an application, drawing from the previous chapters in the manual.
Supported Processors • 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 distributor • Send questions by mail to: Analog Devices, Inc. One Technology Way P.O.
Preface MyAnalog.com MyAnalog.com is a free feature of the Analog Devices Web site that 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 interests. MyAnalog.
Product Information You may also obtain additional information about Analog Devices and its products in any of the following ways. • E-mail questions or requests for information to processor.support@analog.com (World wide support) processor.europe@analog.com (Europe support) processor.china@analog.
Preface Table 2.
Product Information Each documentation file type is described as follows. File Description .chm Help system files and manuals in Help format .htm or .html Dinkum Abridged C++ library and FlexLM network license manager software documentation. Viewing and printing the .html files requires a browser, such as Internet Explorer 6.0 (or higher). .pdf VisualDSP++ and processor manuals in Portable Documentation Format (PDF). Viewing and printing the .
Preface Help system files (.chm) are located in the Help folder, and .pdf files are located in the Docs folder of your VisualDSP++ installation CD-ROM. The Docs folder also contains the Dinkum Abridged C++ library and the FlexLM network license manager software documentation. Your software installation kit includes online Help as part of the Windows interface. These help files provide information about VisualDSP++ and the ADSP-BF548 EZ-KIT Lite evaluation system.
Product Information 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 prompts and a list of data sheet code numbers will be faxed to you.
Preface Notation Conventions Text conventions used in this manual are identified and described as follows. Example Description Close command (File menu) Titles in reference sections indicate the location of an item within the VisualDSP++ environment’s menu system (for example, the Close command appears on the File menu). {this | that} Alternative required items in syntax descriptions appear within curly brackets and separated by vertical bars; read the example as this or that.
Notation Conventions conventions, which apply only to specific chapters, may L Additional appear throughout this document.
1 PROGRAMMING ADSP-BF548 EZ-KIT LITE WITH VISUALDSP++ In this chapter, you will connect your personal computer (PC) to the ADSP-BF548 EZ-KIT Lite evaluation system and write a simple C language program to perform two sorting algorithms. In the exercise, you will learn about the following concepts. • VisualDSP++ sessions and target types • Plot windows • Project configurations The chapter includes the following sections.
Installing VisualDSP++ and the EZ-KIT Lite Installing VisualDSP++ and the EZ-KIT Lite If you have not already done so, install the ADSP-BF548 EZ-KIT Lite. Ensure the board is disconnected from your PC, then install VisualDSP++ by following instructions in the VisualDSP++ Installation Quick Reference Card, steps 1 to 3. are two USB interfaces on the ADSP-BF548 EZ-KIT Lite.
Programming ADSP-BF548 EZ-KIT Lite with VisualDSP++ Starting VisualDSP++ and Connecting to the EZ-KIT Lite If you have not already done so, start VisualDSP++. Use the Windows Start menu to launch the VisualDSP++ environment (also called the Integrated Development and Debugging Environment or IDDE). When VisualDSP++ first launches, it is disconnected from your EZ-KIT Lite or any other kind of debugging session (Figure 1-1). Figure 1-1.
Starting VisualDSP++ and Connecting to the EZ-KIT Lite • EZ-KIT Lite. This is the dedicated USB connection between the PC and EZ-KIT Lite. The connection is simple to manage and is an integral part of the EZ-KIT Lite. However, the connection is available with the EZ-KIT Lite only. Once your custom hardware board is available for development, you will use an emulator session (description follows) to connect to the custom hardware. • Simulator. This is a software model of the processor.
Programming ADSP-BF548 EZ-KIT Lite with VisualDSP++ 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. To inform VisualDSP++ that your target is an ADSP-BF548 processor on an EZ-KIT Lite, you must create and activate a new session. Follow these steps: 1. From VisualDSP++ Session menu, select New Session, which launches the Session Wizard (Figure 1-2). Figure 1-2. Session Wizard 2.
Example 1: Building and Running an Application 3. On the Select Connection Type page, select EZ-KIT Lite. Click Next. 4. On the Select Platform page, ensure that the selected platform is ADSP-BF548 EZ-KIT 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-BF548 EZ-KIT Lite.
Programming ADSP-BF548 EZ-KIT Lite with VisualDSP++ To spare you from typing in the program, the entire example 1 source code is included on the VisualDSP++ distribution CD. The source code and project files can be found in the \Blackfin\Examples\ADSP-BF548 EZ-Kit Lite\Getting subdirectory. The default Devices\VisualDSP 5.0.
Example 1: Building and Running an Application Repeat this procedure to create a plot window for the out_m variable1, modifying steps 2 and 3 accordingly. Once the plot windows are created, adjust them to comfortable sizes. Your plot windows look similar to those in Figure 1-3. Figure 1-3. Plot Windows 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.
Programming ADSP-BF548 EZ-KIT Lite with VisualDSP++ debugging information, which is not desired in the released product. A VisualDSP++ configuration allows you to create alternate build settings without interfering with the build settings of your final product. VisualDSP++ automatically adds two configurations for every project it creates. These configurations are: • Debug. Used for functional debugging of your system.
Example 1: Sorts.
Programming ADSP-BF548 EZ-KIT Lite with VisualDSP++ } 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 ); } } Getting Started with ADSP-BF548 EZ-KIT Lite 1-11
Example 1: Sorts.
2 USING ADSP-BF548 EZ-KIT LITE TO INVESTIGATE PERFORMANCE FACTORS In this chapter, we will benchmark a program, examine memory types, and look at the effects of enabling a portion of fast internal memory as a cache for external memory. Finally we will study the processor performance in terms of clock speed and voltage trade-offs. In the exercise, you will learn about the following concepts.
ADSP-BF548 Processor Memory Hierarchy ADSP-BF548 Processor Memory Hierarchy The ADSP-BF548 processor supports a ‘hierarchy’ of three synchronous memories, where the term synchronous means that the memory operates in step with the edges of the clock signal on whichever processor bus is used to access the memory. Understanding the differences between the different memories is an important aspect of high-performance application development. • Internal L1 memory.
Using ADSP-BF548 EZ-KIT Lite to Investigate Performance Factors The ADSP-BF548 processor also supports asynchronous memories, the internal operations of which are not tied to either of the processor’s main clocks. Typically, these are flash memory devices, of which the ADSP-BF548 processor supports a number of different types. The ADSP-BF548 EZ-KIT Lite is populated with these flash devices: • NOR. The easiest to use but most costly form of flash memory.
Example 2: Benchmarking the Relative Performance of Memories Example 2: Benchmarking the Relative Performance of Memories Now that you are familiar with basic VisualDSP++ operations, it is time to analyze and tweak a program’s performance. Close the Example_1.dpj file using the File–>Close–>Project menu selection. Open the next project file (Example_2.dpj) located in the \Blackfin\Examples\ADSP-BF548 EZ-Kit Lite\Getting Started Examples\Example_1 subdirectory of your VisualDSP++ directory.
Using ADSP-BF548 EZ-KIT Lite to Investigate Performance Factors and associated EZ-KIT Lite devices. Another library function (clock()) provides the current value of the processor’s core clock cycle counter whenever the function is called. Since we are examining performance in this example, we will build the project in the Release configuration, which invokes the compiler’s optimizer.
Example 2: Benchmarking the Relative Performance of Memories the approximate number of millions of processor cycles executed (see Table 2-1). The first row in Table 2-1 shows typical values, along with the Statistical Profiler’s final estimates of the percentage of execution time spent in the bubble_sort() and quick_sort() functions. Your figures may differ slightly from those in Table 2-1 but still will show that, as expected, bubble_sort() is using most of the processor time. Table 2-1.
Using ADSP-BF548 EZ-KIT Lite to Investigate Performance Factors employs. Since the profiler window shows that function bubble_sort() is using the largest percentage of processor time, we will move that function further up the memory hierarchy and examine the results. There are two commented-out section directives in the middle of the Sorts.c file, immediately above the bubble_sort() definition.
Example 3: Using the Blackfin Processor Voltage Regulator 3. In the Instruction cache memory drop-down list, select Enable instruction cache. 4. Click OK to set the new project option. VisualDSP++ will regenerate the necessary files to enable the instruction cache when the program runs. 5. Rebuild the project by selecting Project–>Rebuild Project or by right-clicking the project name Example_2 in the Project window and selecting Rebuild Project.
Using ADSP-BF548 EZ-KIT Lite to Investigate Performance Factors The voltage level can be changed on the fly as a program runs; for example, to suit the current workload or battery state. Changing the voltage regulator setting is not difficult but becomes a more complicated task with respect to coordinating the change with any necessary adjustments of the core and system clock rates.
Example 3: Using the Blackfin Processor Voltage Regulator Our application (Sorts.c) looks similar to the application in the previous example: a work loop in main() repeatedly executes the bubble sort and quick sort functions. Additional calls at the start and end of main() initialize and terminate the SSL library as mentioned above; additionally, the work loop is wrapped inside another loop.
3 USING ADSP-BF548 EZ-KIT LITE PERIPHERALS Chapters 1 and 2 of this tutorial introduce the ADSP-BF548 processor’s features that affect code execution: the memory hierarchy, instruction and data caches, and internal voltage regulator. This chapter introduces the I/O peripheral controllers and devices integrated with the processor and accessible on the EZ-KIT Lite. In this exercise, you will learn about the following concepts.
ADSP-BF548 Processor I/O Peripherals ADSP-BF548 Processor I/O Peripherals The ADSP-BF548 processor’s I/O controllers and peripherals fall into four categories: 1. Serial data interfaces • Two-wire interface (TWI). A TWI interface is compatible with the widely-used I2C bus standard. The processor supports up to two TWI interfaces. • Serial peripheral interface (SPI) bus standard. The processor supports up to three SPI interfaces. • Synchronous serial port (SPORT).
Using ADSP-BF548 EZ-KIT Lite Peripherals and other peripherals. The interface is configurable and supports data widths up to 24 bits. The ADSP-BF548 processor can support up to three EPPI interfaces. • Industry-standard ATA/ATAPI-6 interface. An ATA/ATAPI-6 interface is for control of a CD, DVD, hard disk drive, or any other ATAPI-compatible device. 3. Specialized interfaces • Host DMA port. A host DMA port allows an external processor to control DMA transfers to and from an ADSP-BF548 system.
ADSP-BF548 Peripheral Interfaces on the EZ-KIT Lite to limitations on the number of pins available on the procesL Due sor package, some peripherals are multiplexed onto the same pins and cannot be operated simultaneously. For complete information about the ADSP-BF548 processor and peripherals, consult the processor’s data sheet and hardware reference manuals. The data sheet and manuals are available at http://www.analog.
Using ADSP-BF548 EZ-KIT Lite Peripherals • A rotary switch for the up/down counter • A 4 x 4 keypad matrix for the keypad interface • An audio codec for one of the SPORTs • Push buttons and LED indicators for the GPIO pins In addition, the EZ-KIT Lite board includes a 10/100 Ethernet controller with associated magnetics and RJ-45 socket. The controller connects to the processor’s asynchronous memory bus. See the ADSP-BF548 EZ-KIT Lite Evaluation Manual for a full list of the board features.
Using ADSP-BF548 Peripherals on the EZ-KIT Lite The SSL presents a set of application programming interfaces (APIs) for core peripherals and features common across the Blackfin processors.
Using ADSP-BF548 EZ-KIT Lite Peripherals Some device drivers use other drivers; for example, on the ADSP-BF548 EZ-KIT Lite, the AD1980 audio codec connects to the processor’s SPORT0 interface for data transfers. The AD1980 device driver uses the supplied SPORT driver for managing the data transfers rather than driving the SPORT itself, or requiring the application to do so. Refer to the VisualDSP++ online help for more information about the SSL/DD.
Example 4: Audio.c File Example 4: Audio.c File Four functions in Audio.c interact with the AD1980 audio codec device driver: InitAudio() (see “InitAudio()—Opening the Driver”), TerminateAudio(), PlayBuffer(), and AD1980Callback(). The following sections describe some parts of these functions. InitAudio()—Opening the Driver The audio functions assume that the SSL is initialized. The initialization process is described in Chapters 4 and 5 on page 4-1 and on page 5-1, respectively.
Using ADSP-BF548 EZ-KIT Lite Peripherals A successful call to adi_dev_Open() results in a value identifying the initialized driver instance. We will use this value in future device manager calls to identify the driver instance. The adi_dev_Open() function takes nine arguments. The values supplied by InitAudio() are: • adi_dev_ManagerHandle: The adi_dev_Open() function is part of the device manager section of the SSL.
Example 4: Audio.c File processing or error event occurs. For the single instance of the AD1980 audio codec on the ADSP-BF548 EZ-KIT Lite, we do not need a distinguishing value, so we supply NULL. 3-10 • &AD1980DriverHandle: Argument five informs the device manager where to store the device driver instance value (handle). As noted earlier, we will use this handle to identify the driver instance in later device manager calls.
Using ADSP-BF548 EZ-KIT Lite Peripherals as preparing the next data buffer. Such an operation can affect the application’s response to interrupts from other peripherals. The delayed callback manager provides a mechanism for drivers to place a function pointer and associated arguments in a queue. The callback manager removes entries from the queue and calls the functions at a later time when no other interrupts are being serviced.
Example 4: Audio.c File D The first set is commands to the device manager, requesting the device manager to take certain actions on behalf of the device driver instance. These commands are defined in the device manager header file () and start with “ADI_DEV_CMD_”. D The second set is commands specific to the device driver and start with “ADI_xxx_CMD_”, where “xxx” identifies the driver. In our example, the driver identifiers start with “ADI_AD1980_CMD_”.
Using ADSP-BF548 EZ-KIT Lite Peripherals Other device manager commands include ADI_DEV_CMD_REGISTER_TABLE_WRITE whose operand is the address of an application-defined table of register name/value pairs, and ADI_DEV_CMD_REGISTER_FIELD_TABLE_WRITE which takes a table of register name/field name/value triples. The application can supply tables of whole-register or part-register values to modify an entire set of device registers with one call to adi_dev_Control().
Example 4: Audio.c File { printf(“Failed to initialize audio output device, “ “Error Code: 0x%08X\n”, Result); break; } TerminateAudio() When an application no longer needs a peripheral, the application terminates the peripheral’s driver and reclaims the driver’s resources with two function calls. A call to adi_dev_Control() stops data flow to the peripheral. A call to another device manager API (adi_dev_Close()) makes any memory work areas given to the device driver instance available for reuse.
Using ADSP-BF548 EZ-KIT Lite Peripherals desc[i].ProcessedFlag desc[i].
Example 4: Audio.c File AD1980Callback() Callback functions have the following arguments. • The first argument identifies which driver instance has invoked the callback. This value was supplied as the fourth argument to adi_dev_Open() (see on page 3-8) when the driver instance was created. • The second argument identifies the reason for the callback.
Using ADSP-BF548 EZ-KIT Lite Peripherals { case (ADI_AC97_EVENT_REGISTER_ACCESS_COMPLETE): reg_update_complete = true; break; case (ADI_DEV_EVENT_BUFFER_PROCESSED): /* signal that this transfer has completed */ /* ..get address of this buffer descriptor */ pdesc = (ADI_DEV_1D_BUFFER*)pArg; /* ..extract address of flag and set it */ pflag = (volatile bool*)pdesc->CallbackParameter; *pflag = true; break; default: printf(“Unexpected audio device callback.
Example 4: Running 3-18 Getting Started with ADSP-BF548 EZ-KIT Lite
4 USING ADSP-BF548 EZ-KIT LITE AS A MASS STORAGE DEVICE In this chapter, we will make the EZ-KIT Lite hard disk accessible from a PC as a removable mass storage device (MSD) with minimum application code. Then we will copy some files from the PC to the disk in preparation for later examples. In the exercise, you will learn about the following concepts: • ADSP-BF548 processor’s USB interface • USB standard software • USB data transfers to or from the EZ-KIT Lite The chapter includes the following sections.
ADSP-BF548 Processor USB Interface ADSP-BF548 Processor USB Interface The ADSP-BF548 processor incorporates a USB on-the-go (OTG) controller capable of operating at high speed (480 Mbps), full speed (12 Mbps), and low speed (1.5 Mbps, host mode only). The controller operates in peripheral mode or OTG mode. In peripheral mode, the controller appears as a single or multi-function device on a USB bus.
Using ADSP-BF548 EZ-KIT Lite As A Mass Storage Device code. The supplied software includes mass storage class and bulk transfer class device drivers. In this exercise, we will use the mass storage device driver. The main principle behind the operation of a USB mass storage device is that communication from the host to the device takes the form of basic Small Computer Systems Interface (SCSI) commands wrapped inside standard USB transactions.
Example 5: USB Project to specify their requirements. The common functions in adi_ssl_Init.c perform the SSL initialization, according to the requirements, and the final closing. adi_ssl_Init.h The code in main() is also straightforward. After initializing the SSL, the code does the following. 1. Uses the device manager to open and obtain a handle for the USB mass storage device driver.
Using ADSP-BF548 EZ-KIT Lite As A Mass Storage Device 5. Calls adi_dev_Control() again, this time in a loop, using the ADI_USB_MSD_CMD_IS_DEVICE_CONFIGURED command until the driver signals that a USB host has enumerated and configured the EZ-KIT Lite as a mass storage device. 6. Calls adi_dev_Control() for the final time, using the ADI_USB_MSD_CMD_SET_BUFFER command to pass the address of a data structure to the driver.
Example 5: Running Table 4-1.
Using ADSP-BF548 EZ-KIT Lite As A Mass Storage Device Computer (default action). Figure 4-2 shows My Computer after Windows has recognized the EZ-KIT Lite disk and assigned it a drive letter (“E” in this case). Figure 4-1.
Example 5: Running Figure 4-2. Windows My Computer Display EZ-KIT Lite drive for later use. On the PC, navigate to example 5’s directory and drag the BMP Files folder to the top level of the EZ-KIT Lite drive, thus creating the E:\BMP Files directory if “E” is the letter that Windows assigned to the EZ-KIT Lite drive.
5 USING ADSP-BF548 EZ-KIT LITE HARD DISK AND LCD SCREEN In this chapter we will use a major new component of the system services library (SSL)—the file system service (FSS)—in addition to one of the supplied device drivers to create a program that reads a bitmap image from the EZ-KIT Lite hard disk and displays the image on the LCD screen.
SSL File System Service • “Example 6: Displaying a Bitmap File on the EZ-KIT Lite” on page 5-4 • “Example 6: Project Options” on page 5-4 • “Example 6: Application Structure” on page 5-9 • “Example 6: Running” on page 5-12 SSL File System Service The file system service is a major addition to the SSL in VisualDSP++ 5.0. Embedded applications targeting Blackfin processors now have a direct means of accessing data held on mass storage devices using standard C library functions or custom APIs.
Using ADSP-BF548 EZ-KIT Lite Hard Disk and LCD Screen fwrite()) and many common directory-oriented functions (such as mkdir(), rmdir(), opendir(), readdir(), and closedir()) will apply to the file system/device driver combination supported by the FSS instance. The FSS also supports an API of its own, which allows more detailed control of the underlying file system and device drivers. The API description is included in the FSS documentation accompanying VisualDSP++.
Example 6: Displaying a Bitmap File on the EZ-KIT Lite VisualDSP++ 5.0 includes full documentation about the LCD device driver. Example 6: Displaying a Bitmap File on the EZ-KIT Lite This chapter’s example program (Example_6.dpj) uses the facilities of the FSS and LCD driver to read a bitmap image from the EZ-KIT Lite hard disk and to display the image on the LCD.
Using ADSP-BF548 EZ-KIT Lite Hard Disk and LCD Screen Figure 5-1. Example 6 Project Window The table at the top of the window shows that in addition to the system heap, which the C library functions malloc() and free() use by default, there is a user heap (FSSGeneralHeap) allocated 4 MB of space in DDR SDRAM memory (L3).
Example 6: Project Options Figure 5-2. User Heap Settings the application’s general performance. The processor’s caches or memory protection features require a control table, the cacheability and protection lookaside buffer (CPLB), to be set up. Typically this is done automatically by VisualDSP++ using appropriate default settings. However, current FSS and some device drivers cannot operate correctly when the data sections they read to or write from are cacheable.
Using ADSP-BF548 EZ-KIT Lite Hard Disk and LCD Screen Now double-click the Example_6_heaptab.c filename to open a source window containing the file’s contents and scroll to the bottom of the file (Listing 5-1). There are external declarations for two symbol pairs: one pair for the default system heap, the other pair for our user-defined heap. The symbols are defined by the linker when the example is built, acting on commands placed in the linker description file by VisualDSP++.
Example 6: Project Options The other generated C file (Example_6_cplbtab.c) does require modification—this has already been done in the Example_6.dpj project file distributed with VisualDSP++ 5.0: the properties of the data cache CPLB entries covering the FSS heap and frame buffers for the LCD have been changed to disable caching (Listing 5-2).
Using ADSP-BF548 EZ-KIT Lite Hard Disk and LCD Screen Example 6: Application Structure The structure of the example 6 application is straightforward; source file Example_6.c contains main(), which: • Calls functions to initialize the main components of the SSL, such as the interrupt and device managers, and set up the services and drivers for the specific devices (file system service, LCD display, and an I/O flag for a push button) • Calls a function to read a specific .
Example 6: Application Structure 3. Call the FSS’s initialization function, passing in a table of seven configuration parameters 4. Call a C-library function to install the FSS instance as the default STDIO driver That is all! Our application’s calls to the STDIO file handling functions and the directory manipulation functions now apply to the EZ-KIT Lite hard disk.
Using ADSP-BF548 EZ-KIT Lite Hard Disk and LCD Screen plications involving centering, cropping the image and filling the frame buffer ‘backwards’ to accommodate a line ordering difference between the .bmp file format and the LCD. In the InitLCD() function, we request the DMA manager to call function LcdCallback() after the final transfer in each of the two DMA chains.
Example 6: Running // one for EPPI and two for Disk #define ADI_SSL_FLAG_NUM_CALLBACKS // number of flag callbacks #define ADI_SSL_DEV_NUM_DEVICES // number of device drivers // LCD, EPPI, file system, ATAPI ... ... (0) (4) Example 6: Running Build and run the project. The LCD screen first turns black and then displays the image from the bitmap file (Figure 5-3). To clear the screen and terminate the program, press and hold for a second the PB4 button on the EZ-KIT Lite. Figure 5-3.
6 USING ADSP-BF548 EZ-KIT LITE KEYPAD AND LED INDICATOR In this chapter, we will use the ADSP-BF548 EZ-KIT Lite 4 x 4 matrix keypad and six LED indicators. We will use a simple event-driven driver to detect keypad presses and the system services library’s (SSL) flag service to display each press’s row and column numbers on the LEDs. In addition, we will use the VisualDSP++ real-time kernel (VDK) to structure our example program. In this exercise, you will learn about the following concepts.
Event-Driven Device Drivers Event-Driven Device Drivers There are two classes of peripheral device within the ADSP-BF548 processor: those whose primary purpose is to control a flow of data in or out of the processor, and those that generate or react to individual events.
Using ADSP-BF548 EZ-KIT Lite Keypad and LED Indicator conditions are, by and large, not expected to happen. For event-driven drivers, the emphasis is on reacting appropriately to each of the status or exception events that the device can generate. The driver passes any information supplied with the event notification to the rest of the application for processing.
VDK Message Passing It is possible to use the two complementary features (VDK’s higher-level device model and the SSL/device drivers’ low-level code) together in one application, as shown in example 7. VDK Message Passing As mentioned before, VDK supports a variety of inter-thread synchronization methods. For example, two different threads in your application may require access to the same shared resource; for example, a data buffer.
Using ADSP-BF548 EZ-KIT Lite Keypad and LED Indicator is where VDK-specific attributes of the project are entered and edited. Other general attributes of the project are entered or edited in the Project Wizard. Figure 6-1 shows the Kernel tab for example 7. The VDK project attributes are displayed in a tree structure and grouped into subsections according to function. We will examine the Threads, I/O Interface, Device Flags, and Messages subsections: Figure 6-1.
Example 7: Creating a VDK Application The VDK runtime system is instructed to create and start execution of one instance of BootThreadType as a boot thread when initializing the application. • The I/O Interface subsection defines one type of VDK device driver (KeypadDriver) and instructs VDK to create one instance of the device driver during application initialization.
Using ADSP-BF548 EZ-KIT Lite Keypad and LED Indicator Example 7: Source Files A VDK application typically does not define a main() function: VDK contains a default main() that performs the necessary initialization and starts the scheduler, resulting in execution of one boot thread. However, the default version only initializes the VDK system, while we want our example program to initialize the SSL in the same manner as the previous examples. Therefore, we provide our own main() in the main.
Example 7: Source Files The VDK-style device driver has only one skeleton function requiring completion—KeypadDriver_DispatchFunction(). VDK calls KeypadDriver_DispatchFunction() at specific points in the application, passing an argument to indicate the reason (text in italics describes the code added to the function’s skeleton): • At boot time, when VDK is creating the device object. No additional code for the device driver is required at this point. • When the application opens or closes the device.
Using ADSP-BF548 EZ-KIT Lite Keypad and LED Indicator Each source file that the Project Wizard generates in response to a new thread type definition in the Kernel tab contains skeleton definitions of four functions: • An initialization function called when an instance of the thread type is created by VDK as a boot thread (or by some other thread in the application) • A termination function called when an instance of the thread type is destroyed automatically by VDK (or programmatically by the application)
Example 7: Source Files while (running){ unsigned int r; keycoords_t keypress; /* get next keypress r = VDK_SyncRead( keypad_dd, /* device descriptor for keypad (char*)&keypress, /* where to put next keypress 1, /* number required (ignored) 0); /* no timeout - wait forever if (r == 0) { /* pack row/col info into type word to avoid needing /* a payload int type = ((keypress.row << 8) | keypress.
Using ADSP-BF548 EZ-KIT Lite Keypad and LED Indicator VDK_DestroyThread(LEDthread, false); /* This thread is automatically Destroyed when it exits its */ /* run function */ } The code in Listing 6-2 does the following. • Opens the VDK-style keypad device which, as described above, opens the SSL-style physical device driver for the keypad. • Creates an instance of LEDThreadType.
Example 7: Source Files • Sets the flag directions to ‘out’ • Clears the flags (turns each indicator off). Corresponding code appears in the termination function to close each flag and terminate the flag manager The run function of the LEDThreadType thread consists of an endless loop that pends on the thread’s message queue waiting for the boot thread to post a message.
Using ADSP-BF548 EZ-KIT Lite Keypad and LED Indicator Table 6-1.
Example 7: Source Files 6-14 Getting Started with ADSP-BF548 EZ-KIT Lite
7 CREATING A BOOTABLE APPLICATION In this final chapter, we will step beyond executing programs under the control of the VisualDSP++ Integrated Development and Debugging Environment (IDDE) and learn how to create a program that runs whenever the EZ-KIT Lite is power cycled or reset. The chapter’s example program builds on the previous examples to produce an application that displays a slide show of BMP images with optional audio captions, controlled from the EZ-KIT Lite keypad.
VisualDSP++ Utility Programs VisualDSP++ Utility Programs The loader utility is a VisualDSP++ tool which takes one or more executable (.dxe) files and converts them into a loader (.ldr) file, in the format required by the processor’s boot loader code. The boot loader can access a variety of peripherals and memory types, including flash memory. The Flash Programmer utility is another VisualDSP++ tool that controls the ‘burning’ of data to flash memories on the EZ-KIT Lite.
Creating A Bootable Application code and data sections directly in L1, L2, and L3 (DDR) memories and provide such features as breakpoints, data variable display, and statistical profiling. Note that memory space for extra information is not required on the target hardware —the information is retained within VisualDSP++ on the PC.
Creating a Loadable Program File Figure 7-1. Loader: Options Dialog Box On the Loader: Options page, the options grouped under the Boot Mode label select the memory or peripheral from which the boot loader will read the loader file. The boot loader can read from a UART, SPI-connected device, and host port among other options; a common choice is to place the loader file in flash memory. The options under Boot Format choose between several representations of the loader file.
Creating A Bootable Application The boot stream processed by the processor’s boot loader code can contain more than one program. The boot loader copies the first program into memory and calls the program’s entry point. If the program returns, the boot loader copies the next program in memory and calls that program’s entry point, and so on.
Writing a Loader File to Flash Memory ing a boot stream on an ADSP-BF548 EZ-KIT Lite is the 32 MB, 16-bit wide burst flash memory. VisualDSP++ includes a Flash Programmer utility to program the loader file into flash memory ready for booting. From the Tools menu, click Flash Programmer to open a three-page dialog box. Figure 7-2 shows the Driver page, the initial setup page of the dialog box.
Creating A Bootable Application Figure 7-2. Flash Programmer: Driver Dialog Box plete. Check your selections and click the Program command. After a short while, the message indicates that the erase and program operations have been successful. The %used column in the sector map list shows how much of each sector has been filled. This completes the process of programming your loader file in flash memory.
Booting From Burst Flash Memory Figure 7-3. Flash Programmer: Programming Dialog Box Booting From Burst Flash Memory The BMODE0—3 input pins of the processor select the location accessed by the processor’s boot loader at reset. On the ADSP-BF548 EZ-KIT Lite, rotary switch SW1 (labelled DSP BOOT) sets the values of the BMODE0—3 pins. SW1 position 1 (default) selects the burst flash memory.
Creating A Bootable Application Example 8: Loading This chapter’s example project (Example_8.dpj) reuses much of the code from previous examples to create a simple VDK and SSL/device driver based application that displays a series of .bmp images on the LCD screen. Each image has an optional audio caption, held in a .wav file and played through the audio output socket whenever the image is selected. Image selection is under user control from the keypad.
Epilogue Figure 7-4. Example 8 Instruction Screen If the example works as expected, you can burn the loader file to burst flash memory as described in “Writing a Loader File to Flash Memory” on page 7-5. The application will be booted and run every time the EZ-KIT Lite is reset, assuming that the board is not connected to a VisualDSP++ session. Epilogue We hope that you have enjoyed exploring the ADSP-BF548 EZ-KIT Lite and learning about some of VisualDSP++ features.
I INDEX A AD1980 audio codec, xi, 3-7 AD1980Callback() function, 3-16 adi_dev_Write() SSL API, 3-14 advanced technology attachment packet interface, See ATAPI asynchronous control messaging, 4-2 asynchronous memories, 2-3 ATA/ATAPI-6 interface, 3-3, 3-5 audio interface, xi, 3-7 B burst flash memory, x C cache, enabling, 2-7 cache and protection lookaside buffer (CPLB), 5-6 callback function, 3-11, 6-2 compiled simulators, 1-4 configurations, of projects, 1-8 connections, of this EZ-KIT Lite, 1-3 control
INDEX event-driven device drivers, 6-2 example 1 building, running an application, 1-6 source listing, 1-9 example 2 benchmarking performance of memories, 2-4 typical results, 2-6 using statistical profiler, 2-5 example 3 enabling instruction cache, 2-7 using voltage regulator, 2-8 example 4 running, 3-17 example 5 running, 4-6 USB project config, 4-3 example 6 application structure, 5-9 displaying a bitmap file, 5-4 project options, 5-4 example 7 creating a VDK application, 6-4 source files, 6-7 external
INDEX O OTG (on-the-go) USB controller, 4-2 P parallel data interfaces, 3-2 peripheral mode, 4-2 placement of code/data in memory, 2-6 plug-and-play devices, 4-2 power consumption, 2-10 project configurations, 1-8 R real-time clock (RTC), 2-4, 3-6 release configuration, of projects, 1-9, 2-5 S SDRAM memory (L3), 5-5 section directives, 2-7 secure digital (SD) I/O controller, 3-3 serial data interfaces, 3-2 serial flash memory, 2-3 serial peripheral interface (SPI), -xi, 3-2 simulator debug session, 1-4