Pages created and updated by Terry Sturtevant Date Posted: November 13, 2013

CP316: Microprocessor Systems and Interfacing

Interrupts

Objectives

Interrupts are a critical assembly language feature for systems which interface to the real world or for systems that operate in real time.

Equipment

Procedure

  1. *** THIS STEP SHOULD HAVE BEEN DONE AS A PRELAB EXERCISE ***
    Setup and test a base program that:
    • flashes the left LED every 250 milliseconds (fairly rapid pulse) based on Timer0.  Use hardware timing that polls the interrupt flag. This timing routine will be used to keep the processor busy.   You will be interrupting this routine. You need a fairly rapid pulse so that it is immediately obvious if there are problems with your interrupts or interrupt handling routines.
    • the signal that is driving the LED should be displayed on the oscilloscope (use the C2 pin).
    Demonstration - demonstrate the base program

  2. Set up the signal generator to produce a 0 to 5V square wave and connect it to the oscilloscope. Check GROUND and VDD pins on the header to make absolutely sure you understand the header pin numbering.

    Demonstration - demonstrate your signal and explain header pin numbering.
    You may not proceed to next task until the lab supervisor gives his OK.


  3. Modify the base program to protect the critical region of the timing routine. Turn interrupts off before this critical section and turn them back on after this critical section.

    What is the critical region of the timing routine? There is a section of the timing routine that reads the counter, adjusts the counter, and writes back the counter. This read-modify-write section should never be interrupted.

    HINT: turn on order is critical but you won't see the effects until part 4.

  4. Modify the above program to:
    • Toggle the centre LED if an external interrupt is received on int1.
    • The int1 interrupt should be low priority.
    • Apply the interrupt signals through the flexible header where you have access to both int1 and int2 interrupts.
    • NOTE: the key (arrow) on the socket header is pointing to pin 2 NOT pin1.
    • The left LED should keep flashing at a regular interval as in the base program.
    Demonstration - demonstrate and explain the operation of your program


  5. Modify the above program to:
    • Toggle the centre LED if an external interrupt is received on int1.
    • Toggle the right LED if an external interrupt is received on int2.
    • Both interrupts, int1 and int2, to be low priority.
    • Apply the interrupt signals through the flexible header where you have access to both interrupts.
    • The left LED should keep flashing at a regular interval as in the base program
    Demonstration - demonstrate and explain the operation of your program


  6. The programs for questions 4 and 5 focused on external hardware interrupts. This question focuses on internal hardware interrupts. Write a program (new project) that flashes the left LED every 250 milliseconds (fairly rapid pulse) based on Timer0 using a high priority interrupt to accomplish the task. (You're redoing question 1 using interrupts instead of polling.)

    Demonstration - demonstrate and explain the operation of your program

  7. Now redo question 5 with all three LEDs driven by interrupts. Modify the above program (new project) to:
    • Toggle the centre LED if an external interrupt is received on int1.
    • Toggle the right LED if an external interrupt is received on int2.
    • Both interrupts, int1 and int2, to be low priority.
    • Apply the interrupt signals through the flexible header where you have access to both interrupts.
    • The left LED should keep flashing at a regular interval using a high priority interrupt
    Demonstration - demonstrate and explain the operation of your program
Creative Commons License

Information on this site which is produced by Terry Sturtevant is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License.

Resources

To view pdf documents, you can download Adobe Acrobat Reader .
get Acrobat Reader
If you need to update a browser, you might try Firefox which is Get Firefox!
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the specifications as fully as possible.

If you are looking for an office package, with a word processor, spreadsheet, etc., you might try LibreOffice which is Get LibreOffice!

Go to the main page for the Department of Physics and Computer Science.

Valid XHTML 1.1

Valid CSS!

WCAG
2.0
(Level AA)

Wilfrid Laurier University