====== Interrupts ====== ===== Lecture Material ===== This lecture is related to interrupts \\ of the AVR **[[rtes:topics:arduino:ATmega328|ATmega328]]** microcontroller. We use part of the excellent material from [[http://courses.cs.washington.edu/courses/csep567/10wi/|"CSE P567, Design and Implementation of Digital Systems (Winter 2010)"]] by Carl Ebeling, Computer Science and Engineering Program, University of Washington /* * Lecture 6: {{:envmon:ws2015:session_03:lecture6_atmega328_arduino.pdf|Introduction to the ATmega328 and Arduino}} * Lecture 7: {{:envmon:ws2015:session_03:lecture7_timers_interrupts.pdf|ATmega328 Timers and Interrupts}} */ * Lecture 6: {{ :rtes:topics:arduino:lecture6_atmega328_arduino.pdf |}} * Lecture 7: {{ :rtes:topics:arduino:lecture7_timers_interrupts.pdf |}} * [[https://www.microchip.com/wwwproducts/en/ATmega328p|ATmega328P web page]] * {{http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega328_P%20AVR%20MCU%20with%20picoPower%20Technology%20Data%20Sheet%2040001984A.pdf|ATmega328P Datasheet (pdf)}} * {{http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_Summary.pdf|ATmega328P Datasheet Summary (pdf)}} From the introduction to ATmege328 ("Lecture 6") we just need: * AVR register file: some discussions * AVR memory * Interrupts * I/O ports, pin circuitry We don't need: * Addressing modes * Instructions ==== Interrupt and Context Switch ==== A very good explanation is found here: * https://www.quora.com/What-is-the-difference-between-context-switching-and-interrupt-handling ===== Lab / Exercises / Homework ===== ==== 1) Time Interrupts ==== Let us work on Arduino Timer Interrupts based on material from instructables \\ http://www.instructables.com/id/Arduino-Timer-Interrupts/?ALLSTEPS ==== 2) Generate f = 3 kHz ==== Modify the code from the instructable above to generate a frequency of f = 3 kHz. ==== The Lazy Ones use this ==== http://www.8bit-era.cz/arduino-timer-interrupts-calculator.html ===== Links ===== * https://oscarliang.com/arduino-timer-and-interrupt-tutorial/ * http://ucexperiment.wordpress.com/2012/03/16/examination-of-the-arduino-millis-function/ * https://arduinodiy.wordpress.com/2012/02/28/timer-interrupts/ * [[http://www.atmel.com/Images/doc2505.pdf|AVR130: Setup and Use the AVR® Timers]] (pdf) * https://sites.google.com/site/qeewiki/books/avr-guide/timers-on-the-atmega328