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.
- using multiple low priority interrupts
Equipment
- QwikFlash Development Board
- white breadboard with socket connector
- NOTE: the key (arrow) on the socket header is pointing to pin 2 NOT pin1.
- microcomputer with MPLAB IDE and ICD2
- signal generator, oscilloscope for debugging
Procedure
- *** 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
- 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.
- 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.
- 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
- 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
- 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
- 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
Wilfrid Laurier University
© 2019 Wilfrid Laurier University