DOC PREVIEW
Toronto ECE 532 - Module m03 - Adding IP and Device Drivers — Timers and Interrupts

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

University of TorontoECE532 Digital HardwareModule m03: Adding IP and Device Drivers — Timers and InterruptsVersion for EDK 10.1.03 as of January 7, 2009AcknowledgementThis lab is derived from a Xilinx lab given at the University of Toronto EDK workshop in November 2003.Many thanks to Xilinx for allowing us to use and modify their material.Goals• Use Xilinx tools to add to the Microblaze system that was built in Modules m01 and m02. A primarygoal of this lab is to understand the details of adding IP and device drivers that use interrupts.• IP cores including the General Purpose I/O (GPIO), Timer, and Interrupt Controller are used in thislab together with the associated device drivers. Many complex embedded systems use interrupt drivenI/O rather than polled I/O and as such, learning how to use interrupts is important.• The Interrupt Controller and Timer will be added to the project and used to create a periodic interruptthat can be used to schedule other processing. The GPIO will be used to get input from switch UserInput 1. This switch will control the flashing rate of User LED 0 from Module m02.PrerequisitesModule m02: Adding IP and Device Drivers — GPIO and PollingPreparation• Find the overviews of the XPS Timer/Counter and the XPS Interrupt Controller in the EDK docu-mentation (look in the IP Reference → Processor IP Catalog). From there you will find a link to thedatasheets. Familiarize yourself with how these blocks work.• Copy the XPS project directory (lab2 folder) of the previous lab and rename the copy to lab3. Thiswill be the working project directory for this lab. Extract m03.zip into the directory containing thelab3 directory to add the source files required for this module to the lab3/code/ directory. If youlike, you can delete the existing lab3/code/ directory before extracting m03.zip to clean up the filesfrom Module m02.In this lab you will be modifying the file lab3.c, which you just extracted into your copy of your Modulem02 project. Have a look at this file to understand what it does. In this lab you will be filling in the<TO BE DONE> sections after XPS generates the header files to support the hardware.• Launch XPS and open the project for Module m03 (i.e., lab3/system.xmp).BackgroundThis lab builds from Module m02 and assumes that the user has completed Module m02. A basic under-standing of adding IP and device drivers should have been gained from Module m02.Adding A Timer/Counter And Interrupt Controller1. Add an XPS Timer (xps timer) and an XPS Interrupt Controller (xps intc). Set the address range of thetimer to 0x80040200−0x800402ff and the range of the interrupt controller to 0x80040300−0x8004031f.Attach both peripherals to the PLB bus as slaves.1University of TorontoECE532 Digital HardwareModule m03: Adding IP and Device Drivers — Timers and Interrupts2. Select Ports. The interrupt output signal of the timer should be connected to the interrupt input(Intr) of the interrupt controller. The interrupt output signal (Irq) of the interrupt controller shouldbe connected to the interrupt input of the processor. Connect the signals by entering the same nameinto the Net fields for both signals. Both cores can be left with the default configuration values fortheir paramters.3. Rebuild the bitstream and download it to the board. If you deleted lab2.c earlier, don’t forget toremove it from Project: mb0 default → Sources on the Applications tab before building.Adding Software To Use The Timer And Interrupt Controller4. Remove the source file lab2.c from the project (if you haven’t already done so) and add lab3.c, whichshould be in the code directory of your project.5. Make sure you have regenerated the libraries. Why?6. Using the source file lab3.c, make the appropriate changes to the source file such that it will compile.Reference xparameters.h and the device driver documentation or header files for help.7. Compile the program and download using GDB. Verify that the code works correctly with the softwaredebugger.8. Close the software debugger and switch to the XMD window. From the XMD window, enter dowmb0 default/executable.elf to download the binary to the MicroBlaze. Type run to start runningthe program and confirm that it is operating as it did when you ran it via the software debugger.Type stop to stop the program. Look at the PC — where did the program stop (hint: use the rrdcommand)? Reset the PC to the start address of your program (remember, it’s 0x800) using the rwrcommand and type con to start your program over from the beginning. Notice that this time, thetimer initialization fails and the message “Timer counter initialization error” is printed to the serialport. Why do you suppose this is? Restart the program, this time using the run command and noticethe difference. What changed? Why? Can you use the debugger to explain the different behaviourbetween continuing from the start address of the program and running the program?While trying to figure out what happened, you may find it difficult to debug the driver code. If youconsult your system.log or libgen.log and look for the messages relating to building the libraries, you’llnotice that they’re still built with optimization enabled (-O2) even though you disabled optimizationsfor your application code in Module m02. To recompile the drivers in debug mode, select the Softwaremenu and the Software Platform Settings submenu. Select microblaze 0 from the Processor Instance:drop-down list, and enter -g -O0 in the extra compiler flags field. If you rebuild the libraries, youmight notice that both the -O2 and -O0 flags are set. If you then look at the Makefile for the drivers,you’ll notice that the EXTRA COMPILER FLAGS appears after COMPILER FLAGS in the build command. Ifyou further look at the man page for gcc, you’ll note that if multiple -O flags are included in the gcccommand line, the last one takes precendence.You should now be able to step through the XTmrCtr Initialize function after stopping the program,resetting the PC, and continuing from 0x800. You’ll now notice that it fails because the timer isalready running from the last time your program was run and the function exits before completing theinitialization. To fix this, you should make sure the timer is not running at the start of your program.However, you cannot call the XTmrCtr Stop function before calling XTmrCtr Initialize so you mustuse the level 0 driver interface to disable the timer. Look


View Full Document

Toronto ECE 532 - Module m03 - Adding IP and Device Drivers — Timers and Interrupts

Documents in this Course
Load more
Download Module m03 - Adding IP and Device Drivers — Timers and Interrupts
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Module m03 - Adding IP and Device Drivers — Timers and Interrupts and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Module m03 - Adding IP and Device Drivers — Timers and Interrupts 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?