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
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 Toronto ECE532 Digital Hardware Module m03 Adding IP and Device Drivers That Use Interrupts Version EDK 6 3i Jan 07 05 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 Module 1 and Module 2 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 1 This switch will control the flashing rate of User LED 0 from Module 2 Requirements Module 2 Adding drivers and IP GPIO Preparation 1 Find the overviews of the OPB Timer Counter and the OPB Interrupt Controller 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 Module 2 project The file was in the m01 zip file you loaded for Module 1 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 Driver Reference Guide Background This lab builds from Module 2 and assumes that the user has completed Module 2 A basic understanding of adding IP and device drivers should have been gained from Module 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 3 From the initial startup screen select Open a Recent Project and click OK Browse to the system xmp file of lab3 Click Open to open the project This is the project you completed in Lab2 1 University of Toronto ECE532 Digital Hardware Module m03 Adding IP and Device Drivers That Use Interrupts 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 0x80040200 0x800402ff and the range of the 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 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 and click OK 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 Remove the source file lab2a c from the project and add lab2b c which should be in the code directory of 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 were to you stop your program and run it a second time you would notice that it does not work and the message Timer counter initialization error would be printed to the serial port Why do you think the initialization would fail To find the answer you would have to step into the XTmrCtr Initialize function However first you would have to recompile the drivers in debug mode In XPS double click the microblaze 0 instance and go to the Processor Driver Parameters and Interrupt Handlers tab of the Software Platform Settings dialog box Entering g O0 in the Extra Compiler Flags field would enable debug mode and turn off optimizations for the libraries If you were able to step through the XTmrCtr Initialize function after stopping and restarting the program in GDB you would 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 SW1 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 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 the pin number in the Multimedia Board User Guide 2 University of Toronto ECE532 Digital Hardware Module


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 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?