Skip to content

Commit f9aa265

Browse files
authored
Merge pull request #5 from TUBAF-IfI-LiaScript/master
Update13-01-2021
2 parents 4a9f852 + c497986 commit f9aa265

40 files changed

Lines changed: 979 additions & 23 deletions

13_AVR_CPU.md

Lines changed: 815 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ der Relevanz dieses Wissens bei der hardwarenahen Codeentwicklung.
77

88
| Woche | VL | Tag | Inhalt der Vorlesung |
99
|:----- | --- | ------------ |:-------------------------------- |
10-
| 1 | 1 | 20. Oktober | Einführung und Motivation |
11-
| | 2 | 22. Oktober | Geschichte |
12-
| 2 | 3 | 27. Oktober | Boolsche Algebra |
13-
| 3 | 4 | 03. November | Minimierung von Schaltfunktionen |
14-
| | 5 | 05. November | Schaltnetze |
15-
| 4 | 6 | 10. November | Schaltnetze |
16-
| 5 | 7 | | Schaltwerke |
17-
| | 8 | | Schaltwerke |
18-
| 6 | 9 | | Rechnerarithmetik |
19-
| 7 | 10 | | Modell CPU |
20-
| | 11 | | Befehlsabarbeitung |
21-
| 8 | 12 | | |
22-
| 9 | 13 | | RISC und Pipelining |
23-
| | 14 | | ATmega als reale CPU |
24-
| 10 | 15 | | Mikroprocessor |
25-
| 11 | 16 | | Mikrocontroller I |
26-
| | 17 | | Mikrocontroller II |
27-
| 12 | 18 | | |
28-
| 13 | 19 | | |
29-
| | 20 | | |
30-
| 14 | 21 | | |
31-
| 15 | 22 | | |
32-
| | 23 | | |
10+
| 1 | 0 | 20. Oktober | Einführung und Motivation |
11+
| | 1 | 22. Oktober | Geschichte |
12+
| 2 | 2 | 27. Oktober | Boolsche Algebra |
13+
| 3 | 3 | 03. November | Minimierung von Schaltfunktionen |
14+
| | 4 | 05. November | Schaltnetze |
15+
| 4 | 5 | 10. November | Schaltnetze |
16+
| 5 | 6 | 17. November | Flip-Flops |
17+
| | 7 | 19. November | Schaltwerke |
18+
| 6 | 8 | 24. November | Standard Schaltwerke |
19+
| 7 | 9 | 01. Dezember | Rechnerarithmetik |
20+
| | 10 | 03. Dezember | CPU Motivation |
21+
| 8 | 11 | 15. Dezember | Modell CPU |
22+
| 9 | | 17. Dezember | Befehlsabarbeitung |
23+
| | 12 | 22. Dezember | RISC und Pipelining |
24+
| 10 | 13 | 12. Januar | Eingebettete Systeme |
25+
| 11 | 16 | 14. Januar | |
26+
| | 17 | 19. Januar | |
27+
| 12 | 18 | 26. Januar | |
28+
| 13 | 19 | 28. Januar | |
29+
| | 20 | 2. Februar | |
30+
| 14 | 21 | 9. Februar | |
31+
| 15 | 22 | 11. Februar | |
32+

exampleCode/13_AVR_CPU/Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
TARGET = main
2+
3+
CTRL = atmega328p
4+
STK = arduino
5+
6+
CC = avr-gcc
7+
OC = avr-objcopy
8+
CPFLAGS = -mno-interrupts
9+
LDFLAGS = -j .text -j .data
10+
11+
AVRDUDE = avrdude
12+
AVRDUDE_FLAGS = -P /dev/ttyUSB0
13+
AVRDUDE_FLAGS += -B 57600
14+
AVRDUDE_FLAGS += -c $(STK)
15+
AVRDUDE_FLAGS += -p m328p
16+
AVRDUDE_FLAGS += -v -D -U flash:w:$(TARGET).hex:i
17+
18+
.PHONY: all
19+
20+
all:
21+
@echo "compiling"
22+
$(CC) -c -o $(TARGET).o $(CPFLAGS) -Os -mmcu=$(CTRL) $(TARGET).c
23+
@echo "linking"
24+
@$(CC) -mmcu=$(CTRL) $(TARGET).o -o $(TARGET).elf
25+
@echo "generate properly output format"
26+
@$(OC) $(LDFLAGS) -O ihex $(TARGET).elf $(TARGET).hex
27+
avr-size --mcu=$(CTRL) $(TARGET).elf
28+
29+
program: all
30+
@echo "Programing the device"
31+
@echo $(AVRDUDE_FLAGS)
32+
$(AVRDUDE) $(AVRDUDE_FLAGS)
33+
34+
asm: all
35+
@echo "Generating assembler code"
36+
avr-objdump -d -S $(TARGET).elf > $(TARGET).asm
37+
38+
clean:
39+
@echo "Cleaning"
40+
@rm -rf $(TARGET).hex $(TARGET).o $(TARGET).elf *~
41+
42+
com: program
43+
@echo "Opening Serial connection"
44+
gtkterm -p /dev/ttyACM0 -s 9600 -r "-"

