P4 Changed Interrupt PortB -> PortC; Unfinished implementation of PortB for teens

This commit is contained in:
S170H
2023-12-06 14:14:59 +01:00
parent c6080d47db
commit ee22ff0819
32 changed files with 1904 additions and 152 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -6,22 +6,22 @@
:100050000C9446000C9446000C9446000C94460008
:100060000C9446000C94460011241FBECFEFD8E03C
:10007000DEBFCDBF21E0A0E0B1E001C01D92A43001
:10008000B207E1F70E94B2000C94C8000C94000083
:10008000B207E1F70E94B7000C94CC000C9400007A
:1000900084B5826084BD85B5836085BD89EF87BDE9
:1000A000EEE6F0E080818260808308951F920F92D7
:1000B0000FB60F9211248F939F93AF93BF938091AC
:1000C000000190910101A0910201B09103010196FC
:1000D000A11DB11D8093000190930101A093020125
:1000E000B0930301BF91AF919F918F910F900FBE7D
:1000F0000F901F9018950F931F930091000110917E
:1001000001012091020130910301AB01BC01400FBC
:10011000511F621F731F8091000190910101A091F6
:100120000201B091030184179507A607B70798F35A
:100130001F910F910895AB01BC0180910001909136
:100140000101A0910201B091030184179507A60750
:10015000B70798F30895509A08959BB181E08927D5
:100160008BB908950E94AB000E944800789464EF18
:1001700071E080E090E00E949B000E94AD0064EF7F
:1001800071E080E090E00E947B000E94AD00F7CF1C
:04019000F894FFCF11
:1000F0000F901F901895F894609100017091010184
:10010000809102019091030178940895CF92DF923B
:10011000EF92FF926B017C010E947B00C60ED71EFE
:10012000E81EF91E0E947B00C616D706E806F906EF
:10013000C9F7FF90EF90DF90CF900895CF92DF92B4
:10014000EF92FF926B017C010E947B006C157D0594
:100150008E059F05C9F7FF90EF90DF90CF9008952F
:10016000509A08959BB181E089278BB908950E9428
:10017000B0000E94480064EF71E080E090E00E94CF
:100180009E000E94B20064EF71E080E090E00E9467
:0C01900086000E94B200F7CFF894FFCF69
:00000001FF

View File

