Toronto ECE 532 - LAB 3 - Adding IP And Device Drivers That Use Interrupts

Unformatted text preview:

University of Toronto ECE532 Digital Hardware LAB 3: Adding IP And Device Drivers That Use Interrupts 1 Version 1.1 1/22/2004 9:34 PM Acknowledgement This 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 Lab1 and Lab2. A primary goal 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 this lab together with the associated device drivers. Many complex embedded systems use interrupt driven I/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 interrupt that can be used to schedule other processing. The GPIO will be used to get input from switch User Input 0. This switch will control the flashing rate of User LED 0 from Lab2. Preparation 1. Find the overviews of the OPB Timer/Counter and the OPB Interrupt Controller (v1.00c) in the Processor IP Reference Guide. From there you will find a link to the data sheets. Familiarize yourself with how these 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 Lab2 project. The file was copied from the User_Area when you started Lab1. Have a look at this file to understand what it does. In this lab you will be filling in the <TO BE DONE xxx> sections after XPS generates the header files to support the hardware. 3. You should look at the Xilinx Lecture slides starting at slide 119 for an overview of the driver organization and conventions. You can get more details in the EST Tools Guide in the Driver section. Background This lab builds from Lab2 and assumes that the user has completed Lab2. A basic understanding of adding IP and device drivers should have been gained from Lab2.University of Toronto ECE532 Digital Hardware LAB 3: Adding IP And Device Drivers That Use Interrupts 2 Setup 1. Copy the XPS project directory (lab2 folder) of the previous lab and rename the copy to “lab3”. This will be the working project directory for this lab. 2. Start XPS by selecting Start->Programs->Xilinx Embedded Development Kit 6.1->Xilinx Platform Studio from the Windows desktop. 3. Select the File menu, select Open Project, and browse to the system.xmp file of lab3. Click Open to open the project. This is the project you completed in Lab2. Adding A Timer/Counter And Interrupt Controller 4. Using the Add/Edit Cores feature of XPS, add an OPB Timer (opb_timer) and an OPB Interrupt Controller (opb_intc). Set the address range of the timer to 0x00030300—0x000303ff and the range of the interrupt controller to 0x00030400—0x0003041f. 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 interrupt controller, and the INTERRUPT signal of the Microblaze processor. 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 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 then click the Connect button. Enter a new net name, select Internal, and click OK. Note that the signals to be connected are all internal to the design, so be sure these are specified as Internal scope in the Port Signal Assignment table. You can also rename the Net Names of signals by clicking in the white net name box. There are no parameters 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 Controller 7. Select driver interface level 1 for the Timer and Interrupt Controller software settings. 8. Remove the source file lab2a.c from the project and add lab2b.c, which should be in the code directory of your project.University of Toronto ECE532 Digital Hardware LAB 3: Adding IP And Device Drivers That Use Interrupts 3 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 you stop your program and run it a second time, you may notice that it does not work and the message “Timer counter initialization error” is printed to the serial port. Why do you think the initialization failed? Step into the XTmrCtr_Initialize function to find the answer. However, first you will have to recompile the drivers in debug mode. In XPS, select OptionsàCompiler Options… from the menus. Select the Others tab and enter “-g -O0” in the Extra Compiler Flags field to enable debug mode and turn off optimizations for the libraries. When you step through the XTmrCtr_Initialize function you will notice that it fails because the timer is already running from the last time your program was run and the function exits before completing the initialization. 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 must use the level 0 driver interface to disable the timer. Look in microblaze_0/include/xtmrctr_l.h to determine how to do this and add it to the beginning of your program. Similarly, you should disable interrupts for the interrupt controller at the start of your program using its level 0 driver (xintc_l.h). Otherwise, an interrupt may occur before the drivers are initialized and your program will freeze while trying to service the interrupt. Using A Switch To Control The Flashing Rate Of The LED 12. Add an additional bit (as input) to the GPIO to read the value of SW0 on the User Input DIP switch on the board. In the Parameters tab of Add/Edit Cores change the value of C_GPIO_WIDTH to 2. In the Ports tab, change the range of the opb_gpio_0_GPIO_IO signal to [0:1]. Note the bit order


View Full Document

Toronto ECE 532 - LAB 3 - Adding IP And Device Drivers That Use Interrupts

Documents in this Course
Load more
Download LAB 3 - 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 LAB 3 - 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 LAB 3 - 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?