diff --git a/P1/.vs/P1/v14/.atsuo b/P1/.vs/P1/v14/.atsuo index c8d4434..613d3cb 100644 Binary files a/P1/.vs/P1/v14/.atsuo and b/P1/.vs/P1/v14/.atsuo differ diff --git a/P1/P1/Debug/P1.lss b/P1/P1/Debug/P1.lss index 6740920..1a9221e 100644 --- a/P1/P1/Debug/P1.lss +++ b/P1/P1/Debug/P1.lss @@ -1,5 +1,5 @@ -AVRASM ver. 2.2.7 C:\Users\Safak\SynologyDrive\UNI\3. Semester\53107 ARBK\Praktikumsunterlagen\ARBKVS-Praktika\P1\P1\main.asm Tue Nov 14 00:02:30 2023 +AVRASM ver. 2.2.7 C:\Users\Safak\SynologyDrive\UNI\3. Semester\53107 ARBK\Praktikumsunterlagen\ARBKVS-Praktika\P1\P1\main.asm Thu Nov 23 17:48:47 2023 [builtin](2): Including file 'C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\avrasm\inc\m328pdef.inc' C:\Users\Safak\SynologyDrive\UNI\3. Semester\53107 ARBK\Praktikumsunterlagen\ARBKVS-Praktika\P1\P1\main.asm(8): Including file 'C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\avrasm\inc\m328pdef.inc' diff --git a/P1/P1/Debug/P1.map b/P1/P1/Debug/P1.map index 254e5c7..63b1268 100644 --- a/P1/P1/Debug/P1.map +++ b/P1/P1/Debug/P1.map @@ -1,5 +1,5 @@ -AVRASM ver. 2.2.7 C:\Users\Safak\SynologyDrive\UNI\3. Semester\53107 ARBK\Praktikumsunterlagen\ARBKVS-Praktika\P1\P1\main.asm Tue Nov 14 00:02:30 2023 +AVRASM ver. 2.2.7 C:\Users\Safak\SynologyDrive\UNI\3. Semester\53107 ARBK\Praktikumsunterlagen\ARBKVS-Praktika\P1\P1\main.asm Thu Nov 23 17:48:47 2023 EQU SIGNATURE_000 0000001e diff --git a/P3/.vs/P3/v14/.atsuo b/P3/.vs/P3/v14/.atsuo new file mode 100644 index 0000000..544d4c6 Binary files /dev/null and b/P3/.vs/P3/v14/.atsuo differ diff --git a/P3/P3/P3.atsln b/P3/P3.atsln similarity index 100% rename from P3/P3/P3.atsln rename to P3/P3.atsln diff --git a/P3/P3/.idea/.gitignore b/P3/P3/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/P3/P3/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/P3/P3/.idea/P3.iml b/P3/P3/.idea/P3.iml new file mode 100644 index 0000000..bc2cd87 --- /dev/null +++ b/P3/P3/.idea/P3.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/P3/P3/.idea/modules.xml b/P3/P3/.idea/modules.xml new file mode 100644 index 0000000..3413a3f --- /dev/null +++ b/P3/P3/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/P3/P3/.idea/vcs.xml b/P3/P3/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/P3/P3/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/P3/P3/.vs/P3/v14/.atsuo b/P3/P3/.vs/P3/v14/.atsuo deleted file mode 100644 index 90445e0..0000000 Binary files a/P3/P3/.vs/P3/v14/.atsuo and /dev/null differ diff --git a/P3/P3/Debug/Makefile b/P3/P3/Debug/Makefile new file mode 100644 index 0000000..95b65d7 --- /dev/null +++ b/P3/P3/Debug/Makefile @@ -0,0 +1,127 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +SHELL := cmd.exe +RM := rm -rf + +USER_OBJS := + +LIBS := +PROJ := + +O_SRCS := +C_SRCS := +S_SRCS := +S_UPPER_SRCS := +OBJ_SRCS := +ASM_SRCS := +PREPROCESSING_SRCS := +OBJS := +OBJS_AS_ARGS := +C_DEPS := +C_DEPS_AS_ARGS := +EXECUTABLES := +OUTPUT_FILE_PATH := +OUTPUT_FILE_PATH_AS_ARGS := +AVR_APP_PATH :=$$$AVR_APP_PATH$$$ +QUOTE := " +ADDITIONAL_DEPENDENCIES:= +OUTPUT_FILE_DEP:= +LIB_DEP:= +LINKER_SCRIPT_DEP:= + +# Every subdirectory with source files must be described here +SUBDIRS := + + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../main.c + + +PREPROCESSING_SRCS += + + +ASM_SRCS += + + +OBJS += \ +main.o + +OBJS_AS_ARGS += \ +main.o + +C_DEPS += \ +main.d + +C_DEPS_AS_ARGS += \ +main.d + +OUTPUT_FILE_PATH +=P3.elf + +OUTPUT_FILE_PATH_AS_ARGS +=P3.elf + +ADDITIONAL_DEPENDENCIES:= + +OUTPUT_FILE_DEP:= ./makedep.mk + +LIB_DEP+= + +LINKER_SCRIPT_DEP+= + + +# AVR32/GNU C Compiler +./main.o: .././main.c + @echo Building file: $< + @echo Invoking: AVR/GNU C Compiler : 5.4.0 + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega328p" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<" + @echo Finished building: $< + + + + + +# AVR32/GNU Preprocessing Assembler + + + +# AVR32/GNU Assembler + + + + +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(strip $(C_DEPS)),) +-include $(C_DEPS) +endif +endif + +# Add inputs and outputs from these tool invocations to the build variables + +# All Target +all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES) + +$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP) + @echo Building target: $@ + @echo Invoking: AVR/GNU Linker : 5.4.0 + $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="P3.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega328p" + @echo Finished building target: $@ + "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "P3.elf" "P3.hex" + "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "P3.elf" "P3.eep" || exit 0 + "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "P3.elf" > "P3.lss" + "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "P3.elf" "P3.srec" + "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "P3.elf" + + + + + + + +# Other Targets +clean: + -$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES) + -$(RM) $(C_DEPS_AS_ARGS) + rm -rf "P3.elf" "P3.a" "P3.hex" "P3.lss" "P3.eep" "P3.map" "P3.srec" "P3.usersignatures" + \ No newline at end of file diff --git a/P3/P3/Debug/P3.eep b/P3/P3/Debug/P3.eep new file mode 100644 index 0000000..7c166a1 --- /dev/null +++ b/P3/P3/Debug/P3.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/P3/P3/Debug/P3.elf b/P3/P3/Debug/P3.elf new file mode 100644 index 0000000..fc43ada Binary files /dev/null and b/P3/P3/Debug/P3.elf differ diff --git a/P3/P3/Debug/P3.hex b/P3/P3/Debug/P3.hex new file mode 100644 index 0000000..2bea52f --- /dev/null +++ b/P3/P3/Debug/P3.hex @@ -0,0 +1,27 @@ +:100000000C9434000C9446000C9446000C9446006A +:100010000C9446000C9446000C9446000C94460048 +:100020000C9446000C9446000C9446000C94460038 +:100030000C9446000C9446000C9456000C94460018 +:100040000C9446000C9446000C9446000C94460018 +:100050000C9446000C9446000C9446000C94460008 +:100060000C9446000C94460011241FBECFEFD8E03C +:10007000DEBFCDBF21E0A0E0B1E001C01D92A43001 +:10008000B207E1F70E94B2000C94C8000C94000083 +:1000900084B5826084BD85B5836085BD89EF87BDE9 +:1000A000EEE6F0E080818260808308951F920F92D7 +:1000B0000FB60F9211248F939F93AF93BF938091AC +:1000C000000190910101A0910201B09103010196FC +:1000D000A11DB11D8093000190930101A093020125 +:1000E000B0930301BF91AF919F918F910F900FBE7D +:1000F0000F901F9018950F931F930091000110917E +:1001000001012091020130910301AB01BC01400FBC +:10011000511F621F731F8091000190910101A091F6 +:100120000201B091030184179507A607B70798F35A +:100130001F910F910895AB01BC0180910001909136 +:100140000101A0910201B091030184179507A60750 +:10015000B70798F30895509A08959BB181E08927D5 +:100160008BB908950E94AB000E944800789464EF18 +:1001700071E080E090E00E949B000E94AD0064EF7F +:1001800071E080E090E00E947B000E94AD00F7CF1C +:04019000F894FFCF11 +:00000001FF diff --git a/P3/P3/Debug/P3.lss b/P3/P3/Debug/P3.lss new file mode 100644 index 0000000..c18c044 --- /dev/null +++ b/P3/P3/Debug/P3.lss @@ -0,0 +1,254 @@ + +P3.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .data 00000000 00800100 00800100 00000208 2**0 + CONTENTS, ALLOC, LOAD, DATA + 1 .text 00000194 00000000 00000000 00000074 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 2 .bss 00000004 00800100 00800100 00000208 2**0 + ALLOC + 3 .comment 00000030 00000000 00000000 00000208 2**0 + CONTENTS, READONLY + 4 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 00000238 2**2 + CONTENTS, READONLY + 5 .debug_aranges 00000050 00000000 00000000 00000278 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_info 000007d8 00000000 00000000 000002c8 2**0 + CONTENTS, READONLY, DEBUGGING + 7 .debug_abbrev 000006b6 00000000 00000000 00000aa0 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_line 000002b4 00000000 00000000 00001156 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_frame 000000b0 00000000 00000000 0000140c 2**2 + CONTENTS, READONLY, DEBUGGING + 10 .debug_str 000003c7 00000000 00000000 000014bc 2**0 + CONTENTS, READONLY, DEBUGGING + 11 .debug_loc 00000092 00000000 00000000 00001883 2**0 + CONTENTS, READONLY, DEBUGGING + 12 .debug_ranges 00000040 00000000 00000000 00001915 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00000000 <__vectors>: + 0: 0c 94 34 00 jmp 0x68 ; 0x68 <__ctors_end> + 4: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 8: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + c: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 10: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 14: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 18: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 1c: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 20: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 24: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 28: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 2c: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 30: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 34: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 38: 0c 94 56 00 jmp 0xac ; 0xac <__vector_14> + 3c: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 40: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 44: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 48: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 4c: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 50: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 54: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 58: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 5c: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 60: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + 64: 0c 94 46 00 jmp 0x8c ; 0x8c <__bad_interrupt> + +00000068 <__ctors_end>: + 68: 11 24 eor r1, r1 + 6a: 1f be out 0x3f, r1 ; 63 + 6c: cf ef ldi r28, 0xFF ; 255 + 6e: d8 e0 ldi r29, 0x08 ; 8 + 70: de bf out 0x3e, r29 ; 62 + 72: cd bf out 0x3d, r28 ; 61 + +00000074 <__do_clear_bss>: + 74: 21 e0 ldi r18, 0x01 ; 1 + 76: a0 e0 ldi r26, 0x00 ; 0 + 78: b1 e0 ldi r27, 0x01 ; 1 + 7a: 01 c0 rjmp .+2 ; 0x7e <.do_clear_bss_start> + +0000007c <.do_clear_bss_loop>: + 7c: 1d 92 st X+, r1 + +0000007e <.do_clear_bss_start>: + 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
+ 88: 0c 94 c8 00 jmp 0x190 ; 0x190 <_exit> + +0000008c <__bad_interrupt>: + 8c: 0c 94 00 00 jmp 0 ; 0x0 <__vectors> + +00000090 : + +volatile uint32_t systemClock = 0; + +void setupTimer0() { + // Configure Timer0 for CTC mode + TCCR0A |= (1 << WGM01); // Set Waveform Generation Mode bits for CTC + 90: 84 b5 in r24, 0x24 ; 36 + 92: 82 60 ori r24, 0x02 ; 2 + 94: 84 bd out 0x24, r24 ; 36 + TCCR0B |= (1 << CS01) | (1 << CS00); // Set prescaler to 64 + 96: 85 b5 in r24, 0x25 ; 37 + 98: 83 60 ori r24, 0x03 ; 3 + 9a: 85 bd out 0x25, r24 ; 37 + OCR0A = 249; // Set Output Compare Register to 249 for ~1ms interrupt + 9c: 89 ef ldi r24, 0xF9 ; 249 + 9e: 87 bd out 0x27, r24 ; 39 + TIMSK0 |= (1 << OCIE0A); // Enable Timer0 Output Compare A Match interrupt + a0: ee e6 ldi r30, 0x6E ; 110 + a2: f0 e0 ldi r31, 0x00 ; 0 + a4: 80 81 ld r24, Z + a6: 82 60 ori r24, 0x02 ; 2 + a8: 80 83 st Z, r24 + aa: 08 95 ret + +000000ac <__vector_14>: +} + +// Timer0 Output Compare A Match Interrupt Service Routine +ISR(TIMER0_COMPA_vect) { + ac: 1f 92 push r1 + ae: 0f 92 push r0 + b0: 0f b6 in r0, 0x3f ; 63 + b2: 0f 92 push r0 + b4: 11 24 eor r1, r1 + b6: 8f 93 push r24 + b8: 9f 93 push r25 + ba: af 93 push r26 + bc: bf 93 push r27 + systemClock++; // Increment the milliseconds counter + be: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <_edata> + c2: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <_edata+0x1> + c6: a0 91 02 01 lds r26, 0x0102 ; 0x800102 <_edata+0x2> + ca: b0 91 03 01 lds r27, 0x0103 ; 0x800103 <_edata+0x3> + ce: 01 96 adiw r24, 0x01 ; 1 + d0: a1 1d adc r26, r1 + d2: b1 1d adc r27, r1 + d4: 80 93 00 01 sts 0x0100, r24 ; 0x800100 <_edata> + d8: 90 93 01 01 sts 0x0101, r25 ; 0x800101 <_edata+0x1> + dc: a0 93 02 01 sts 0x0102, r26 ; 0x800102 <_edata+0x2> + e0: b0 93 03 01 sts 0x0103, r27 ; 0x800103 <_edata+0x3> +} + e4: bf 91 pop r27 + e6: af 91 pop r26 + e8: 9f 91 pop r25 + ea: 8f 91 pop r24 + ec: 0f 90 pop r0 + ee: 0f be out 0x3f, r0 ; 63 + f0: 0f 90 pop r0 + f2: 1f 90 pop r1 + f4: 18 95 reti + +000000f6 : + +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 +} + 130: 1f 91 pop r17 + 132: 0f 91 pop r16 + 134: 08 95 ret + +00000136 : + +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 +} + 154: 08 95 ret + +00000156 : + +void initializeLED() { + DDRD |= (1 << LED_PIN); // Set LED_PIN as an output + 156: 50 9a sbi 0x0a, 0 ; 10 + 158: 08 95 ret + +0000015a : +} + +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 + +00000164
: +} + +int main(void) { + initializeLED(); // Initialize the LED pin + 164: 0e 94 ab 00 call 0x156 ; 0x156 + setupTimer0(); // Setup Timer0 + 168: 0e 94 48 00 call 0x90 ; 0x90 + sei(); // Enable global interrupts + 16c: 78 94 sei + + 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 + toggleLED(); // Toggle the LED to turn it on + 17a: 0e 94 ad 00 call 0x15a ; 0x15a + + 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 + toggleLED(); // Toggle the LED + 18a: 0e 94 ad 00 call 0x15a ; 0x15a + 18e: f7 cf rjmp .-18 ; 0x17e + +00000190 <_exit>: + 190: f8 94 cli + +00000192 <__stop_program>: + 192: ff cf rjmp .-2 ; 0x192 <__stop_program> diff --git a/P3/P3/Debug/P3.map b/P3/P3/Debug/P3.map new file mode 100644 index 0000000..ec43bd2 --- /dev/null +++ b/P3/P3/Debug/P3.map @@ -0,0 +1,457 @@ +Archive member included to satisfy reference by file (symbol) + +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) + C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o (exit) +c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + main.o (__do_clear_bss) + +Discarded input sections + + .data 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o + .bss 0x00000000 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o + .text 0x00000000 0x0 main.o + .data 0x00000000 0x0 main.o + .bss 0x00000000 0x0 main.o + .text 0x00000000 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) + .data 0x00000000 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) + .bss 0x00000000 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) + .text.libgcc.mul + 0x00000000 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) + .text.libgcc.div + 0x00000000 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) + .text.libgcc 0x00000000 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) + .text.libgcc.prologue + 0x00000000 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) + .text.libgcc.builtins + 0x00000000 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) + .text.libgcc.fmul + 0x00000000 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) + .text.libgcc.fixed + 0x00000000 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) + .text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + .data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + .bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + .text.libgcc.mul + 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + .text.libgcc.div + 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + .text.libgcc 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + .text.libgcc.prologue + 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + .text.libgcc.builtins + 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + .text.libgcc.fmul + 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + .text.libgcc.fixed + 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + +Memory Configuration + +Name Origin Length Attributes +text 0x00000000 0x00020000 xr +data 0x00800060 0x0000ffa0 rw !x +eeprom 0x00810000 0x00010000 rw !x +fuse 0x00820000 0x00000003 rw !x +lock 0x00830000 0x00000400 rw !x +signature 0x00840000 0x00000400 rw !x +user_signatures 0x00850000 0x00000400 rw !x +*default* 0x00000000 0xffffffff + +Linker script and memory map + +Address of section .data set to 0x800100 +LOAD C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o +LOAD main.o +START GROUP +LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avr5\libm.a +END GROUP +START GROUP +LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a +LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avr5\libm.a +LOAD c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avr5\libc.a +LOAD C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5\libatmega328p.a +END GROUP + 0x00020000 __TEXT_REGION_LENGTH__ = DEFINED (__TEXT_REGION_LENGTH__)?__TEXT_REGION_LENGTH__:0x20000 + 0x0000ffa0 __DATA_REGION_LENGTH__ = DEFINED (__DATA_REGION_LENGTH__)?__DATA_REGION_LENGTH__:0xffa0 + 0x00010000 __EEPROM_REGION_LENGTH__ = DEFINED (__EEPROM_REGION_LENGTH__)?__EEPROM_REGION_LENGTH__:0x10000 + [0x00000003] __FUSE_REGION_LENGTH__ = DEFINED (__FUSE_REGION_LENGTH__)?__FUSE_REGION_LENGTH__:0x400 + 0x00000400 __LOCK_REGION_LENGTH__ = DEFINED (__LOCK_REGION_LENGTH__)?__LOCK_REGION_LENGTH__:0x400 + 0x00000400 __SIGNATURE_REGION_LENGTH__ = DEFINED (__SIGNATURE_REGION_LENGTH__)?__SIGNATURE_REGION_LENGTH__:0x400 + 0x00000400 __USER_SIGNATURE_REGION_LENGTH__ = DEFINED (__USER_SIGNATURE_REGION_LENGTH__)?__USER_SIGNATURE_REGION_LENGTH__:0x400 + +.hash + *(.hash) + +.dynsym + *(.dynsym) + +.dynstr + *(.dynstr) + +.gnu.version + *(.gnu.version) + +.gnu.version_d + *(.gnu.version_d) + +.gnu.version_r + *(.gnu.version_r) + +.rel.init + *(.rel.init) + +.rela.init + *(.rela.init) + +.rel.text + *(.rel.text) + *(.rel.text.*) + *(.rel.gnu.linkonce.t*) + +.rela.text + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t*) + +.rel.fini + *(.rel.fini) + +.rela.fini + *(.rela.fini) + +.rel.rodata + *(.rel.rodata) + *(.rel.rodata.*) + *(.rel.gnu.linkonce.r*) + +.rela.rodata + *(.rela.rodata) + *(.rela.rodata.*) + *(.rela.gnu.linkonce.r*) + +.rel.data + *(.rel.data) + *(.rel.data.*) + *(.rel.gnu.linkonce.d*) + +.rela.data + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d*) + +.rel.ctors + *(.rel.ctors) + +.rela.ctors + *(.rela.ctors) + +.rel.dtors + *(.rel.dtors) + +.rela.dtors + *(.rela.dtors) + +.rel.got + *(.rel.got) + +.rela.got + *(.rela.got) + +.rel.bss + *(.rel.bss) + +.rela.bss + *(.rela.bss) + +.rel.plt + *(.rel.plt) + +.rela.plt + *(.rela.plt) + +.text 0x00000000 0x194 + *(.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 + 0x00000000 __vectors + *(.vectors) + *(.progmem.gcc*) + 0x00000068 . = ALIGN (0x2) + 0x00000068 __trampolines_start = . + *(.trampolines) + .trampolines 0x00000068 0x0 linker stubs + *(.trampolines*) + 0x00000068 __trampolines_end = . + *libprintf_flt.a:*(.progmem.data) + *libc.a:*(.progmem.data) + *(.progmem*) + 0x00000068 . = ALIGN (0x2) + *(.jumptables) + *(.jumptables*) + *(.lowtext) + *(.lowtext*) + 0x00000068 __ctors_start = . + *(.ctors) + 0x00000068 __ctors_end = . + 0x00000068 __dtors_start = . + *(.dtors) + 0x00000068 __dtors_end = . + SORT(*)(.ctors) + SORT(*)(.dtors) + *(.init0) + .init0 0x00000068 0x0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o + 0x00000068 __init + *(.init0) + *(.init1) + *(.init1) + *(.init2) + .init2 0x00000068 0xc C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o + *(.init2) + *(.init3) + *(.init3) + *(.init4) + .init4 0x00000074 0x10 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) + 0x00000074 __do_clear_bss + *(.init4) + *(.init5) + *(.init5) + *(.init6) + *(.init6) + *(.init7) + *(.init7) + *(.init8) + *(.init8) + *(.init9) + .init9 0x00000084 0x8 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o + *(.init9) + *(.text) + .text 0x0000008c 0x4 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o + 0x0000008c __vector_22 + 0x0000008c __vector_1 + 0x0000008c __vector_24 + 0x0000008c __vector_12 + 0x0000008c __bad_interrupt + 0x0000008c __vector_6 + 0x0000008c __vector_3 + 0x0000008c __vector_23 + 0x0000008c __vector_25 + 0x0000008c __vector_11 + 0x0000008c __vector_13 + 0x0000008c __vector_17 + 0x0000008c __vector_19 + 0x0000008c __vector_7 + 0x0000008c __vector_5 + 0x0000008c __vector_4 + 0x0000008c __vector_9 + 0x0000008c __vector_2 + 0x0000008c __vector_21 + 0x0000008c __vector_15 + 0x0000008c __vector_8 + 0x0000008c __vector_10 + 0x0000008c __vector_16 + 0x0000008c __vector_18 + 0x0000008c __vector_20 + 0x00000090 . = ALIGN (0x2) + *(.text.*) + .text.setupTimer0 + 0x00000090 0x1c main.o + 0x00000090 setupTimer0 + .text.__vector_14 + 0x000000ac 0x4a main.o + 0x000000ac __vector_14 + .text.waitFor 0x000000f6 0x40 main.o + 0x000000f6 waitFor + .text.waitUntil + 0x00000136 0x20 main.o + 0x00000136 waitUntil + .text.initializeLED + 0x00000156 0x4 main.o + 0x00000156 initializeLED + .text.toggleLED + 0x0000015a 0xa main.o + 0x0000015a toggleLED + .text.main 0x00000164 0x2c main.o + 0x00000164 main + 0x00000190 . = 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) + *(.fini8) + *(.fini8) + *(.fini7) + *(.fini7) + *(.fini6) + *(.fini6) + *(.fini5) + *(.fini5) + *(.fini4) + *(.fini4) + *(.fini3) + *(.fini3) + *(.fini2) + *(.fini2) + *(.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) + 0x00000194 _etext = . + +.data 0x00800100 0x0 load address 0x00000194 + [!provide] PROVIDE (__data_start, .) + *(.data) + *(.data*) + *(.gnu.linkonce.d*) + *(.rodata) + *(.rodata*) + *(.gnu.linkonce.r*) + 0x00800100 . = ALIGN (0x2) + 0x00800100 _edata = . + [!provide] PROVIDE (__data_end, .) + +.bss 0x00800100 0x4 + 0x00800100 PROVIDE (__bss_start, .) + *(.bss) + *(.bss*) + .bss.systemClock + 0x00800100 0x4 main.o + 0x00800100 systemClock + *(COMMON) + 0x00800104 PROVIDE (__bss_end, .) + 0x00000194 __data_load_start = LOADADDR (.data) + 0x00000194 __data_load_end = (__data_load_start + SIZEOF (.data)) + +.noinit 0x00800104 0x0 + [!provide] PROVIDE (__noinit_start, .) + *(.noinit*) + [!provide] PROVIDE (__noinit_end, .) + 0x00800104 _end = . + [!provide] PROVIDE (__heap_start, .) + +.eeprom 0x00810000 0x0 + *(.eeprom*) + 0x00810000 __eeprom_end = . + +.fuse + *(.fuse) + *(.lfuse) + *(.hfuse) + *(.efuse) + +.lock + *(.lock*) + +.signature + *(.signature*) + +.user_signatures + *(.user_signatures*) + +.stab + *(.stab) + +.stabstr + *(.stabstr) + +.stab.excl + *(.stab.excl) + +.stab.exclstr + *(.stab.exclstr) + +.stab.index + *(.stab.index) + +.stab.indexstr + *(.stab.indexstr) + +.comment 0x00000000 0x30 + *(.comment) + .comment 0x00000000 0x30 main.o + 0x31 (size before relaxing) + +.note.gnu.avr.deviceinfo + 0x00000000 0x40 + .note.gnu.avr.deviceinfo + 0x00000000 0x40 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o + +.note.gnu.build-id + *(.note.gnu.build-id) + +.debug + *(.debug) + +.line + *(.line) + +.debug_srcinfo + *(.debug_srcinfo) + +.debug_sfnames + *(.debug_sfnames) + +.debug_aranges 0x00000000 0x50 + *(.debug_aranges) + .debug_aranges + 0x00000000 0x50 main.o + +.debug_pubnames + *(.debug_pubnames) + +.debug_info 0x00000000 0x7d8 + *(.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_abbrev 0x00000000 0x6b6 + *(.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_line 0x00000000 0x2b4 + *(.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_frame 0x00000000 0xb0 + *(.debug_frame) + .debug_frame 0x00000000 0xb0 main.o + +.debug_str 0x00000000 0x3c7 + *(.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_loc 0x00000000 0x92 + *(.debug_loc) + .debug_loc 0x00000000 0x92 main.o + +.debug_macinfo + *(.debug_macinfo) + +.debug_weaknames + *(.debug_weaknames) + +.debug_funcnames + *(.debug_funcnames) + +.debug_typenames + *(.debug_typenames) + +.debug_varnames + *(.debug_varnames) + +.debug_pubtypes + *(.debug_pubtypes) + +.debug_ranges 0x00000000 0x40 + *(.debug_ranges) + .debug_ranges 0x00000000 0x40 main.o + +.debug_macro + *(.debug_macro) +OUTPUT(P3.elf elf32-avr) +LOAD linker stubs diff --git a/P3/P3/Debug/P3.srec b/P3/P3/Debug/P3.srec new file mode 100644 index 0000000..8e93f0d --- /dev/null +++ b/P3/P3/Debug/P3.srec @@ -0,0 +1,28 @@ +S00A000050332E7372656397 +S11300000C9434000C9446000C9446000C94460066 +S11300100C9446000C9446000C9446000C94460044 +S11300200C9446000C9446000C9446000C94460034 +S11300300C9446000C9446000C9456000C94460014 +S11300400C9446000C9446000C9446000C94460014 +S11300500C9446000C9446000C9446000C94460004 +S11300600C9446000C94460011241FBECFEFD8E038 +S1130070DEBFCDBF21E0A0E0B1E001C01D92A430FD +S1130080B207E1F70E94B2000C94C8000C9400007F +S113009084B5826084BD85B5836085BD89EF87BDE5 +S11300A0EEE6F0E080818260808308951F920F92D3 +S11300B00FB60F9211248F939F93AF93BF938091A8 +S11300C0000190910101A0910201B09103010196F8 +S11300D0A11DB11D8093000190930101A093020121 +S11300E0B0930301BF91AF919F918F910F900FBE79 +S11300F00F901F9018950F931F930091000110917A +S113010001012091020130910301AB01BC01400FB8 +S1130110511F621F731F8091000190910101A091F2 +S11301200201B091030184179507A607B70798F356 +S11301301F910F910895AB01BC0180910001909132 +S11301400101A0910201B091030184179507A6074C +S1130150B70798F30895509A08959BB181E08927D1 +S11301608BB908950E94AB000E944800789464EF14 +S113017071E080E090E00E949B000E94AD0064EF7B +S113018071E080E090E00E947B000E94AD00F7CF18 +S1070190F894FFCF0D +S9030000FC diff --git a/P3/P3/Debug/main.d b/P3/P3/Debug/main.d new file mode 100644 index 0000000..8b670a9 --- /dev/null +++ b/P3/P3/Debug/main.d @@ -0,0 +1,37 @@ +main.d main.o: .././main.c \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \ + C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include/avr/iom328p.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \ + c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\include\stdint.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h: + +C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include/avr/iom328p.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h: + +c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h: diff --git a/P3/P3/Debug/main.o b/P3/P3/Debug/main.o new file mode 100644 index 0000000..a09028b Binary files /dev/null and b/P3/P3/Debug/main.o differ diff --git a/P3/P3/Debug/makedep.mk b/P3/P3/Debug/makedep.mk new file mode 100644 index 0000000..6a14fde --- /dev/null +++ b/P3/P3/Debug/makedep.mk @@ -0,0 +1,6 @@ +################################################################################ +# Automatically-generated file. Do not edit or delete the file +################################################################################ + +main.c + diff --git a/P3/P3/P3/P3.componentinfo.xml b/P3/P3/P3.componentinfo.xml similarity index 100% rename from P3/P3/P3/P3.componentinfo.xml rename to P3/P3/P3.componentinfo.xml diff --git a/P3/P3/P3/P3.cproj b/P3/P3/P3.cproj similarity index 100% rename from P3/P3/P3/P3.cproj rename to P3/P3/P3.cproj diff --git a/P3/P3/P3/main.c b/P3/P3/P3/main.c deleted file mode 100644 index cd549fa..0000000 --- a/P3/P3/P3/main.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * P3.c - * - * Created: 22.11.2023 18:20:05 - * Author : Safak - */ - -#define F_CPU 16000000UL -#include - -#define LED PIND0 - -volatile uint32_t systemClk = 0; - -void setUp_Timer0() { - TCCR0A = (1 << WGM01); // enable CTC mode of Timer/Counter 0 Control Register A - TCCR0B |= (1 << CS01) | (1 << CS00); // set Prescaler 64 - OCR0A = 249; // set up Output Comparison Register A for Timer0 to generate an interrupt when timer counter and OCR0A are equals - - // F_TimerInterrupt = F_clk / ( (prescaler) x (OCR + 1) ) - // => OCR = F_clk / (F_TimerInterrupt x prescaler) - 1 = ( 16MHz/(1000Hz x 64) ) - 1 = 249 - TIMSK0 = (1 << OCIE0A); // enable interrupt -} - -ISR(TIMER0_COMPA_vect) { - systemClk++; -} - -void waitFor(uint32_t ms) { - uint32_t currentTime = systemClk + ms; - while (systemClk < currentTime) {} -} - -void waitUntil(uint32_t ms) { - while (systemClk <= ms) {} -} - -int main(void) { - /* Replace with your application code */ - - DDRD = 0xff; // Data direction register D (D0) as output - PORTD = 0x00; - setUp_Timer0(); - sei(); // set global interrupt enable - - waitUntil(5000); // wait until 5s from the beginning then turn on LED - PORTD |= (1 << LED); // setting bit for LED - - while (1) { - waitFor(200); // wait for 0.2s then toggle LED - PORTD ^= (1 << LED); // toggling LED - } -} \ No newline at end of file diff --git a/P3/P3/main.c b/P3/P3/main.c new file mode 100644 index 0000000..102ef3a --- /dev/null +++ b/P3/P3/main.c @@ -0,0 +1,51 @@ +#include +#include + +#define F_CPU 16000000UL // 16MHz clock frequency +#define LED_PIN PD0 // LED is connected to Pin D0 + +volatile uint32_t systemClock = 0; + +void setupTimer0() { + // Configure Timer0 for CTC mode + TCCR0A |= (1 << WGM01); // Set Waveform Generation Mode bits for CTC + TCCR0B |= (1 << CS01) | (1 << CS00); // Set prescaler to 64 + OCR0A = 249; // Set Output Compare Register to 249 for ~1ms interrupt + TIMSK0 |= (1 << OCIE0A); // Enable Timer0 Output Compare A Match interrupt +} + +// Timer0 Output Compare A Match Interrupt Service Routine +ISR(TIMER0_COMPA_vect) { + systemClock++; // Increment the milliseconds counter +} + +void waitFor(uint32_t ms) { + uint32_t endTime = systemClock + ms; + while (systemClock < endTime); +} + +void waitUntil(uint32_t ms) { + while (systemClock < ms); +} + +void initializeLED() { + DDRD |= (1 << LED_PIN); // Set LED_PIN as an output +} + +void toggleLED() { + PORTD ^= (1 << LED_PIN); // Toggle the LED +} + +int main(void) { + initializeLED(); // Initialize the LED pin + setupTimer0(); // Setup Timer0 + sei(); // Enable global interrupts + + waitUntil(500); // Wait until 500 ms have passed + toggleLED(); // Toggle the LED to turn it on + + while (1) { + waitFor(500); // Wait for 500 ms + toggleLED(); // Toggle the LED + } +} \ No newline at end of file