CS 273 HW 11 - Ziad Arafat
-
The addresses are.
- TCNT0 = 0x26 (0x46)
- TCCR0A = 0x24 (0x44)
- TCCR0B = 0x25 (0x45)
- OCR0A = 0x27 (0x47)
- OCR0B = 0x28 (0x48)
- TIMSK0 = (0x6E)
- TCNT1H = (0x85)
- TCNT1L = (0x84)
- TCCR1A = (0x80)
- TCCR1B = (0x81)
- TCCR1C = (0x82)
- OCR1AH = (0x89)
- OCR1AL = (0x88)
- OCR1BH = (0x8B)
- OCR1BL = (0x8A)
- TIMSK1 = (0x6F)
- TCNT2 = (0xB2)
- TCCR2A = (0xB0)
- TCCR2B = (0xB1)
- OCR2A = (0xB3)
- OCR2B = (0xB4)
- TIMSK2 = (0x70)
-
Read Section 14 Interrupts and Timers of the booklet and answer the following questions.
- 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.
- An array of addresses indicating the address of the code that should be executed corresponding to an interrupt signal.
- Because we need to ensure that none of the registers have changed in the meantime.
- 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