diff --git a/MIC-Week1/.vs/MIC-Week1/v14/.atsuo b/MIC-Week1/.vs/MIC-Week1/v14/.atsuo
index 1a56256..d16ecf6 100644
Binary files a/MIC-Week1/.vs/MIC-Week1/v14/.atsuo and b/MIC-Week1/.vs/MIC-Week1/v14/.atsuo differ
diff --git a/MIC-Week1/MIC-Week1.cproj b/MIC-Week1/MIC-Week1.cproj
index a5fd715..4a9602d 100644
--- a/MIC-Week1/MIC-Week1.cproj
+++ b/MIC-Week1/MIC-Week1.cproj
@@ -55,71 +55,71 @@
- -mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.90\gcc\dev\atmega128"
- True
- True
- True
- True
- True
- False
- True
- True
-
-
- NDEBUG
-
-
-
-
- %24(PackRepoDir)\atmel\ATmega_DFP\1.0.90\include
-
-
- Optimize for size (-Os)
- True
- True
- True
-
-
- libm
-
-
-
+ -mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.90\gcc\dev\atmega128"
+ True
+ True
+ True
+ True
+ True
+ False
+ True
+ True
+
+
+ NDEBUG
+
+
+
+
+ %24(PackRepoDir)\atmel\ATmega_DFP\1.0.90\include
+
+
+ Optimize for size (-Os)
+ True
+ True
+ True
+
+
+ libm
+
+
+
- -mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.90\gcc\dev\atmega128"
- True
- True
- True
- True
- True
- False
- True
- True
-
-
- DEBUG
-
-
-
-
- %24(PackRepoDir)\atmel\ATmega_DFP\1.0.90\include
-
-
- Optimize (-O1)
- True
- True
- Default (-g2)
- True
-
-
- libm
-
-
- Default (-Wa,-g)
-
+ -mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.90\gcc\dev\atmega128"
+ True
+ True
+ True
+ True
+ True
+ False
+ True
+ True
+
+
+ DEBUG
+
+
+
+
+ %24(PackRepoDir)\atmel\ATmega_DFP\1.0.90\include
+
+
+ Optimize (-O1)
+ True
+ True
+ Default (-g2)
+ True
+
+
+ libm
+
+
+ Default (-Wa,-g)
+
diff --git a/MIC-Week2/Debug/MIC-Week2.lss b/MIC-Week2/Debug/MIC-Week2.lss
index afc0f92..3b75b42 100644
--- a/MIC-Week2/Debug/MIC-Week2.lss
+++ b/MIC-Week2/Debug/MIC-Week2.lss
@@ -3,31 +3,31 @@ MIC-Week2.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
- 0 .data 00000010 00800100 0000022c 000002c0 2**0
+ 0 .data 0000006c 00800100 00000294 00000328 2**0
CONTENTS, ALLOC, LOAD, DATA
- 1 .text 0000022c 00000000 00000000 00000094 2**1
+ 1 .text 00000294 00000000 00000000 00000094 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
- 2 .bss 00000002 00800110 00800110 000002d0 2**0
+ 2 .bss 00000004 0080016c 0080016c 00000394 2**0
ALLOC
- 3 .comment 00000030 00000000 00000000 000002d0 2**0
+ 3 .comment 00000030 00000000 00000000 00000394 2**0
CONTENTS, READONLY
- 4 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 00000300 2**2
+ 4 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 000003c4 2**2
CONTENTS, READONLY
- 5 .debug_aranges 00000070 00000000 00000000 0000033c 2**0
+ 5 .debug_aranges 00000078 00000000 00000000 00000400 2**0
CONTENTS, READONLY, DEBUGGING
- 6 .debug_info 000003fb 00000000 00000000 000003ac 2**0
+ 6 .debug_info 000004e3 00000000 00000000 00000478 2**0
CONTENTS, READONLY, DEBUGGING
- 7 .debug_abbrev 00000216 00000000 00000000 000007a7 2**0
+ 7 .debug_abbrev 00000277 00000000 00000000 0000095b 2**0
CONTENTS, READONLY, DEBUGGING
- 8 .debug_line 00000303 00000000 00000000 000009bd 2**0
+ 8 .debug_line 00000392 00000000 00000000 00000bd2 2**0
CONTENTS, READONLY, DEBUGGING
- 9 .debug_frame 00000174 00000000 00000000 00000cc0 2**2
+ 9 .debug_frame 00000184 00000000 00000000 00000f64 2**2
CONTENTS, READONLY, DEBUGGING
- 10 .debug_str 000001f8 00000000 00000000 00000e34 2**0
+ 10 .debug_str 00000223 00000000 00000000 000010e8 2**0
CONTENTS, READONLY, DEBUGGING
- 11 .debug_loc 00000346 00000000 00000000 0000102c 2**0
+ 11 .debug_loc 000003ae 00000000 00000000 0000130b 2**0
CONTENTS, READONLY, DEBUGGING
- 12 .debug_ranges 00000078 00000000 00000000 00001372 2**0
+ 12 .debug_ranges 000000b0 00000000 00000000 000016b9 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
@@ -35,15 +35,15 @@ Disassembly of section .text:
00000000 <__vectors>:
0: 45 c0 rjmp .+138 ; 0x8c <__ctors_end>
2: 00 00 nop
- 4: 61 c0 rjmp .+194 ; 0xc8 <__vector_1>
+ 4: 72 c0 rjmp .+228 ; 0xea <__vector_1>
6: 00 00 nop
- 8: 90 c0 rjmp .+288 ; 0x12a <__vector_2>
+ 8: a1 c0 rjmp .+322 ; 0x14c <__vector_2>
a: 00 00 nop
- c: c1 c0 rjmp .+386 ; 0x190 <__vector_3>
+ c: d2 c0 rjmp .+420 ; 0x1b2 <__vector_3>
e: 00 00 nop
10: 5a c0 rjmp .+180 ; 0xc6 <__bad_interrupt>
12: 00 00 nop
- 14: 64 c0 rjmp .+200 ; 0xde <__vector_5>
+ 14: 75 c0 rjmp .+234 ; 0x100 <__vector_5>
16: 00 00 nop
18: 56 c0 rjmp .+172 ; 0xc6 <__bad_interrupt>
1a: 00 00 nop
@@ -116,20 +116,20 @@ Disassembly of section .text:
98: 11 e0 ldi r17, 0x01 ; 1
9a: a0 e0 ldi r26, 0x00 ; 0
9c: b1 e0 ldi r27, 0x01 ; 1
- 9e: ec e2 ldi r30, 0x2C ; 44
+ 9e: e4 e9 ldi r30, 0x94 ; 148
a0: f2 e0 ldi r31, 0x02 ; 2
a2: 00 e0 ldi r16, 0x00 ; 0
a4: 0b bf out 0x3b, r16 ; 59
a6: 02 c0 rjmp .+4 ; 0xac <__do_copy_data+0x14>
a8: 07 90 elpm r0, Z+
aa: 0d 92 st X+, r0
- ac: a0 31 cpi r26, 0x10 ; 16
+ ac: ac 36 cpi r26, 0x6C ; 108
ae: b1 07 cpc r27, r17
b0: d9 f7 brne .-10 ; 0xa8 <__do_copy_data+0x10>
000000b2 <__do_clear_bss>:
b2: 21 e0 ldi r18, 0x01 ; 1
- b4: a0 e1 ldi r26, 0x10 ; 16
+ b4: ac e6 ldi r26, 0x6C ; 108
b6: b1 e0 ldi r27, 0x01 ; 1
b8: 01 c0 rjmp .+2 ; 0xbc <.do_clear_bss_start>
@@ -137,312 +137,283 @@ Disassembly of section .text:
ba: 1d 92 st X+, r1
000000bc <.do_clear_bss_start>:
- bc: a2 31 cpi r26, 0x12 ; 18
+ bc: a0 37 cpi r26, 0x70 ; 112
be: b2 07 cpc r27, r18
c0: e1 f7 brne .-8 ; 0xba <.do_clear_bss_loop>
- c2: b1 d0 rcall .+354 ; 0x226
- c4: b1 c0 rjmp .+354 ; 0x228 <_exit>
+ c2: e5 d0 rcall .+458 ; 0x28e
+ c4: e5 c0 rjmp .+458 ; 0x290 <_exit>
000000c6 <__bad_interrupt>:
c6: 9c cf rjmp .-200 ; 0x0 <__vectors>
-000000c8 <__vector_1>:
- sei();
-
- while(1)
- {
- wait(500);
- }
- c8: 1f 92 push r1
- ca: 0f 92 push r0
- cc: 0f b6 in r0, 0x3f ; 63
- ce: 0f 92 push r0
- d0: 11 24 eor r1, r1
- d2: 95 9a sbi 0x12, 5 ; 18
- d4: 0f 90 pop r0
- d6: 0f be out 0x3f, r0 ; 63
- d8: 0f 90 pop r0
- da: 1f 90 pop r1
- dc: 18 95 reti
-
-000000de <__vector_5>:
- de: 1f 92 push r1
- e0: 0f 92 push r0
- e2: 0f b6 in r0, 0x3f ; 63
- e4: 0f 92 push r0
- e6: 11 24 eor r1, r1
- e8: 8f 93 push r24
- ea: 9f 93 push r25
- ec: 93 b1 in r25, 0x03 ; 3
- ee: 81 e0 ldi r24, 0x01 ; 1
- f0: 89 27 eor r24, r25
- f2: 83 b9 out 0x03, r24 ; 3
- f4: 9f 91 pop r25
- f6: 8f 91 pop r24
- f8: 0f 90 pop r0
- fa: 0f be out 0x3f, r0 ; 63
- fc: 0f 90 pop r0
- fe: 1f 90 pop r1
- 100: 18 95 reti
-
-00000102 :
-}
-
-void shift(int i)
+000000c8 :
+void display(int d, int dot)
{
-
- if(i)
- 102: 89 2b or r24, r25
- 104: 21 f0 breq .+8 ; 0x10e
- PORTC = (PORTC>>1);
- 106: 85 b3 in r24, 0x15 ; 21
- 108: 86 95 lsr r24
- 10a: 85 bb out 0x15, r24 ; 21
- 10c: 03 c0 rjmp .+6 ; 0x114
+ if(dot)
+ PORTD = data[d] | 0b10000000;
else
- PORTC = (PORTC<<1);
- 10e: 85 b3 in r24, 0x15 ; 21
- 110: 88 0f add r24, r24
- 112: 85 bb out 0x15, r24 ; 21
-
- //Als het looplicht aan het einde is
- if (PORTC >= 0x80)
- 114: af 9b sbis 0x15, 7 ; 21
- 116: 03 c0 rjmp .+6 ; 0x11e
- {
- PORTC= 0x01;
- 118: 81 e0 ldi r24, 0x01 ; 1
- 11a: 85 bb out 0x15, r24 ; 21
- 11c: 08 95 ret
- }
- //Als het looplicht aan het begin is
- else if (PORTC < 0x1)
- 11e: 85 b3 in r24, 0x15 ; 21
- 120: 81 11 cpse r24, r1
- 122: 02 c0 rjmp .+4 ; 0x128
- {
- PORTC= 0x80;
- 124: 80 e8 ldi r24, 0x80 ; 128
- 126: 85 bb out 0x15, r24 ; 21
- 128: 08 95 ret
+ PORTD = data[d];
+ c8: 18 16 cp r1, r24
+ ca: 19 06 cpc r1, r25
+ cc: 6c f4 brge .+26 ; 0xe8
+ ce: 20 e0 ldi r18, 0x00 ; 0
+ d0: 30 e0 ldi r19, 0x00 ; 0
+ d2: ef ec ldi r30, 0xCF ; 207
+ d4: f7 e0 ldi r31, 0x07 ; 7
+ d6: 31 97 sbiw r30, 0x01 ; 1
+ d8: f1 f7 brne .-4 ; 0xd6
+ da: 00 c0 rjmp .+0 ; 0xdc
+ dc: 00 00 nop
+ de: 2f 5f subi r18, 0xFF ; 255
+ e0: 3f 4f sbci r19, 0xFF ; 255
+ e2: 28 17 cp r18, r24
+ e4: 39 07 cpc r19, r25
+ e6: a9 f7 brne .-22 ; 0xd2
+ e8: 08 95 ret
-0000012a <__vector_2>:
- PORTD |= (1<<5);
+000000ea <__vector_1>:
+ ea: 1f 92 push r1
+ ec: 0f 92 push r0
+ ee: 0f b6 in r0, 0x3f ; 63
+ f0: 0f 92 push r0
+ f2: 11 24 eor r1, r1
+ f4: 95 9a sbi 0x12, 5 ; 18
+ f6: 0f 90 pop r0
+ f8: 0f be out 0x3f, r0 ; 63
+ fa: 0f 90 pop r0
+ fc: 1f 90 pop r1
+ fe: 18 95 reti
+
+00000100 <__vector_5>:
+ 100: 1f 92 push r1
+ 102: 0f 92 push r0
+ 104: 0f b6 in r0, 0x3f ; 63
+ 106: 0f 92 push r0
+ 108: 11 24 eor r1, r1
+ 10a: 8f 93 push r24
+ 10c: 9f 93 push r25
+ 10e: 93 b1 in r25, 0x03 ; 3
+ 110: 81 e0 ldi r24, 0x01 ; 1
+ 112: 89 27 eor r24, r25
+ 114: 83 b9 out 0x03, r24 ; 3
+ 116: 9f 91 pop r25
+ 118: 8f 91 pop r24
+ 11a: 0f 90 pop r0
+ 11c: 0f be out 0x3f, r0 ; 63
+ 11e: 0f 90 pop r0
+ 120: 1f 90 pop r1
+ 122: 18 95 reti
+
+00000124 :
+ 124: 89 2b or r24, r25
+ 126: 21 f0 breq .+8 ; 0x130
+ 128: 85 b3 in r24, 0x15 ; 21
+ 12a: 86 95 lsr r24
+ 12c: 85 bb out 0x15, r24 ; 21
+ 12e: 03 c0 rjmp .+6 ; 0x136
+ 130: 85 b3 in r24, 0x15 ; 21
+ 132: 88 0f add r24, r24
+ 134: 85 bb out 0x15, r24 ; 21
+ 136: af 9b sbis 0x15, 7 ; 21
+ 138: 03 c0 rjmp .+6 ; 0x140
+ 13a: 81 e0 ldi r24, 0x01 ; 1
+ 13c: 85 bb out 0x15, r24 ; 21
+ 13e: 08 95 ret
+ 140: 85 b3 in r24, 0x15 ; 21
+ 142: 81 11 cpse r24, r1
+ 144: 02 c0 rjmp .+4 ; 0x14a
+ 146: 80 e8 ldi r24, 0x80 ; 128
+ 148: 85 bb out 0x15, r24 ; 21
+ 14a: 08 95 ret
+
+0000014c <__vector_2>:
+ 14c: 1f 92 push r1
+ 14e: 0f 92 push r0
+ 150: 0f b6 in r0, 0x3f ; 63
+ 152: 0f 92 push r0
+ 154: 11 24 eor r1, r1
+ 156: 0b b6 in r0, 0x3b ; 59
+ 158: 0f 92 push r0
+ 15a: 2f 93 push r18
+ 15c: 3f 93 push r19
+ 15e: 4f 93 push r20
+ 160: 5f 93 push r21
+ 162: 6f 93 push r22
+ 164: 7f 93 push r23
+ 166: 8f 93 push r24
+ 168: 9f 93 push r25
+ 16a: af 93 push r26
+ 16c: bf 93 push r27
+ 16e: ef 93 push r30
+ 170: ff 93 push r31
+ 172: 80 91 6e 01 lds r24, 0x016E
+ 176: 90 91 6f 01 lds r25, 0x016F
+ 17a: 00 97 sbiw r24, 0x00 ; 0
+ 17c: 11 f4 brne .+4 ; 0x182 <__vector_2+0x36>
+ 17e: 95 98 cbi 0x12, 5 ; 18
+ 180: 05 c0 rjmp .+10 ; 0x18c <__vector_2+0x40>
+ 182: 01 97 sbiw r24, 0x01 ; 1
+ 184: 19 f4 brne .+6 ; 0x18c <__vector_2+0x40>
+ 186: 81 e0 ldi r24, 0x01 ; 1
+ 188: 90 e0 ldi r25, 0x00 ; 0
+ 18a: cc df rcall .-104 ; 0x124
+ 18c: ff 91 pop r31
+ 18e: ef 91 pop r30
+ 190: bf 91 pop r27
+ 192: af 91 pop r26
+ 194: 9f 91 pop r25
+ 196: 8f 91 pop r24
+ 198: 7f 91 pop r23
+ 19a: 6f 91 pop r22
+ 19c: 5f 91 pop r21
+ 19e: 4f 91 pop r20
+ 1a0: 3f 91 pop r19
+ 1a2: 2f 91 pop r18
+ 1a4: 0f 90 pop r0
+ 1a6: 0b be out 0x3b, r0 ; 59
+ 1a8: 0f 90 pop r0
+ 1aa: 0f be out 0x3f, r0 ; 63
+ 1ac: 0f 90 pop r0
+ 1ae: 1f 90 pop r1
+ 1b0: 18 95 reti
+
+000001b2 <__vector_3>:
+ 1b2: 1f 92 push r1
+ 1b4: 0f 92 push r0
+ 1b6: 0f b6 in r0, 0x3f ; 63
+ 1b8: 0f 92 push r0
+ 1ba: 11 24 eor r1, r1
+ 1bc: 0b b6 in r0, 0x3b ; 59
+ 1be: 0f 92 push r0
+ 1c0: 2f 93 push r18
+ 1c2: 3f 93 push r19
+ 1c4: 4f 93 push r20
+ 1c6: 5f 93 push r21
+ 1c8: 6f 93 push r22
+ 1ca: 7f 93 push r23
+ 1cc: 8f 93 push r24
+ 1ce: 9f 93 push r25
+ 1d0: af 93 push r26
+ 1d2: bf 93 push r27
+ 1d4: ef 93 push r30
+ 1d6: ff 93 push r31
+ 1d8: 80 e0 ldi r24, 0x00 ; 0
+ 1da: 90 e0 ldi r25, 0x00 ; 0
+ 1dc: a3 df rcall .-186 ; 0x124
+ 1de: ff 91 pop r31
+ 1e0: ef 91 pop r30
+ 1e2: bf 91 pop r27
+ 1e4: af 91 pop r26
+ 1e6: 9f 91 pop r25
+ 1e8: 8f 91 pop r24
+ 1ea: 7f 91 pop r23
+ 1ec: 6f 91 pop r22
+ 1ee: 5f 91 pop r21
+ 1f0: 4f 91 pop r20
+ 1f2: 3f 91 pop r19
+ 1f4: 2f 91 pop r18
+ 1f6: 0f 90 pop r0
+ 1f8: 0b be out 0x3b, r0 ; 59
+ 1fa: 0f 90 pop r0
+ 1fc: 0f be out 0x3f, r0 ; 63
+ 1fe: 0f 90 pop r0
+ 200: 1f 90 pop r1
+ 202: 18 95 reti
+
+00000204 :
}
-/******************************************************************/
-ISR( INT1_vect )
-{
- 12a: 1f 92 push r1
- 12c: 0f 92 push r0
- 12e: 0f b6 in r0, 0x3f ; 63
- 130: 0f 92 push r0
- 132: 11 24 eor r1, r1
- 134: 0b b6 in r0, 0x3b ; 59
- 136: 0f 92 push r0
- 138: 2f 93 push r18
- 13a: 3f 93 push r19
- 13c: 4f 93 push r20
- 13e: 5f 93 push r21
- 140: 6f 93 push r22
- 142: 7f 93 push r23
- 144: 8f 93 push r24
- 146: 9f 93 push r25
- 148: af 93 push r26
- 14a: bf 93 push r27
- 14c: ef 93 push r30
- 14e: ff 93 push r31
-inputs:
-outputs:
-notes: Clear PORTD.5
-Version : DMK, Initial code
-*******************************************************************/
- if(opdr==0)
- 150: 80 91 10 01 lds r24, 0x0110
- 154: 90 91 11 01 lds r25, 0x0111
- 158: 00 97 sbiw r24, 0x00 ; 0
- 15a: 11 f4 brne .+4 ; 0x160 <__vector_2+0x36>
- {
- PORTD &= ~(1<<5);
- 15c: 95 98 cbi 0x12, 5 ; 18
- 15e: 05 c0 rjmp .+10 ; 0x16a <__vector_2+0x40>
- }
- else if(opdr==1)
- 160: 01 97 sbiw r24, 0x01 ; 1
- 162: 19 f4 brne .+6 ; 0x16a <__vector_2+0x40>
- {
- shift(1);
- 164: 81 e0 ldi r24, 0x01 ; 1
- 166: 90 e0 ldi r25, 0x00 ; 0
- 168: cc df rcall .-104 ; 0x102
- }
-}
- 16a: ff 91 pop r31
- 16c: ef 91 pop r30
- 16e: bf 91 pop r27
- 170: af 91 pop r26
- 172: 9f 91 pop r25
- 174: 8f 91 pop r24
- 176: 7f 91 pop r23
- 178: 6f 91 pop r22
- 17a: 5f 91 pop r21
- 17c: 4f 91 pop r20
- 17e: 3f 91 pop r19
- 180: 2f 91 pop r18
- 182: 0f 90 pop r0
- 184: 0b be out 0x3b, r0 ; 59
- 186: 0f 90 pop r0
- 188: 0f be out 0x3f, r0 ; 63
- 18a: 0f 90 pop r0
- 18c: 1f 90 pop r1
- 18e: 18 95 reti
-
-00000190 <__vector_3>:
-inputs:
-outputs:
-notes: Clear PORTD.3
-Version : DMK, Initial code
-*******************************************************************/
+void opgave4(void)
{
- 190: 1f 92 push r1
- 192: 0f 92 push r0
- 194: 0f b6 in r0, 0x3f ; 63
- 196: 0f 92 push r0
- 198: 11 24 eor r1, r1
- 19a: 0b b6 in r0, 0x3b ; 59
- 19c: 0f 92 push r0
- 19e: 2f 93 push r18
- 1a0: 3f 93 push r19
- 1a2: 4f 93 push r20
- 1a4: 5f 93 push r21
- 1a6: 6f 93 push r22
- 1a8: 7f 93 push r23
- 1aa: 8f 93 push r24
- 1ac: 9f 93 push r25
- 1ae: af 93 push r26
- 1b0: bf 93 push r27
- 1b2: ef 93 push r30
- 1b4: ff 93 push r31
- shift(0);
- 1b6: 80 e0 ldi r24, 0x00 ; 0
- 1b8: 90 e0 ldi r25, 0x00 ; 0
- 1ba: a3 df rcall .-186 ; 0x102
-}
- 1bc: ff 91 pop r31
- 1be: ef 91 pop r30
- 1c0: bf 91 pop r27
- 1c2: af 91 pop r26
- 1c4: 9f 91 pop r25
- 1c6: 8f 91 pop r24
- 1c8: 7f 91 pop r23
- 1ca: 6f 91 pop r22
- 1cc: 5f 91 pop r21
- 1ce: 4f 91 pop r20
- 1d0: 3f 91 pop r19
- 1d2: 2f 91 pop r18
- 1d4: 0f 90 pop r0
- 1d6: 0b be out 0x3b, r0 ; 59
- 1d8: 0f 90 pop r0
- 1da: 0f be out 0x3f, r0 ; 63
- 1dc: 0f 90 pop r0
- 1de: 1f 90 pop r1
- 1e0: 18 95 reti
-
-000001e2 :
- }
-}
-
-void opgave3()
-{
- DDRC = 0x00;
- 1e2: 14 ba out 0x14, r1 ; 20
DDRD = 0xFF;
- 1e4: 8f ef ldi r24, 0xFF ; 255
- 1e6: 81 bb out 0x11, r24 ; 17
-
- int count = 0;
- 1e8: 80 e0 ldi r24, 0x00 ; 0
- 1ea: 90 e0 ldi r25, 0x00 ; 0
- display(count);
- }
-}
-void display(int d)
-{
- PORTD = data[d];
- 1ec: a0 e0 ldi r26, 0x00 ; 0
- 1ee: b1 e0 ldi r27, 0x01 ; 1
-
- int count = 0;
+ 204: 8f ef ldi r24, 0xFF ; 255
+ 206: 81 bb out 0x11, r24 ; 17
+ DDRC = 0x00;
+ 208: 14 ba out 0x14, r1 ; 20
while(1)
{
- if(0b00000001 & PINC == 0b00000001)
- 1f0: 23 b3 in r18, 0x13 ; 19
- 1f2: 21 30 cpi r18, 0x01 ; 1
- 1f4: 11 f4 brne .+4 ; 0x1fa
+ //Als een knop ingedrukt wordt, wordt de waarde daarvan de snelheid. Werkt niet met system interrupts, dus je moet de knop soms ingedrukt houden
+ if(PINC != 0 )
+ 20a: 83 b3 in r24, 0x13 ; 19
+ 20c: 88 23 and r24, r24
+ 20e: 31 f0 breq .+12 ; 0x21c
{
- count++;
- 1f6: 01 96 adiw r24, 0x01 ; 1
- 1f8: 01 c0 rjmp .+2 ; 0x1fc
+ speed = PINC;
+ 210: 83 b3 in r24, 0x13 ; 19
+ 212: 90 e0 ldi r25, 0x00 ; 0
+ 214: 90 93 6a 01 sts 0x016A, r25
+ 218: 80 93 69 01 sts 0x0169, r24
}
- else if(0b00000010 & PINC == 0b00000010)
- 1fa: 23 b3 in r18, 0x13 ; 19
+
+ //Schrijf de data van het huidige patroon naar PORTD
+ PORTD = pattern[count].data;
+ 21c: 80 91 6c 01 lds r24, 0x016C
+ 220: 90 91 6d 01 lds r25, 0x016D
+ 224: fc 01 movw r30, r24
+ 226: ee 0f add r30, r30
+ 228: ff 1f adc r31, r31
+ 22a: 8e 0f add r24, r30
+ 22c: 9f 1f adc r25, r31
+ 22e: fc 01 movw r30, r24
+ 230: e0 50 subi r30, 0x00 ; 0
+ 232: ff 4f sbci r31, 0xFF ; 255
+ 234: 80 81 ld r24, Z
+ 236: 82 bb out 0x12, r24 ; 18
+ //Wacht het aantal milliseconde dat in het huidige patroon staat
+ wait(pattern[count].delay * speed);
+ 238: 80 91 6c 01 lds r24, 0x016C
+ 23c: 90 91 6d 01 lds r25, 0x016D
+ 240: fc 01 movw r30, r24
+ 242: ee 0f add r30, r30
+ 244: ff 1f adc r31, r31
+ 246: 8e 0f add r24, r30
+ 248: 9f 1f adc r25, r31
+ 24a: fc 01 movw r30, r24
+ 24c: e0 50 subi r30, 0x00 ; 0
+ 24e: ff 4f sbci r31, 0xFF ; 255
+ 250: 20 91 69 01 lds r18, 0x0169
+ 254: 30 91 6a 01 lds r19, 0x016A
+ 258: 81 81 ldd r24, Z+1 ; 0x01
+ 25a: 92 81 ldd r25, Z+2 ; 0x02
+ 25c: ac 01 movw r20, r24
+ 25e: 24 9f mul r18, r20
+ 260: c0 01 movw r24, r0
+ 262: 25 9f mul r18, r21
+ 264: 90 0d add r25, r0
+ 266: 34 9f mul r19, r20
+ 268: 90 0d add r25, r0
+ 26a: 11 24 eor r1, r1
+ 26c: 2d df rcall .-422 ; 0xc8
+
+ count++; //patroon verder
+ 26e: 80 91 6c 01 lds r24, 0x016C
+ 272: 90 91 6d 01 lds r25, 0x016D
+ 276: 01 96 adiw r24, 0x01 ; 1
+ 278: 90 93 6d 01 sts 0x016D, r25
+ 27c: 80 93 6c 01 sts 0x016C, r24
+
+ //als alle patronen geweest zijn, opnieuw beginnen
+ if(count >= NELEMS(pattern))
+ 280: 83 97 sbiw r24, 0x23 ; 35
+ 282: 18 f2 brcs .-122 ; 0x20a
{
- count--;
- }
+ count = 0;
+ 284: 10 92 6d 01 sts 0x016D, r1
+ 288: 10 92 6c 01 sts 0x016C, r1
+ 28c: be cf rjmp .-132 ; 0x20a
- if(count > 15)
- 1fc: 80 31 cpi r24, 0x10 ; 16
- 1fe: 91 05 cpc r25, r1
- 200: 2c f0 brlt .+10 ; 0x20c
- display(count);
- }
-}
-void display(int d)
-{
- PORTD = data[d];
- 202: 1e 96 adiw r26, 0x0e ; 14
- 204: 2c 91 ld r18, X
- 206: 1e 97 sbiw r26, 0x0e ; 14
- 208: 22 bb out 0x12, r18 ; 18
- 20a: f2 cf rjmp .-28 ; 0x1f0
- count--;
- }
-
- if(count > 15)
- display(14);
- else if(count < 0)
- 20c: 99 23 and r25, r25
- 20e: 2c f4 brge .+10 ; 0x21a
- display(count);
- }
-}
-void display(int d)
-{
- PORTD = data[d];
- 210: 1e 96 adiw r26, 0x0e ; 14
- 212: 2c 91 ld r18, X
- 214: 1e 97 sbiw r26, 0x0e ; 14
- 216: 22 bb out 0x12, r18 ; 18
- 218: eb cf rjmp .-42 ; 0x1f0
- 21a: fc 01 movw r30, r24
- 21c: e0 50 subi r30, 0x00 ; 0
- 21e: ff 4f sbci r31, 0xFF ; 255
- 220: 20 81 ld r18, Z
- 222: 22 bb out 0x12, r18 ; 18
- 224: e5 cf rjmp .-54 ; 0x1f0
-
-00000226 :
-Version : DMK, Initial code
+0000028e :
*******************************************************************/
{
//powerpointOpg();
//opgave2();
- opgave3();
- 226: dd df rcall .-70 ; 0x1e2
+ //opgave3();
+ opgave4();
+ 28e: ba df rcall .-140 ; 0x204
-00000228 <_exit>:
- 228: f8 94 cli
+00000290 <_exit>:
+ 290: f8 94 cli
-0000022a <__stop_program>:
- 22a: ff cf rjmp .-2 ; 0x22a <__stop_program>
+00000292 <__stop_program>:
+ 292: ff cf rjmp .-2 ; 0x292 <__stop_program>
diff --git a/MIC-Week2/Debug/MIC-Week2.map b/MIC-Week2/Debug/MIC-Week2.map
index 9271fab..20ac49a 100644
--- a/MIC-Week2/Debug/MIC-Week2.map
+++ b/MIC-Week2/Debug/MIC-Week2.map
@@ -19,11 +19,12 @@ Discarded input sections
.text 0x00000000 0x0 main.o
.data 0x00000000 0x0 main.o
.bss 0x00000000 0x0 main.o
- .text.wait 0x00000000 0x22 main.o
.text.powerpointOpg
0x00000000 0x38 main.o
.text.opgave2 0x00000000 0x34 main.o
- .text.display 0x00000000 0xc main.o
+ .text.opgave3 0x00000000 0x74 main.o
+ .text.display 0x00000000 0x1e main.o
+ .data.data 0x00000000 0x10 main.o
.text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.9.2/avr51\libgcc.a(_exit.o)
.data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.9.2/avr51\libgcc.a(_exit.o)
.bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.9.2/avr51\libgcc.a(_exit.o)
@@ -190,7 +191,7 @@ END GROUP
.rela.plt
*(.rela.plt)
-.text 0x00000000 0x22c
+.text 0x00000000 0x294
*(.vectors)
.vectors 0x00000000 0x8c C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.0.90/gcc/dev/atmega128/avr51/crtatmega128.o
0x00000000 __vector_default
@@ -280,29 +281,31 @@ END GROUP
0x000000c6 __vector_20
0x000000c8 . = ALIGN (0x2)
*(.text.*)
+ .text.wait 0x000000c8 0x22 main.o
+ 0x000000c8 wait
.text.__vector_1
- 0x000000c8 0x16 main.o
- 0x000000c8 __vector_1
+ 0x000000ea 0x16 main.o
+ 0x000000ea __vector_1
.text.__vector_5
- 0x000000de 0x24 main.o
- 0x000000de __vector_5
- .text.shift 0x00000102 0x28 main.o
- 0x00000102 shift
+ 0x00000100 0x24 main.o
+ 0x00000100 __vector_5
+ .text.shift 0x00000124 0x28 main.o
+ 0x00000124 shift
.text.__vector_2
- 0x0000012a 0x66 main.o
- 0x0000012a __vector_2
+ 0x0000014c 0x66 main.o
+ 0x0000014c __vector_2
.text.__vector_3
- 0x00000190 0x52 main.o
- 0x00000190 __vector_3
- .text.opgave3 0x000001e2 0x44 main.o
- 0x000001e2 opgave3
- .text.main 0x00000226 0x2 main.o
- 0x00000226 main
- 0x00000228 . = ALIGN (0x2)
+ 0x000001b2 0x52 main.o
+ 0x000001b2 __vector_3
+ .text.opgave4 0x00000204 0x8a main.o
+ 0x00000204 opgave4
+ .text.main 0x0000028e 0x2 main.o
+ 0x0000028e main
+ 0x00000290 . = ALIGN (0x2)
*(.fini9)
- .fini9 0x00000228 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.9.2/avr51\libgcc.a(_exit.o)
- 0x00000228 _exit
- 0x00000228 exit
+ .fini9 0x00000290 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.9.2/avr51\libgcc.a(_exit.o)
+ 0x00000290 _exit
+ 0x00000290 exit
*(.fini9)
*(.fini8)
*(.fini8)
@@ -321,40 +324,45 @@ END GROUP
*(.fini1)
*(.fini1)
*(.fini0)
- .fini0 0x00000228 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.9.2/avr51\libgcc.a(_exit.o)
+ .fini0 0x00000290 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.9.2/avr51\libgcc.a(_exit.o)
*(.fini0)
- 0x0000022c _etext = .
+ 0x00000294 _etext = .
-.data 0x00800100 0x10 load address 0x0000022c
+.data 0x00800100 0x6c load address 0x00000294
0x00800100 PROVIDE (__data_start, .)
*(.data)
*(.data*)
- .data.data 0x00800100 0x10 main.o
- 0x00800100 data
+ .data.pattern 0x00800100 0x69 main.o
+ 0x00800100 pattern
+ .data.speed 0x00800169 0x2 main.o
+ 0x00800169 speed
*(.rodata)
*(.rodata*)
*(.gnu.linkonce.d*)
- 0x00800110 . = ALIGN (0x2)
- 0x00800110 _edata = .
- 0x00800110 PROVIDE (__data_end, .)
+ 0x0080016c . = ALIGN (0x2)
+ *fill* 0x0080016b 0x1
+ 0x0080016c _edata = .
+ 0x0080016c PROVIDE (__data_end, .)
-.bss 0x00800110 0x2
- 0x00800110 PROVIDE (__bss_start, .)
+.bss 0x0080016c 0x4
+ 0x0080016c PROVIDE (__bss_start, .)
*(.bss)
*(.bss*)
+ .bss.count 0x0080016c 0x2 main.o
+ 0x0080016c count
*(COMMON)
- COMMON 0x00800110 0x2 main.o
- 0x00800110 opdr
- 0x00800112 PROVIDE (__bss_end, .)
- 0x0000022c __data_load_start = LOADADDR (.data)
- 0x0000023c __data_load_end = (__data_load_start + SIZEOF (.data))
+ COMMON 0x0080016e 0x2 main.o
+ 0x0080016e opdr
+ 0x00800170 PROVIDE (__bss_end, .)
+ 0x00000294 __data_load_start = LOADADDR (.data)
+ 0x00000300 __data_load_end = (__data_load_start + SIZEOF (.data))
-.noinit 0x00800112 0x0
- 0x00800112 PROVIDE (__noinit_start, .)
+.noinit 0x00800170 0x0
+ 0x00800170 PROVIDE (__noinit_start, .)
*(.noinit*)
- 0x00800112 PROVIDE (__noinit_end, .)
- 0x00800112 _end = .
- 0x00800112 PROVIDE (__heap_start, .)
+ 0x00800170 PROVIDE (__noinit_end, .)
+ 0x00800170 _end = .
+ 0x00800170 PROVIDE (__heap_start, .)
.eeprom 0x00810000 0x0
*(.eeprom*)
@@ -418,38 +426,38 @@ END GROUP
.debug_sfnames
*(.debug_sfnames)
-.debug_aranges 0x00000000 0x70
+.debug_aranges 0x00000000 0x78
*(.debug_aranges)
.debug_aranges
- 0x00000000 0x70 main.o
+ 0x00000000 0x78 main.o
.debug_pubnames
*(.debug_pubnames)
-.debug_info 0x00000000 0x3fb
+.debug_info 0x00000000 0x4e3
*(.debug_info .gnu.linkonce.wi.*)
- .debug_info 0x00000000 0x3fb main.o
+ .debug_info 0x00000000 0x4e3 main.o
-.debug_abbrev 0x00000000 0x216
+.debug_abbrev 0x00000000 0x277
*(.debug_abbrev)
- .debug_abbrev 0x00000000 0x216 main.o
+ .debug_abbrev 0x00000000 0x277 main.o
-.debug_line 0x00000000 0x303
+.debug_line 0x00000000 0x392
*(.debug_line .debug_line.* .debug_line_end)
- .debug_line 0x00000000 0x303 main.o
+ .debug_line 0x00000000 0x392 main.o
-.debug_frame 0x00000000 0x174
+.debug_frame 0x00000000 0x184
*(.debug_frame)
- .debug_frame 0x00000000 0x174 main.o
+ .debug_frame 0x00000000 0x184 main.o
-.debug_str 0x00000000 0x1f8
+.debug_str 0x00000000 0x223
*(.debug_str)
- .debug_str 0x00000000 0x1f8 main.o
- 0x231 (size before relaxing)
+ .debug_str 0x00000000 0x223 main.o
+ 0x25c (size before relaxing)
-.debug_loc 0x00000000 0x346
+.debug_loc 0x00000000 0x3ae
*(.debug_loc)
- .debug_loc 0x00000000 0x346 main.o
+ .debug_loc 0x00000000 0x3ae main.o
.debug_macinfo
*(.debug_macinfo)
@@ -469,9 +477,9 @@ END GROUP
.debug_pubtypes
*(.debug_pubtypes)
-.debug_ranges 0x00000000 0x78
+.debug_ranges 0x00000000 0xb0
*(.debug_ranges)
- .debug_ranges 0x00000000 0x78 main.o
+ .debug_ranges 0x00000000 0xb0 main.o
.debug_macro
*(.debug_macro)
diff --git a/MIC-Week2/Debug/MIC-Week2.srec b/MIC-Week2/Debug/MIC-Week2.srec
index 3431967..1203c36 100644
--- a/MIC-Week2/Debug/MIC-Week2.srec
+++ b/MIC-Week2/Debug/MIC-Week2.srec
@@ -1,6 +1,6 @@
S01100004D49432D5765656B322E737265634F
-S113000045C0000061C0000090C00000C1C00000F5
-S11300105AC0000064C0000056C0000054C0000074
+S113000045C0000072C00000A1C00000D2C00000C2
+S11300105AC0000075C0000056C0000054C0000063
S113002052C0000050C000004EC000004CC0000090
S11300304AC0000048C0000046C0000044C00000A0
S113004042C0000040C000003EC000003CC00000B0
@@ -8,31 +8,44 @@ S11300503AC0000038C0000036C0000034C00000C0
S113006032C0000030C000002EC000002CC00000D0
S11300702AC0000028C0000026C0000024C00000E0
S113008022C0000020C000001EC0000011241FBEBA
-S1130090CFEFD0E1DEBFCDBF11E0A0E0B1E0ECE2F4
-S11300A0F2E000E00BBF02C007900D92A031B1074F
-S11300B0D9F721E0A0E1B1E001C01D92A231B2075D
-S11300C0E1F7B1D0B1C09CCF1F920F920FB60F923F
-S11300D01124959A0F900FBE0F901F9018951F92A0
-S11300E00F920FB60F9211248F939F9393B181E0D7
-S11300F0892783B99F918F910F900FBE0F901F9006
-S11301001895892B21F085B3869585BB03C085B3EB
-S1130110880F85BBAF9B03C081E085BB089585B381
-S1130120811102C080E885BB08951F920F920FB61B
-S11301300F9211240BB60F922F933F934F935F931B
-S11301406F937F938F939F93AF93BF93EF93FF939B
-S11301508091100190911101009711F4959805C0B8
-S1130160019719F481E090E0CCDFFF91EF91BF910A
-S1130170AF919F918F917F916F915F914F913F913B
-S11301802F910F900BBE0F900FBE0F901F901895DC
-S11301901F920F920FB60F9211240BB60F922F934A
-S11301A03F934F935F936F937F938F939F93AF93FB
-S11301B0BF93EF93FF9380E090E0A3DFFF91EF9173
-S11301C0BF91AF919F918F917F916F915F914F916B
-S11301D03F912F910F900BBE0F900FBE0F901F9069
-S11301E0189514BA8FEF81BB80E090E0A0E0B1E0F5
-S11301F023B3213011F4019601C023B3803191055A
-S11302002CF01E962C911E9722BBF2CF99232CF42E
-S11302101E962C911E9722BBEBCFFC01E050FF4FA2
-S10F0220208122BBE5CFDDDFF894FFCF86
-S113022C3F065B4F666D7D077F6F777C395E797116
+S1130090CFEFD0E1DEBFCDBF11E0A0E0B1E0E4E9F5
+S11300A0F2E000E00BBF02C007900D92AC36B1073E
+S11300B0D9F721E0ACE6B1E001C01D92A037B20748
+S11300C0E1F7E5D0E5C09CCF181619066CF420E0E2
+S11300D030E0EFECF7E03197F1F700C000002F5F5C
+S11300E03F4F28173907A9F708951F920F920FB6AB
+S11300F00F921124959A0F900FBE0F901F90189590
+S11301001F920F920FB60F9211248F939F9393B166
+S113011081E0892783B99F918F910F900FBE0F9033
+S11301201F901895892B21F085B3869585BB03C054
+S113013085B3880F85BBAF9B03C081E085BB089561
+S113014085B3811102C080E885BB08951F920F9288
+S11301500FB60F9211240BB60F922F933F934F9328
+S11301605F936F937F938F939F93AF93BF93EF931B
+S1130170FF9380916E0190916F01009711F495980F
+S113018005C0019719F481E090E0CCDFFF91EF9175
+S1130190BF91AF919F918F917F916F915F914F919B
+S11301A03F912F910F900BBE0F900FBE0F901F9099
+S11301B018951F920F920FB60F9211240BB60F923F
+S11301C02F933F934F935F936F937F938F939F935B
+S11301D0AF93BF93EF93FF9380E090E0A3DFFF9191
+S11301E0EF91BF91AF919F918F917F916F915F91AB
+S11301F04F913F912F910F900BBE0F900FBE0F9018
+S11302001F9018958FEF81BB14BA83B3882331F004
+S113021083B390E090936A018093690180916C01AB
+S113022090916D01FC01EE0FFF1F8E0F9F1FFC01CB
+S1130230E050FF4F808182BB80916C0190916D01F1
+S1130240FC01EE0FFF1F8E0F9F1FFC01E050FF4FBC
+S11302502091690130916A0181819281AC01249FCE
+S1130260C001259F900D349F900D11242DDF8091A6
+S11302706C0190916D01019690936D0180936C01D6
+S1130280839718F210926D0110926C01BECFBADF01
+S1070290F894FFCF0C
+S11302940164000264000464000864001064002023
+S11302A464000164002064001064000864000464B1
+S11302B400026400016400016400406400086400F6
+S11302C408640040640001640001640040640008A0
+S11302D4640008640048640009640009640012644A
+S11302E400246400096400126400246400096400A6
+S10F02F409640041640001640001000082
S9030000FC
diff --git a/MIC-Week2/main.c b/MIC-Week2/main.c
index 9daf3e9..cbc1a90 100644
--- a/MIC-Week2/main.c
+++ b/MIC-Week2/main.c
@@ -15,11 +15,16 @@
** -------------------------------------------------------------------------*/
#define F_CPU 8000000UL //CPU op 8MHz
+#define NELEMS(x) (sizeof(x) / sizeof(x[0])) //Geeft het aantal elementen uit een array terug.
+
#include
#include
#include
int opdr;
+int count = 0; //Counter voor opgave 4 om bij te houden bij welke pattern in de array hij is
+int speed = 1; //De snelheid voor opgave 4 van de patronen
+
/******************************************************************/
void wait( int ms )
/*
@@ -57,6 +62,34 @@ char data[16] = { //segment display
0b01110001 // F
};
+//Struct voor een pattroon. Eerste onderdeel is welke ledjes aan moeten staan, tweede hoelang deze dan aan moeten staan
+typedef struct {
+ unsigned char data;
+ unsigned int delay ;
+} PATTERN_STRUCT;
+
+//PIN 0 == SEG A
+//PIN 1 == SEG B
+//PIN 2 == SEG C
+//PIN 3 == SEG D
+//PIN 4 == SEG E
+//PIN 5 == SEG F
+//PIN 6 == SEG G
+//PIN 7 == SEG DP
+
+//Array van patronen die elkaar opvolgen.
+PATTERN_STRUCT pattern[] = {
+ {0b00000001, 100}, {0b00000010, 100}, {0b00000100, 100}, {0b00001000, 100}, {0b00010000, 100}, {0b00100000, 100}, {0b00000001, 100},
+ {0b00100000, 100}, {0b00010000, 100}, {0b00001000, 100}, {0b00000100, 100}, {0b00000010, 100}, {0b00000001, 100},
+ {0b00000001, 100}, {0b01000000, 100}, {0b00001000, 100}, //omlaag
+ {0b00001000, 100}, {0b01000000, 100}, {0b00000001, 100}, //omhoog
+ {0b00000001, 100}, {0b01000000, 100}, {0b00001000, 100}, //omlaag
+ {0b00001000, 100}, {0b01001000, 100}, {0b00001001, 100}, //omhoog
+ {0b00001001, 100}, {0b00010010, 100}, {0b00100100, 100}, {0b00001001, 100}, {0b00010010, 100}, {0b00100100, 100}, {0b00001001, 100},
+ {0b00001001, 100}, {0b01000001, 100}, {0b00000001, 100}
+};
+
+
/******************************************************************/
ISR( INT0_vect ) //powerpointopg
/*
@@ -126,7 +159,8 @@ Version : DMK, Initial code
{
//powerpointOpg();
//opgave2();
- opgave3();
+ //opgave3();
+ opgave4();
return 1;
}
@@ -202,24 +236,70 @@ void opgave3()
while(1)
{
- if(0b00000001 & PINC == 0b00000001)
+ wait(150);
+
+ //Button C0 & C1
+ if( (0x03 & PINC) == 0x03)
+ {
+ count = 0;
+ }
+ //Button C0
+ else if( (0x01 & PINC) != 0)
{
count++;
}
- else if(0b00000010 & PINC == 0b00000010)
+ //Button C1
+ else if( (0x02 & PINC) != 0)
{
count--;
}
if(count > 15)
- display(14);
+ {
+ display(14, 1);
+ count = 16;
+ }
else if(count < 0)
- display(14);
+ {
+ display(14, 1);
+ count = -1;
+ }
else
- display(count);
+ display(count, 0);
}
}
-void display(int d)
+void display(int d, int dot)
{
- PORTD = data[d];
+ if(dot)
+ PORTD = data[d] | 0b10000000;
+ else
+ PORTD = data[d];
+}
+
+void opgave4(void)
+{
+ DDRD = 0xFF;
+ DDRC = 0x00;
+
+ while(1)
+ {
+ //Als een knop ingedrukt wordt, wordt de waarde daarvan de snelheid. Werkt niet met system interrupts, dus je moet de knop soms ingedrukt houden
+ if(PINC != 0 )
+ {
+ speed = PINC;
+ }
+
+ //Schrijf de data van het huidige patroon naar PORTD
+ PORTD = pattern[count].data;
+ //Wacht het aantal milliseconde dat in het huidige patroon staat
+ wait(pattern[count].delay * speed);
+
+ count++; //patroon verder
+
+ //als alle patronen geweest zijn, opnieuw beginnen
+ if(count >= NELEMS(pattern))
+ {
+ count = 0;
+ }
+ }
}
\ No newline at end of file