@@ -3,31 +3,31 @@ P3.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 00000000 00800100 00800100 00000208 2**0
0 .data 00000000 00800100 00800100 00000210 2**0
CONTENTS, ALLOC, LOAD, DATA
1 .text 00000194 00000000 00000000 00000074 2**1
1 .text 0000019c 00000000 00000000 00000074 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .bss 00000004 00800100 00800100 00000208 2**0
2 .bss 00000004 00800100 00800100 00000210 2**0
ALLOC
3 .comment 00000030 00000000 00000000 00000208 2**0
3 .comment 00000030 00000000 00000000 00000210 2**0
CONTENTS, READONLY
4 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 00000238 2**2
4 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 00000240 2**2
CONTENTS, READONLY
5 .debug_aranges 00000050 00000000 00000000 00000278 2**0
5 .debug_aranges 00000058 00000000 00000000 00000280 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_info 000007d8 00000000 00000000 000002c8 2**0
6 .debug_info 0000080e 00000000 00000000 000002d8 2**0
CONTENTS, READONLY, DEBUGGING
7 .debug_abbrev 000006b6 00000000 00000000 00000aa0 2**0
7 .debug_abbrev 000006c5 00000000 00000000 00000ae6 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_line 000002b4 00000000 00000000 00001156 2**0
8 .debug_line 000002d6 00000000 00000000 000011ab 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_frame 000000b0 00000000 00000000 0000140c 2**2
9 .debug_frame 000000dc 00000000 00000000 00001484 2**2
CONTENTS, READONLY, DEBUGGING
10 .debug_str 000003c7 00000000 00000000 000014bc 2**0
10 .debug_str 000003e6 00000000 00000000 00001560 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_loc 00000092 00000000 00000000 00001883 2**0
11 .debug_loc 00000197 00000000 00000000 00001946 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_ranges 00000040 00000000 00000000 00001915 2**0
12 .debug_ranges 00000048 00000000 00000000 00001add 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
@@ -81,8 +81,8 @@ Disassembly of section .text:
7e: a4 30 cpi r26, 0x04 ; 4
80: b2 07 cpc r27, r18
82: e1 f7 brne .-8 ; 0x7c <.do_clear_bss_loop>
84: 0e 94 b2 00 call 0x164 ; 0x164 <main>
88: 0c 94 c8 00 jmp 0x190 ; 0x190 <_exit>
84: 0e 94 b7 00 call 0x16e ; 0x16e <main>
88: 0c 94 cc 00 jmp 0x198 ; 0x198 <_exit>
0000008c <__bad_interrupt>:
8c: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
@@ -149,106 +149,124 @@ ISR(TIMER0_COMPA_vect) {
f2: 1f 90 pop r1
f4: 18 95 reti
000000f6 <waitFor>:
000000f6 <getSystemClock>:
uint32_t getSystemClock(){
cli();
f6: f8 94 cli
uint32_t tempSystemClock = systemClock;
f8: 60 91 00 01 lds r22, 0x0100 ; 0x800100 <_edata>
fc: 70 91 01 01 lds r23, 0x0101 ; 0x800101 <_edata+0x1>
100: 80 91 02 01 lds r24, 0x0102 ; 0x800102 <_edata+0x2>
104: 90 91 03 01 lds r25, 0x0103 ; 0x800103 <_edata+0x3>
sei();
108: 78 94 sei
return tempSystemClock;
}
10a: 08 95 ret
0000010c <waitFor>:
void waitFor(uint32_t ms) {
f6: 0f 93 push r16
f8: 1f 93 push r17
uint32_t endTime = systemClock + ms;
fa: 00 91 00 01 lds r16, 0x0100 ; 0x800100 <_edata>
fe: 10 91 01 01 lds r17, 0x0101 ; 0x800101 <_edata+0x1>
102: 20 91 02 01 lds r18, 0x0102 ; 0x800102 <_edata+0x2>
106: 30 91 03 01 lds r19, 0x0103 ; 0x800103 <_edata+0x3>
10a: ab 01 movw r20, r22
10c: bc 01 movw r22, r24
10e: 40 0f add r20, r16
110: 51 1f adc r21, r17
112: 62 1f adc r22, r18
114: 73 1f adc r23, r19
while (systemClock < endTime);
116: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <_edata>
11a: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <_edata+0x1>
11e: a0 91 02 01 lds r26, 0x0102 ; 0x800102 <_edata+0x2>
122: b0 91 03 01 lds r27, 0x0103 ; 0x800103 <_edata+0x3>
126: 84 17 cp r24, r20
128: 95 07 cpc r25, r21
12a: a6 07 cpc r26, r22
12c: b7 07 cpc r27, r23
12e: 98 f3 brcs .-26 ; 0x116 <waitFor+0x20>
10c: cf 92 push r12
10e: df 92 push r13
110: ef 92 push r14
112: ff 92 push r15
114: 6b 01 movw r12, r22
116: 7c 01 movw r14, r24
uint32_t endTime = getSystemClock() + ms;
118: 0e 94 7b 00 call 0xf6 ; 0xf6 <getSystemClock>
11c: c6 0e add r12, r22
11e: d7 1e adc r13, r23
120: e8 1e adc r14, r24
122: f9 1e adc r15, r25
while (getSystemClock() != endTime);
124: 0e 94 7b 00 call 0xf6 ; 0xf6 <getSystemClock>
128: c6 16 cp r12, r22
12a: d7 06 cpc r13, r23
12c: e8 06 cpc r14, r24
12e: f9 06 cpc r15, r25
130: c9 f7 brne .-14 ; 0x124 <waitFor+0x18>
}
130: 1f 91 pop r17
132: 0f 91 pop r16
134: 08 95 ret
132: ff 90 pop r15
134: ef 90 pop r14
136: df 90 pop r13
138: cf 90 pop r12
13a: 08 95 ret
00000136 <waitUntil>:
0000013c <waitUntil>:
void waitUntil(uint32_t ms) {
136: ab 01 movw r20, r22
138: bc 01 movw r22, r24
while (systemClock < ms);
13a: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <_edata>
13e: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <_edata+0x1>
142: a0 91 02 01 lds r26, 0x0102 ; 0x800102 <_edata+0x2>
146: b0 91 03 01 lds r27, 0x0103 ; 0x800103 <_edata+0x3>
14a: 84 17 cp r24, r20
14c: 95 07 cpc r25, r21
14e: a6 07 cpc r26, r22
150: b7 07 cpc r27, r23
152: 98 f3 brcs .-26 ; 0x13a <waitUntil+0x4>
13c: cf 92 push r12
13e: df 92 push r13
140: ef 92 push r14
142: ff 92 push r15
144: 6b 01 movw r12, r22
146: 7c 01 movw r14, r24
while (getSystemClock() != ms);
148: 0e 94 7b 00 call 0xf6 ; 0xf6 <getSystemClock>
14c: 6c 15 cp r22, r12
14e: 7d 05 cpc r23, r13
150: 8e 05 cpc r24, r14
152: 9f 05 cpc r25, r15
154: c9 f7 brne .-14 ; 0x148 <waitUntil+0xc>
}
154: 08 95 ret
156: ff 90 pop r15
158: ef 90 pop r14
15a: df 90 pop r13
15c: cf 90 pop r12
15e: 08 95 ret
00000156 <initializeLED>:
00000160 <initializeLED>:
void initializeLED() {
DDRD |= (1 << LED_PIN); // Set LED_PIN as an output
156: 50 9a sbi 0x0a, 0 ; 10
158: 08 95 ret
160: 50 9a sbi 0x0a, 0 ; 10
162: 08 95 ret
0000015a <toggleLED>:
00000164 <toggleLED>:
}
void toggleLED() {
PORTD ^= (1 << LED_PIN); // Toggle the LED
15a: 9b b1 in r25, 0x0b ; 11
15c: 81 e0 ldi r24, 0x01 ; 1
15e: 89 27 eor r24, r25
160: 8b b9 out 0x0b, r24 ; 11
162: 08 95 ret
164: 9b b1 in r25, 0x0b ; 11
166: 81 e0 ldi r24, 0x01 ; 1
168: 89 27 eor r24, r25
16a: 8b b9 out 0x0b, r24 ; 11
16c: 08 95 ret
00000164 <main>:
0000016e <main>:
}
int main(void) {
initializeLED(); // Initialize the LED pin
164: 0e 94 ab 00 call 0x156 ; 0x156 <initializeLED>
16e: 0e 94 b0 00 call 0x160 ; 0x160 <initializeLED>
setupTimer0(); // Setup Timer0
168: 0e 94 48 00 call 0x90 ; 0x90 <setupTimer0>
sei(); // Enable global interrupts
16c: 78 94 sei
172: 0e 94 48 00 call 0x90 ; 0x90 <setupTimer0>
//sei(); // Enable global interrupts
waitUntil(500); // Wait until 500 ms have passed
16e: 64 ef ldi r22, 0xF4 ; 244
170: 71 e0 ldi r23, 0x01 ; 1
172: 80 e0 ldi r24, 0x00 ; 0
174: 90 e0 ldi r25, 0x00 ; 0
176: 0e 94 9b 00 call 0x136 ; 0x136 <waitUntil>
176: 64 ef ldi r22, 0xF4 ; 244
178: 71 e0 ldi r23, 0x01 ; 1
17a: 80 e0 ldi r24, 0x00 ; 0
17c: 90 e0 ldi r25, 0x00 ; 0
17e: 0e 94 9e 00 call 0x13c ; 0x13c <waitUntil>
toggleLED(); // Toggle the LED to turn it on
17a: 0e 94 ad 00 call 0x15a ; 0x15a <toggleLED>
182: 0e 94 b2 00 call 0x164 ; 0x164 <toggleLED>
while (1) {
waitFor(500); // Wait for 500 ms
17e: 64 ef ldi r22, 0xF4 ; 244
180: 71 e0 ldi r23, 0x01 ; 1
182: 80 e0 ldi r24, 0x00 ; 0
184: 90 e0 ldi r25, 0x00 ; 0
186: 0e 94 7b 00 call 0xf6 ; 0xf6 <waitFor>
186: 64 ef ldi r22, 0xF4 ; 244
188: 71 e0 ldi r23, 0x01 ; 1
18a: 80 e0 ldi r24, 0x00 ; 0
18c: 90 e0 ldi r25, 0x00 ; 0
18e: 0e 94 86 00 call 0x10c ; 0x10c <waitFor>
toggleLED(); // Toggle the LED
18a: 0e 94 ad 00 call 0x15a ; 0x15a <toggleLED>
18e: f7 cf rjmp .-18 ; 0x17e <main+0x1a>
192: 0e 94 b2 00 call 0x164 ; 0x164 <toggleLED>
196: f7 cf rjmp .-18 ; 0x186 <main+0x18>
00000190 <_exit>:
190: f8 94 cli
00000198 <_exit>:
198: f8 94 cli
00000192 <__stop_program>:
192: ff cf rjmp .-2 ; 0x192 <__stop_program>
0000019a <__stop_program>:
19a: ff cf rjmp .-2 ; 0x19a <__stop_program>

View File

@@ -169,7 +169,7 @@ END GROUP
.rela.plt
*(.rela.plt)
.text 0x00000000 0x194
.text 0x00000000 0x19c
*(.vectors)
.vectors 0x00000000 0x68 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
0x00000000 __vector_default
@@ -259,24 +259,27 @@ END GROUP
.text.__vector_14
0x000000ac 0x4a main.o
0x000000ac __vector_14
.text.waitFor 0x000000f6 0x40 main.o
0x000000f6 waitFor
.text.getSystemClock
0x000000f6 0x16 main.o
0x000000f6 getSystemClock
.text.waitFor 0x0000010c 0x30 main.o
0x0000010c waitFor
.text.waitUntil
0x00000136 0x20 main.o
0x00000136 waitUntil
0x0000013c 0x24 main.o
0x0000013c waitUntil
.text.initializeLED
0x00000156 0x4 main.o
0x00000156 initializeLED
0x00000160 0x4 main.o
0x00000160 initializeLED
.text.toggleLED
0x0000015a 0xa main.o
0x0000015a toggleLED
.text.main 0x00000164 0x2c main.o
0x00000164 main
0x00000190 . = ALIGN (0x2)
0x00000164 0xa main.o
0x00000164 toggleLED
.text.main 0x0000016e 0x2a main.o
0x0000016e main
0x00000198 . = ALIGN (0x2)
*(.fini9)
.fini9 0x00000190 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_exit.o)
0x00000190 _exit
0x00000190 exit
.fini9 0x00000198 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_exit.o)
0x00000198 _exit
0x00000198 exit
*(.fini9)
*(.fini8)
*(.fini8)
@@ -295,11 +298,11 @@ END GROUP
*(.fini1)
*(.fini1)
*(.fini0)
.fini0 0x00000190 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_exit.o)
.fini0 0x00000198 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_exit.o)
*(.fini0)
0x00000194 _etext = .
0x0000019c _etext = .
.data 0x00800100 0x0 load address 0x00000194
.data 0x00800100 0x0 load address 0x0000019c
[!provide] PROVIDE (__data_start, .)
*(.data)
*(.data*)
@@ -320,8 +323,8 @@ END GROUP
0x00800100 systemClock
*(COMMON)
0x00800104 PROVIDE (__bss_end, .)
0x00000194 __data_load_start = LOADADDR (.data)
0x00000194 __data_load_end = (__data_load_start + SIZEOF (.data))
0x0000019c __data_load_start = LOADADDR (.data)
0x0000019c __data_load_end = (__data_load_start + SIZEOF (.data))
.noinit 0x00800104 0x0
[!provide] PROVIDE (__noinit_start, .)
@@ -392,42 +395,42 @@ END GROUP
.debug_sfnames
*(.debug_sfnames)
.debug_aranges 0x00000000 0x50
.debug_aranges 0x00000000 0x58
*(.debug_aranges)
.debug_aranges
0x00000000 0x50 main.o
0x00000000 0x58 main.o
.debug_pubnames
*(.debug_pubnames)
.debug_info 0x00000000 0x7d8
.debug_info 0x00000000 0x80e
*(.debug_info .gnu.linkonce.wi.*)
.debug_info 0x00000000 0x5f4 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
.debug_info 0x000005f4 0x1e4 main.o
.debug_info 0x000005f4 0x21a main.o
.debug_abbrev 0x00000000 0x6b6
.debug_abbrev 0x00000000 0x6c5
*(.debug_abbrev)
.debug_abbrev 0x00000000 0x5a2 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
.debug_abbrev 0x000005a2 0x114 main.o
.debug_abbrev 0x000005a2 0x123 main.o
.debug_line 0x00000000 0x2b4
.debug_line 0x00000000 0x2d6
*(.debug_line .debug_line.* .debug_line_end)
.debug_line 0x00000000 0x133 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
.debug_line 0x00000133 0x181 main.o
.debug_line 0x00000133 0x1a3 main.o
.debug_frame 0x00000000 0xb0
.debug_frame 0x00000000 0xdc
*(.debug_frame)
.debug_frame 0x00000000 0xb0 main.o
.debug_frame 0x00000000 0xdc main.o
.debug_str 0x00000000 0x3c7
.debug_str 0x00000000 0x3e6
*(.debug_str)
.debug_str 0x00000000 0x208 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
.debug_str 0x00000208 0x1bf main.o
0x1f3 (size before relaxing)
.debug_str 0x00000208 0x1de main.o
0x212 (size before relaxing)
.debug_loc 0x00000000 0x92
.debug_loc 0x00000000 0x197
*(.debug_loc)
.debug_loc 0x00000000 0x92 main.o
.debug_loc 0x00000000 0x197 main.o
.debug_macinfo
*(.debug_macinfo)
@@ -447,9 +450,9 @@ END GROUP
.debug_pubtypes
*(.debug_pubtypes)
.debug_ranges 0x00000000 0x40
.debug_ranges 0x00000000 0x48
*(.debug_ranges)
.debug_ranges 0x00000000 0x40 main.o
.debug_ranges 0x00000000 0x48 main.o
.debug_macro
*(.debug_macro)