exampleCode/13_AVR_CPU/main.asm

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
main.elf: file format elf32-avr
3+
4+
5+
Disassembly of section .text:
6+
7+
00000000 <__vectors>:
8+
0: 0c 94 34 00 jmp 0x68 ; 0x68 <__ctors_end>
9+
4: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
10+
8: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
11+
c: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
12+
10: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
13+
14: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
14+
18: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
15+
1c: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
16+
20: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
17+
24: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
18+
28: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
19+
2c: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
20+
30: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
21+
34: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
22+
38: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
23+
3c: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
24+
40: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
25+
44: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
26+
48: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
27+
4c: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
28+
50: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
29+
54: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
30+
58: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
31+
5c: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
32+
60: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
33+
64: 0c 94 3e 00 jmp 0x7c ; 0x7c <__bad_interrupt>
34+
35+
00000068 <__ctors_end>:
36+
68: 11 24 eor r1, r1
37+
6a: 1f be out 0x3f, r1 ; 63
38+
6c: cf ef ldi r28, 0xFF ; 255
39+
6e: d8 e0 ldi r29, 0x08 ; 8
40+
70: de bf out 0x3e, r29 ; 62
41+
72: cd bf out 0x3d, r28 ; 61
42+
74: 0e 94 40 00 call 0x80 ; 0x80 <main>
43+
78: 0c 94 4f 00 jmp 0x9e ; 0x9e <_exit>
44+
45+
0000007c <__bad_interrupt>:
46+
7c: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
47+
48+
00000080 <main>:
49+
80: 20 9a sbi 0x04, 0 ; 4
50+
82: 91 e0 ldi r25, 0x01 ; 1
51+
84: 85 b1 in r24, 0x05 ; 5
52+
86: 89 27 eor r24, r25
53+
88: 85 b9 out 0x05, r24 ; 5
54+
8a: 2f e7 ldi r18, 0x7F ; 127
55+
8c: 33 e3 ldi r19, 0x33 ; 51
56+
8e: 86 e0 ldi r24, 0x06 ; 6
57+
90: 21 50 subi r18, 0x01 ; 1
58+
92: 30 40 sbci r19, 0x00 ; 0
59+
94: 80 40 sbci r24, 0x00 ; 0
60+
96: e1 f7 brne .-8 ; 0x90 <main+0x10>
61+
98: 00 c0 rjmp .+0 ; 0x9a <main+0x1a>
62+
9a: 00 00 nop
63+
9c: f3 cf rjmp .-26 ; 0x84 <main+0x4>
64+
65+
0000009e <_exit>:
66+
9e: f8 94 cli
67+
68+
000000a0 <__stop_program>:
69+
a0: ff cf rjmp .-2 ; 0xa0 <__stop_program>

exampleCode/13_AVR_CPU/main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#define F_CPU 8000000UL
2+
3+
#include <avr/io.h>
4+
#include <util/delay.h>
5+
6+
int main (void) {
7+
8+
DDRB |= (1 << PB0);
9+
10+
while(1) {
11+
PORTB ^= (1 << PB0);
12+
_delay_ms(254);
13+
}
14+
15+
return 0;
16+
}

exampleCode/13_AVR_CPU/main.elf

6.3 KB
Binary file not shown.

exampleCode/13_AVR_CPU/main.hex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
:100000000C9434000C943E000C943E000C943E0082
2+
:100010000C943E000C943E000C943E000C943E0068
3+
:100020000C943E000C943E000C943E000C943E0058
4+
:100030000C943E000C943E000C943E000C943E0048
5+
:100040000C943E000C943E000C943E000C943E0038
6+
:100050000C943E000C943E000C943E000C943E0028
7+
:100060000C943E000C943E0011241FBECFEFD8E04C
8+
:10007000DEBFCDBF0E9440000C944F000C940000E6
9+
:10008000209A91E085B1892785B92FE733E386E08F
10+
:10009000215030408040E1F700C00000F3CFF894D9
11+
:0200A000FFCF90
12+
:00000001FF

exampleCode/13_AVR_CPU/main.o

884 Bytes
Binary file not shown.

images/13_AVR_CPU/ATTINY13A.jpeg

17.6 KB
Loading
115 KB
Loading

0 commit comments

Comments
 (0)