Pages created and updated by Terry Sturtevant Date Posted: January 20, 2020

CP316: Microprocessor Systems and Interfacing

Interrupts

Objectives

Interrupts allow very quick reactions to external events independent of normal program flow.

Equipment

Procedure

Timer interrupts

  1. Connect the Arduino board.
  2. Create a new sketch, and download the timer interrupt sketch.
  3. Connect the oscilloscope to the output pin identified in the sketch.
  4. Run the program to see that the square wave appears on the scope.
  5. Given the timer mode, should the value in the OCR affect the period? Change the value and rerun the program to confirm your prediction.
  6. Modify the program so that you get direct output from the timer along with the output from the interrupt. Connect the other oscilloscope channel to the timer pin, and rerun the program to confirm the result.
  7. Sketch the scope output showing both signals. Are the two signals tightly synchronized, or is there some variation in the delay between them? Explain.
    (Hint: Trigger on one channel, and see what the other looks like, and then trigger on the other channel and view the first one.)
    Demonstration - demonstrate what you have determined to the lab instructor.
  8. Disassemble both the original code and the modified version so that they can be compared.

Hardware multitasking; timers and interrupts

  1. Create a new sketch, and download the timer multitasking sketch.
  2. Connect the oscilloscope to the output pins identified in the sketch.
  3. Run the program to see that the square waves appear on the scope.
  4. Given the timer mode, should the value in the OCR affect the period? Change the value and rerun the program to confirm your prediction.
  5. Sketch the scope output showing both signals. Are the two signals tightly synchronized, or is there some variation in the delay between them? Explain.
    (Hint: Trigger on one channel, and see what the other looks like, and then trigger on the other channel and view the first one.)
    Demonstration - demonstrate what you have determined to the lab instructor.
  6. Disassemble both the original code and the modified version so that they can be compared.
    What additional code gets added to the ISR beyond what is needed to toggle the output pin?
    Even though the main loop is empty, what code does it still contain?

3 process program

  1. Modify the program so that you have an putput pin that can be toggled in the main loop.
    Thus there will be three output pins:
    1. one controlled directly by a timer;
    2. one controlled by the ISR;
    3. one controlled by the main loop.
  2. Since you only have two oscilloscope channels, you can only see two outputs at a time.
    Connect the hardware output pin and the ISR pin, as previously, and observe the output to see that it performs as before.
    Sketch the scope output showing both signals. Are the two signals tightly synchronized, or is there some variation in the delay between them? Explain.
    (Hint: Trigger on one channel, and see what the other looks like, and then trigger on the other channel and view the first one.)
    Demonstration - demonstrate what you have determined to the lab instructor.
  3. Now connect the hardware output pin and the main loop pin and observe the output to see that it performs as expected.
    Sketch the scope output showing both signals. Are the two signals tightly synchronized, or is there some variation in the delay between them? Explain.
    (Hint: Trigger on one channel, and see what the other looks like, and then trigger on the other channel and view the first one.)
    Demonstration - demonstrate what you have determined to the lab instructor.
  4. Disassemble both the original code and the modified version so that they can be compared.
    Now that the main loop is not empty, does the code in it all make sense?
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