View File

@@ -7,22 +7,22 @@ S11300400C9446000C9446000C9446000C94460014
S11300500C9446000C9446000C9446000C94460004
S11300600C9446000C94460011241FBECFEFD8E038
S1130070DEBFCDBF21E0A0E0B1E001C01D92A430FD
S1130080B207E1F70E94B2000C94C8000C9400007F
S1130080B207E1F70E94B7000C94CC000C94000076
S113009084B5826084BD85B5836085BD89EF87BDE5
S11300A0EEE6F0E080818260808308951F920F92D3
S11300B00FB60F9211248F939F93AF93BF938091A8
S11300C0000190910101A0910201B09103010196F8
S11300D0A11DB11D8093000190930101A093020121
S11300E0B0930301BF91AF919F918F910F900FBE79
S11300F00F901F9018950F931F930091000110917A
S113010001012091020130910301AB01BC01400FB8
S1130110511F621F731F8091000190910101A091F2
S11301200201B091030184179507A607B70798F356
S11301301F910F910895AB01BC0180910001909132
S11301400101A0910201B091030184179507A6074C
S1130150B70798F30895509A08959BB181E08927D1
S11301608BB908950E94AB000E944800789464EF14
S113017071E080E090E00E949B000E94AD0064EF7B
S113018071E080E090E00E947B000E94AD00F7CF18
S1070190F894FFCF0D
S11300F00F901F901895F894609100017091010180
S1130100809102019091030178940895CF92DF9237
S1130110EF92FF926B017C010E947B00C60ED71EFA
S1130120E81EF91E0E947B00C616D706E806F906EB
S1130130C9F7FF90EF90DF90CF900895CF92DF92B0
S1130140EF92FF926B017C010E947B006C157D0590
S11301508E059F05C9F7FF90EF90DF90CF9008952B
S1130160509A08959BB181E089278BB908950E9424
S1130170B0000E94480064EF71E080E090E00E94CB
S11301809E000E94B20064EF71E080E090E00E9463
S10F019086000E94B200F7CFF894FFCF65
S9030000FC

Binary file not shown.

View File

@@ -19,13 +19,20 @@ ISR(TIMER0_COMPA_vect) {
systemClock++; // Increment the milliseconds counter
}
uint32_t getSystemClock(){
cli();
uint32_t tempSystemClock = systemClock;
sei();
return tempSystemClock;
}
void waitFor(uint32_t ms) {
uint32_t endTime = systemClock + ms;
while (systemClock < endTime);
uint32_t endTime = getSystemClock() + ms;
while (getSystemClock() != endTime);
}
void waitUntil(uint32_t ms) {
while (systemClock < ms);
while (getSystemClock() != ms);
}
void initializeLED() {
@@ -39,7 +46,7 @@ void toggleLED() {
int main(void) {
initializeLED(); // Initialize the LED pin
setupTimer0(); // Setup Timer0
sei(); // Enable global interrupts
//sei(); // Enable global interrupts
waitUntil(500); // Wait until 500 ms have passed
toggleLED(); // Toggle the LED to turn it on