EDK Programming Essentials

This guide assumes that the user already has at least a basic understanding of C-coding. Programming the WARP in EDK does not require any advanced coding techniques, but may prove useful. The following are c-programming elements the user should have experience with to effectively program for WARP:

  • working with arrays
  • working with structs
  • working with pointers
  • typedefs
  • memory and string functions (such as memcpy)
  • bit-level coding and manipulation

All such skills are not hard to learn, however, as there are many good resources and documentation available online.

Preparing the System for Programming (in EDK 8+)

NOTE: EDK 8 is only required for using Software Platform Settings -- otherwise it's perfectly acceptable to make changes to the system MSS file directly.

It is assumed that the user has already successfully generated the hardware system in XPS. Before building a software application project, it’s important to set up the Operating System and drivers such that all required API are included during compilation. This can be done through direct modification of the system MSS file (requires familiarity with the MSS format and a good read of the software platform specification manual), or through tweaking settings in the “Software Platform Settings” User Interface. “Software Platform Settings” (SPS) is available in the “Software” drop-down in XPS.

There exist 4 tabs for setting up the system in SPS. “Software Platform,” “OS and Libraries,” “Drivers,” and “Interrupt Handlers.” In “Software Platform,” the user can specify the processor settings, the Operating System to use, and extended built in libraries. All operating systems support the extended built in libraries. The user may select these to fit their functionality requirements (such as lwip for networking or xilfatfs for using Compact Flash and the SystemACE controller on WARP) – if the functionality is not required, it’s best to leave the library out in order to reduce the operating system memory footprint. The extended library API documentation is available in the “OS and Libraries Document Collection” It should be located under the EDK installation directory: $EDK\doc\oslib_rm.pdf.

The “OS and Libraries” tab in SPS gives the user a host of modifiable parameters based on the chosen operating system. Here, the user can specify the peripheral to use for standard I/O – for warp this should be the RS232 serial peripheral. This will allow the WARP to display prints to a mini-terminal (such as TeraTerm Pro) by simply calling the print( ) function in C. If any extended libraries were included, they can be modified in this tab as well. Information on all the modifiable parameters (available for standalone and xilkernel operating systems only), is also located in $EDK\doc\oslib_rm.pdf.

The third tab is “Drivers.” The parameters here typically do not need to be changed. Bringing an EDK-compliant peripheral into XPS will automatically update the MSS to include the most up-to-date driver associated with it. If a deprecated driver is required, however, it can be selected here.

The final tab is “Interrupt Handlers.” The user can give specify the function names to be called with an associated peripheral’s interrupt. It is important to note, that for interrupts to appear here, they must be tied in hardware first correctly. Secondarily, it is not required (but convenient) to place the handler names here – an alternative to doing so, is to use the intc API (for standalone OS, documentation located in: $EDK\doc\xilinx_drivers_api_toc.htm), or the xilkernel API (located in $EDK\doc\oslib_rm.pdf).

Setting Up Interrupts in C (Standalone OS)

Setting up interrupts is largely driver-API dependent, but the general procedure is the same:

  1. Use the peripheral API to initialize the hardware if an initialize function is provided
  2. Use the peripheral API to customize the hardware (if GPIO, such as the data direction/channel)
  3. Register the Handler with XIntc_RegsiterHandler( ) (or use SPS)
    1. Reference designs available on the WARP website
    2. Intc API documentation is located in: $EDK\doc\xilinx_drivers_api_toc.htm
  4. Master enable the interrupt controller with XIntc_mMasterEnable( ) – see API
  5. Enable the individual interrupts with the interrupt controller using Xintc_mEnableIntr – see API
  6. Use the peripheral API to enable the peripheral interrupt (EG: XGpio_InterruptEnable)
  7. Create a function with the handler name and program it to do the desired task

The procedure in xilkernel abstracts away the interrupt controller function calls. A Standalone OS reference design for WARP that uses interrupts can be found here.

General Programming Notes

This section is written to detail the nuances of programming the hardware, rather than teach the programmer all of the functions available. Reference designs are available at for basic PPC-type examples. WARP-specific reference designs are available here. Driver APIs can be found in the following places:

  • Extended libraries (such as LWIP): $EDK\doc\oslib_rm.pdf
  • Xilinx-based peripherals: $EDK\doc\xilinx_drivers_api_toc.htm
  • WARP-based peripherals: via

The first item of note when programming to control the peripherals, is that the PowerPC uses memory mapped control over the them – registers are used to define hardware states, which lie in RAM. Thus, controlling the hardware is a simple matter of getting the PowerPC to write to these memory locations. The memory locations are hard-coded into the system from the “System Assembly View,” for XPS-8 (or Add/Edit Hardware for XPS 7).

Therefore, many of the provided APIs rely on knowing the base address of the peripheral. The functions use the base address of the peripheral to calculate the correct offset in memory of a particular read/write register. Instead of having to provide the actual location in memory to these functions, XPS generates a file called “xparameters.h,” when the “generate libraries and BSPs” function is called under the software drop-down. The file can be found in the “Applications” view of the system, under the project section, and finally under the “Processor: ppc405_0” heading. This file contains defined constants for all of the memory-mapped peripherals’ base addresses. The file also contains other useful constants which may be used for masking control registers or for interrupt control.

Secondarily, unlike when working with other C/C++ development applications, XPS does not require the user to apply all of the sources and headers used in the system manually. Only the application code itself and non-EDK-compliant custom libraries must be added. The OS, extended functionality (if used), and EDK-peripheral libraries are all automatically added by XPS at compilation. It is still important, however, to include all required library definitions in the application code, otherwise the compiler will complain about undefined functions.

Custom Driver Programming

If the user is developing a custom peripheral to be controlled by the PPC, chances are that it has been created in one of two ways: by using the “create/import peripheral” wizard, or through System Generator. The former will generate a basic API and the latter will simply generate a header file of base addresses. In either case, if the developer knows the proper coding of bits for a control register or wants to read/write data from a register, creating an expanded API is a simple matter of using pointers.

Alternatively, Xilinx provides a library called “xio.h,” which gives the user a host of abstract lower-level functions. The most useful of these are XIo_In16( ) and XIo_Out16( ), which are also available in the 8bit-wide and 32bit-wide varieties. The XIo_In functions allow a user to read data from a register by providing a base-address and an offset. The XIo_Out functions allow a user to write data to a register by providing a base address, an offset, and the data value. The library header can be found in: $EDK\sw\XilinxProcessorIPLib\drivers\cpu_ppc405_v1_00_a\src\xio.h

| HOME | NEXT: Xilkernel Support and Programming
Last modified 16 years ago Last modified on Aug 3, 2006, 2:01:43 PM