DOC PREVIEW
Toronto ECE 532 - Module m03 - Adding IP and Device Drivers That Use 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 That Use InterruptsVersion EDK 6.3i Jan/07/05AcknowledgementThis 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 Module 1 and Module 2. 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 such that 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 2.RequirementsModule 2 Adding drivers and IP - GPIO.Preparation1. Find the overviews of the OPB Timer/Counter and the OPB Interrupt Controller in the Processor IPReference Guide. From there you will find a link to the data sheets. Familiarize yourself with howthese blocks work. The data sheets will also be posted on the course web page.2. In this lab you will be modifying the file lab2b.c, which should be in the code directory of your Module 2project. The file was in the m01.zip file you loaded for Module 1. Have a look at this file to understandwhat it does. In this lab you will be filling in the <TO BE DONE xxx> sections after XPS generates theheader files to support the hardware.3. You should look at the Xilinx Lecture slides starting at slide 119 for an overview of the driver organi-zation and conventions. You can get more details in the Driver Reference Guide.BackgroundThis lab builds from Module 2 and assumes that the user has completed Module 2. A basic understandingof adding IP and device drivers should have been gained from Module 2.Setup1. 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.2. Start XPS.3. From the initial startup screen, select Open a Recent Project and click OK. Browse to the system.xmpfile of lab3. Click Open to open the project. This is the project you completed in Lab2.1University of TorontoECE532 Digital HardwareModule m03: Adding IP and Device Drivers That Use InterruptsAdding A Timer/Counter And Interrupt Controller4. Using the Add/Edit Cores feature of XPS, add an OPB Timer (opbtimer) and an OPB InterruptController (opb intc). Set the address range of the timer to 0x80040200–0x800402ff and the range ofthe interrupt controller to 0x80040300–0x8004031f. Attach both peripherals to the OPB bus as slaves.5. Select the Ports tab and add the Interrupt signal of the timer, the Intr and Irq signals of the interruptcontroller, and the INTERRUPT signal of the Microblaze processor. The interrupt output signal of thetimer should be connected to the interrupt input (Intr) of the interrupt controller. The interrupt outputsignal (Irq) of the interrupt controller should be connected to the interrupt input of the processor.Connect the signals by selecting the first signal, hold ctrl while clicking the second signal, and thenclick the Connect button. Enter a new net name and click OK.You can also rename the Net Names of signals by clicking in the white net name box. There are noparameters for each core that must be set differently than the default value.6. Rebuild the bitstream and download it to the board.Adding Software To Use The Timer And Interrupt Controller7. Remove the source file lab2a.c from the project and add lab2b.c, which should be in the code directoryof your project.8. Make sure to have regenerated the Libraries. Why?9. Using the source file lab2b.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.10. Compile the program and download using GDB. Verify the code works correctly.11. If the bug with the Fast Download Methodology and GDB did not exist in EDK 6.3i, if you wereto you stop your program and run it a second time, you would notice that it does not work and themessage “Timer counter initialization error” would be printed to the serial port. Why do you thinkthe initialization would fail? To find the answer, you would have to step into the XTmrCtr Initializefunction. However, first you would have to recompile the drivers in debug mode. In XPS, double clickthe microblaze 0 instance and go to the Processor, Driver Parameters and Interrupt Handlers tab ofthe Software Platform Settings dialog box. Entering “-g -O0” in the Extra Compiler Flags field wouldenable debug mode and turn off optimizations for the libraries.If you were able to step through the XTmrCtr Initialize function after stopping and restarting theprogram in GDB, you would notice that it fails because the timer is already running from the lasttime your program was run and the function exits before completing the initialization. To fix this, youshould make sure the timer is not running at the start of your program. However, you cannot call theXTmrCtr Stop function before calling XTmrCtr Initialize so you must use the level 0 driver interfaceto disable the timer. Look in microblaze 0/include/xtmrctr l.h to determine how to do this and addit to the beginning of your program.Similarly, you should disable interrupts for the interrupt controller at the start of your program usingits level 0 driver (xintc l.h). Otherwise, an interrupt may occur before the drivers are initialized andyour program will freeze while trying to service the interrupt.Using A Switch To Control The Flashing Rate Of The LED12. Add an additional bit (as input) to the GPIO to read the value of SW1 on the User Input DIP switchon the board. In the Parameters tab of Add/Edit Cores change the value of C GPIO WIDTH to 2.Having changed this generic, the range of the opb gpio 0 GPIO IO signal would now become [0:1].You must also make this change manually in the External Ports Connections section of the Ports tab.Add bit 1 of this signal to the system.ucf file and connect it to the pin for USER INPUT1. Find thepin number in the


View Full Document

Toronto ECE 532 - Module m03 - Adding IP and Device Drivers That Use Interrupts

Documents in this Course
Load more
Download Module m03 - Adding IP and Device Drivers That Use 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 That Use 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 That Use 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?