CS 273 HW 11 - Ziad Arafat

  1. The addresses are.

  2. Read Section 14 Interrupts and Timers of the booklet and answer the following questions.

    1. We can utilize resources more efficiently so our CPU doesn't have to constantly listen for a signal. Instead we offload it to a dedicated device.
    2. An array of addresses indicating the address of the code that should be executed corresponding to an interrupt signal.
    3. Because we need to ensure that none of the registers have changed in the meantime.
    4. CODE:

C Code

#include "avr/io.h" #include "avr/interrupt.h" void isr(vector) { byte *a = 0x200; byte *b = 0x201; if (*a == 255) { *a = 0; *b++; } else{ *a++; } }

ASM code

timer2b: push r20 in r20, sreg push r20 push r21 clr r21 lds r20, 0x200 inc r20 sts 0x200, r20 lds r20, 0x201 adc r20, r21 sts 0x201, r20 pop r21 pop r20 out sreg, r20 pop r20