From 4904c6afcbe4ea981ef3e282c3c2f55a958b13ab Mon Sep 17 00:00:00 2001 From: stijn Date: Wed, 24 Feb 2021 10:32:59 +0100 Subject: [PATCH] opdracht 3.3 --- Microcontrollers/Microcontrollers.atsln | 22 +- .../opdracht 2.3/opdracht 2.3.cproj | 2 +- Microcontrollers/opdracht 3.3/Debug/Makefile | 127 ++++++++ .../opdracht 3.3/Debug/makedep.mk | 6 + .../opdracht 3.3/Debug/opdracht 3.3.eep | 1 + .../opdracht 3.3/Debug/opdracht 3.3.lss | 292 ++++++++++++++++++ .../opdracht 3.3/Debug/opdracht 3.3.srec | 28 ++ Microcontrollers/opdracht 3.3/main.c | 57 ++++ .../opdracht 3.3.componentinfo.xml | 86 ++++++ .../opdracht 3.3/opdracht 3.3.cproj | 130 ++++++++ 10 files changed, 745 insertions(+), 6 deletions(-) create mode 100644 Microcontrollers/opdracht 3.3/Debug/Makefile create mode 100644 Microcontrollers/opdracht 3.3/Debug/makedep.mk create mode 100644 Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.eep create mode 100644 Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.lss create mode 100644 Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.srec create mode 100644 Microcontrollers/opdracht 3.3/main.c create mode 100644 Microcontrollers/opdracht 3.3/opdracht 3.3.componentinfo.xml create mode 100644 Microcontrollers/opdracht 3.3/opdracht 3.3.cproj diff --git a/Microcontrollers/Microcontrollers.atsln b/Microcontrollers/Microcontrollers.atsln index b8dfdb7..0eabf56 100644 --- a/Microcontrollers/Microcontrollers.atsln +++ b/Microcontrollers/Microcontrollers.atsln @@ -17,10 +17,14 @@ Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 2.1", "opdracht 2. EndProject Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "Opdracht 2.2", "Opdracht 2.2\Opdracht 2.2.cproj", "{7328E66F-4181-4553-9542-DA5CC2A74A4E}" EndProject -Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 2.3", "opdracht 2.3\opdracht 2.3.cproj", "{E0046CE4-D6F8-435F-9C6E-72E6EB89CCB3}" +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 2.3", "opdracht 2.3\opdracht 2.3.cproj", "{9154C165-89AB-43CF-8C28-23147BC26FDC}" EndProject Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 2.5", "opdracht 2.5\opdracht 2.5.cproj", "{C81B68AA-F4BB-4A5D-81F8-2737DCD1D4A7}" EndProject +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 2.4", "opdracht 2.4\opdracht 2.4.cproj", "{0FA0C637-5AC0-44F3-999B-49C114B97183}" +EndProject +Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 3.3", "opdracht 3.3\opdracht 3.3.cproj", "{985D5C75-F61E-49F1-A532-66A1E6141552}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|AVR = Debug|AVR @@ -55,14 +59,22 @@ Global {7328E66F-4181-4553-9542-DA5CC2A74A4E}.Debug|AVR.Build.0 = Debug|AVR {7328E66F-4181-4553-9542-DA5CC2A74A4E}.Release|AVR.ActiveCfg = Release|AVR {7328E66F-4181-4553-9542-DA5CC2A74A4E}.Release|AVR.Build.0 = Release|AVR - {E0046CE4-D6F8-435F-9C6E-72E6EB89CCB3}.Debug|AVR.ActiveCfg = Debug|AVR - {E0046CE4-D6F8-435F-9C6E-72E6EB89CCB3}.Debug|AVR.Build.0 = Debug|AVR - {E0046CE4-D6F8-435F-9C6E-72E6EB89CCB3}.Release|AVR.ActiveCfg = Release|AVR - {E0046CE4-D6F8-435F-9C6E-72E6EB89CCB3}.Release|AVR.Build.0 = Release|AVR + {9154C165-89AB-43CF-8C28-23147BC26FDC}.Debug|AVR.ActiveCfg = Debug|AVR + {9154C165-89AB-43CF-8C28-23147BC26FDC}.Debug|AVR.Build.0 = Debug|AVR + {9154C165-89AB-43CF-8C28-23147BC26FDC}.Release|AVR.ActiveCfg = Release|AVR + {9154C165-89AB-43CF-8C28-23147BC26FDC}.Release|AVR.Build.0 = Release|AVR {C81B68AA-F4BB-4A5D-81F8-2737DCD1D4A7}.Debug|AVR.ActiveCfg = Debug|AVR {C81B68AA-F4BB-4A5D-81F8-2737DCD1D4A7}.Debug|AVR.Build.0 = Debug|AVR {C81B68AA-F4BB-4A5D-81F8-2737DCD1D4A7}.Release|AVR.ActiveCfg = Release|AVR {C81B68AA-F4BB-4A5D-81F8-2737DCD1D4A7}.Release|AVR.Build.0 = Release|AVR + {0FA0C637-5AC0-44F3-999B-49C114B97183}.Debug|AVR.ActiveCfg = Debug|AVR + {0FA0C637-5AC0-44F3-999B-49C114B97183}.Debug|AVR.Build.0 = Debug|AVR + {0FA0C637-5AC0-44F3-999B-49C114B97183}.Release|AVR.ActiveCfg = Release|AVR + {0FA0C637-5AC0-44F3-999B-49C114B97183}.Release|AVR.Build.0 = Release|AVR + {985D5C75-F61E-49F1-A532-66A1E6141552}.Debug|AVR.ActiveCfg = Debug|AVR + {985D5C75-F61E-49F1-A532-66A1E6141552}.Debug|AVR.Build.0 = Debug|AVR + {985D5C75-F61E-49F1-A532-66A1E6141552}.Release|AVR.ActiveCfg = Release|AVR + {985D5C75-F61E-49F1-A532-66A1E6141552}.Release|AVR.Build.0 = Release|AVR EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Microcontrollers/opdracht 2.3/opdracht 2.3.cproj b/Microcontrollers/opdracht 2.3/opdracht 2.3.cproj index 93b2609..b3965e7 100644 --- a/Microcontrollers/opdracht 2.3/opdracht 2.3.cproj +++ b/Microcontrollers/opdracht 2.3/opdracht 2.3.cproj @@ -4,7 +4,7 @@ 2.0 7.0 com.microchip.xc8 - {e0046ce4-d6f8-435f-9c6e-72e6eb89ccb3} + {9154c165-89ab-43cf-8c28-23147bc26fdc} ATmega128 none Executable diff --git a/Microcontrollers/opdracht 3.3/Debug/Makefile b/Microcontrollers/opdracht 3.3/Debug/Makefile new file mode 100644 index 0000000..8acc317 --- /dev/null +++ b/Microcontrollers/opdracht 3.3/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 +=opdracht\ 3.3.elf + +OUTPUT_FILE_PATH_AS_ARGS +="opdracht 3.3.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.6.364\include" -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128" -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="opdracht 3.3.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128" + @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 "opdracht 3.3.elf" "opdracht 3.3.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 "opdracht 3.3.elf" "opdracht 3.3.eep" || exit 0 + "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "opdracht 3.3.elf" > "opdracht 3.3.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 "opdracht 3.3.elf" "opdracht 3.3.srec" + "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "opdracht 3.3.elf" + + + + + + + +# Other Targets +clean: + -$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES) + -$(RM) $(C_DEPS_AS_ARGS) + rm -rf "opdracht 3.3.elf" "opdracht 3.3.a" "opdracht 3.3.hex" "opdracht 3.3.lss" "opdracht 3.3.eep" "opdracht 3.3.map" "opdracht 3.3.srec" "opdracht 3.3.usersignatures" + \ No newline at end of file diff --git a/Microcontrollers/opdracht 3.3/Debug/makedep.mk b/Microcontrollers/opdracht 3.3/Debug/makedep.mk new file mode 100644 index 0000000..6a14fde --- /dev/null +++ b/Microcontrollers/opdracht 3.3/Debug/makedep.mk @@ -0,0 +1,6 @@ +################################################################################ +# Automatically-generated file. Do not edit or delete the file +################################################################################ + +main.c + diff --git a/Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.eep b/Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.eep new file mode 100644 index 0000000..7c166a1 --- /dev/null +++ b/Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.lss b/Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.lss new file mode 100644 index 0000000..ffbe8ff --- /dev/null +++ b/Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.lss @@ -0,0 +1,292 @@ + +opdracht 3.3.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .data 00000002 00800100 00000190 00000224 2**0 + CONTENTS, ALLOC, LOAD, DATA + 1 .text 00000190 00000000 00000000 00000094 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 2 .bss 00000002 00800102 00800102 00000226 2**0 + ALLOC + 3 .comment 00000030 00000000 00000000 00000226 2**0 + CONTENTS, READONLY + 4 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 00000258 2**2 + CONTENTS, READONLY + 5 .debug_aranges 00000038 00000000 00000000 00000294 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_info 00000944 00000000 00000000 000002cc 2**0 + CONTENTS, READONLY, DEBUGGING + 7 .debug_abbrev 00000878 00000000 00000000 00000c10 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_line 00000329 00000000 00000000 00001488 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_frame 00000074 00000000 00000000 000017b4 2**2 + CONTENTS, READONLY, DEBUGGING + 10 .debug_str 0000046a 00000000 00000000 00001828 2**0 + CONTENTS, READONLY, DEBUGGING + 11 .debug_loc 000000cd 00000000 00000000 00001c92 2**0 + CONTENTS, READONLY, DEBUGGING + 12 .debug_ranges 00000028 00000000 00000000 00001d5f 2**0 + CONTENTS, READONLY, DEBUGGING + +Disassembly of section .text: + +00000000 <__vectors>: + 0: 45 c0 rjmp .+138 ; 0x8c <__ctors_end> + 2: 00 00 nop + 4: 60 c0 rjmp .+192 ; 0xc6 <__bad_interrupt> + 6: 00 00 nop + 8: 5e c0 rjmp .+188 ; 0xc6 <__bad_interrupt> + a: 00 00 nop + c: 5c c0 rjmp .+184 ; 0xc6 <__bad_interrupt> + e: 00 00 nop + 10: 5a c0 rjmp .+180 ; 0xc6 <__bad_interrupt> + 12: 00 00 nop + 14: 58 c0 rjmp .+176 ; 0xc6 <__bad_interrupt> + 16: 00 00 nop + 18: 56 c0 rjmp .+172 ; 0xc6 <__bad_interrupt> + 1a: 00 00 nop + 1c: 54 c0 rjmp .+168 ; 0xc6 <__bad_interrupt> + 1e: 00 00 nop + 20: 52 c0 rjmp .+164 ; 0xc6 <__bad_interrupt> + 22: 00 00 nop + 24: 69 c0 rjmp .+210 ; 0xf8 <__vector_9> + 26: 00 00 nop + 28: 4e c0 rjmp .+156 ; 0xc6 <__bad_interrupt> + 2a: 00 00 nop + 2c: 4c c0 rjmp .+152 ; 0xc6 <__bad_interrupt> + 2e: 00 00 nop + 30: 4a c0 rjmp .+148 ; 0xc6 <__bad_interrupt> + 32: 00 00 nop + 34: 48 c0 rjmp .+144 ; 0xc6 <__bad_interrupt> + 36: 00 00 nop + 38: 46 c0 rjmp .+140 ; 0xc6 <__bad_interrupt> + 3a: 00 00 nop + 3c: 44 c0 rjmp .+136 ; 0xc6 <__bad_interrupt> + 3e: 00 00 nop + 40: 42 c0 rjmp .+132 ; 0xc6 <__bad_interrupt> + 42: 00 00 nop + 44: 40 c0 rjmp .+128 ; 0xc6 <__bad_interrupt> + 46: 00 00 nop + 48: 3e c0 rjmp .+124 ; 0xc6 <__bad_interrupt> + 4a: 00 00 nop + 4c: 3c c0 rjmp .+120 ; 0xc6 <__bad_interrupt> + 4e: 00 00 nop + 50: 3a c0 rjmp .+116 ; 0xc6 <__bad_interrupt> + 52: 00 00 nop + 54: 38 c0 rjmp .+112 ; 0xc6 <__bad_interrupt> + 56: 00 00 nop + 58: 36 c0 rjmp .+108 ; 0xc6 <__bad_interrupt> + 5a: 00 00 nop + 5c: 34 c0 rjmp .+104 ; 0xc6 <__bad_interrupt> + 5e: 00 00 nop + 60: 32 c0 rjmp .+100 ; 0xc6 <__bad_interrupt> + 62: 00 00 nop + 64: 30 c0 rjmp .+96 ; 0xc6 <__bad_interrupt> + 66: 00 00 nop + 68: 2e c0 rjmp .+92 ; 0xc6 <__bad_interrupt> + 6a: 00 00 nop + 6c: 2c c0 rjmp .+88 ; 0xc6 <__bad_interrupt> + 6e: 00 00 nop + 70: 2a c0 rjmp .+84 ; 0xc6 <__bad_interrupt> + 72: 00 00 nop + 74: 28 c0 rjmp .+80 ; 0xc6 <__bad_interrupt> + 76: 00 00 nop + 78: 26 c0 rjmp .+76 ; 0xc6 <__bad_interrupt> + 7a: 00 00 nop + 7c: 24 c0 rjmp .+72 ; 0xc6 <__bad_interrupt> + 7e: 00 00 nop + 80: 22 c0 rjmp .+68 ; 0xc6 <__bad_interrupt> + 82: 00 00 nop + 84: 20 c0 rjmp .+64 ; 0xc6 <__bad_interrupt> + 86: 00 00 nop + 88: 1e c0 rjmp .+60 ; 0xc6 <__bad_interrupt> + ... + +0000008c <__ctors_end>: + 8c: 11 24 eor r1, r1 + 8e: 1f be out 0x3f, r1 ; 63 + 90: cf ef ldi r28, 0xFF ; 255 + 92: d0 e1 ldi r29, 0x10 ; 16 + 94: de bf out 0x3e, r29 ; 62 + 96: cd bf out 0x3d, r28 ; 61 + +00000098 <__do_copy_data>: + 98: 11 e0 ldi r17, 0x01 ; 1 + 9a: a0 e0 ldi r26, 0x00 ; 0 + 9c: b1 e0 ldi r27, 0x01 ; 1 + 9e: e0 e9 ldi r30, 0x90 ; 144 + a0: f1 e0 ldi r31, 0x01 ; 1 + 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: a2 30 cpi r26, 0x02 ; 2 + 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: a2 e0 ldi r26, 0x02 ; 2 + b6: b1 e0 ldi r27, 0x01 ; 1 + b8: 01 c0 rjmp .+2 ; 0xbc <.do_clear_bss_start> + +000000ba <.do_clear_bss_loop>: + ba: 1d 92 st X+, r1 + +000000bc <.do_clear_bss_start>: + bc: a4 30 cpi r26, 0x04 ; 4 + be: b2 07 cpc r27, r18 + c0: e1 f7 brne .-8 ; 0xba <.do_clear_bss_loop> + c2: 5b d0 rcall .+182 ; 0x17a
+ c4: 63 c0 rjmp .+198 ; 0x18c <_exit> + +000000c6 <__bad_interrupt>: + c6: 9c cf rjmp .-200 ; 0x0 <__vectors> + +000000c8 : +#define BIT(x) (1 << (x)) + +// wait(): busy waiting for 'ms' millisecond +// Used library: util/delay.h +void wait( int ms ) { + for (int tms=0; tms + #else + //round up by default + __ticks_dc = (uint32_t)(ceil(fabs(__tmp))); + #endif + + __builtin_avr_delay_cycles(__ticks_dc); + ce: ef ec ldi r30, 0xCF ; 207 + d0: f7 e0 ldi r31, 0x07 ; 7 + d2: 31 97 sbiw r30, 0x01 ; 1 + d4: f1 f7 brne .-4 ; 0xd2 + d6: 00 c0 rjmp .+0 ; 0xd8 + d8: 00 00 nop + da: 2f 5f subi r18, 0xFF ; 255 + dc: 3f 4f sbci r19, 0xFF ; 255 + de: 28 17 cp r18, r24 + e0: 39 07 cpc r19, r25 + e2: ac f3 brlt .-22 ; 0xce + _delay_ms( 1 ); // library function (max 30 ms at 8MHz) + } +} + e4: 08 95 ret + +000000e6 : + +volatile int msCount = 0; + +void timer2Init( void ) { + OCR2 = 155; // Compare value of counter 2 + e6: 8b e9 ldi r24, 0x9B ; 155 + e8: 83 bd out 0x23, r24 ; 35 + TIMSK |= BIT(7); // T2 compare match interrupt enable + ea: 87 b7 in r24, 0x37 ; 55 + ec: 80 68 ori r24, 0x80 ; 128 + ee: 87 bf out 0x37, r24 ; 55 + sei(); // turn_on intr all + f0: 78 94 sei + TCCR2 = 0b00001011; // Initialize T2: timer, prescaler=32, compare output disconnected,CTC,RUN + f2: 8b e0 ldi r24, 0x0B ; 11 + f4: 85 bd out 0x25, r24 ; 37 + f6: 08 95 ret + +000000f8 <__vector_9>: +} +unsigned int msThersh = 15; + +ISR( TIMER2_COMP_vect ) { + f8: 1f 92 push r1 + fa: 0f 92 push r0 + fc: 0f b6 in r0, 0x3f ; 63 + fe: 0f 92 push r0 + 100: 11 24 eor r1, r1 + 102: 2f 93 push r18 + 104: 3f 93 push r19 + 106: 8f 93 push r24 + 108: 9f 93 push r25 + msCount++; // Increment ms counter + 10a: 80 91 02 01 lds r24, 0x0102 ; 0x800102 <__data_end> + 10e: 90 91 03 01 lds r25, 0x0103 ; 0x800103 <__data_end+0x1> + 112: 01 96 adiw r24, 0x01 ; 1 + 114: 90 93 03 01 sts 0x0103, r25 ; 0x800103 <__data_end+0x1> + 118: 80 93 02 01 sts 0x0102, r24 ; 0x800102 <__data_end> + if ( msCount >= msThersh ) { + 11c: 20 91 02 01 lds r18, 0x0102 ; 0x800102 <__data_end> + 120: 30 91 03 01 lds r19, 0x0103 ; 0x800103 <__data_end+0x1> + 124: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <__DATA_REGION_ORIGIN__> + 128: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 12c: 28 17 cp r18, r24 + 12e: 39 07 cpc r19, r25 + 130: d8 f0 brcs .+54 ; 0x168 <__vector_9+0x70> + // Toggle bit 0 van PORTC + PORTC ^= BIT(0); + 132: 95 b3 in r25, 0x15 ; 21 + 134: 81 e0 ldi r24, 0x01 ; 1 + 136: 89 27 eor r24, r25 + 138: 85 bb out 0x15, r24 ; 21 + msCount = 0; + 13a: 10 92 03 01 sts 0x0103, r1 ; 0x800103 <__data_end+0x1> + 13e: 10 92 02 01 sts 0x0102, r1 ; 0x800102 <__data_end> + if(msThersh == 15){ + 142: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <__DATA_REGION_ORIGIN__> + 146: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 14a: 0f 97 sbiw r24, 0x0f ; 15 + 14c: 39 f4 brne .+14 ; 0x15c <__vector_9+0x64> + msThersh = 25; + 14e: 89 e1 ldi r24, 0x19 ; 25 + 150: 90 e0 ldi r25, 0x00 ; 0 + 152: 90 93 01 01 sts 0x0101, r25 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 156: 80 93 00 01 sts 0x0100, r24 ; 0x800100 <__DATA_REGION_ORIGIN__> + 15a: 06 c0 rjmp .+12 ; 0x168 <__vector_9+0x70> + } else { + msThersh = 15; + 15c: 8f e0 ldi r24, 0x0F ; 15 + 15e: 90 e0 ldi r25, 0x00 ; 0 + 160: 90 93 01 01 sts 0x0101, r25 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 164: 80 93 00 01 sts 0x0100, r24 ; 0x800100 <__DATA_REGION_ORIGIN__> + } // Reset ms_count value + } + +} + 168: 9f 91 pop r25 + 16a: 8f 91 pop r24 + 16c: 3f 91 pop r19 + 16e: 2f 91 pop r18 + 170: 0f 90 pop r0 + 172: 0f be out 0x3f, r0 ; 63 + 174: 0f 90 pop r0 + 176: 1f 90 pop r1 + 178: 18 95 reti + +0000017a
: + +int main( void ) { + DDRC = 0xFF; + 17a: 8f ef ldi r24, 0xFF ; 255 + 17c: 84 bb out 0x14, r24 ; 20 + PORTC = BIT(0); // set PORTC for output (toggle PC0) + 17e: 81 e0 ldi r24, 0x01 ; 1 + 180: 85 bb out 0x15, r24 ; 21 + timer2Init(); + 182: b1 df rcall .-158 ; 0xe6 + + while (1) { + // do something else + wait(10); // every 10 ms (busy waiting + 184: 8a e0 ldi r24, 0x0A ; 10 + 186: 90 e0 ldi r25, 0x00 ; 0 + 188: 9f df rcall .-194 ; 0xc8 + 18a: fc cf rjmp .-8 ; 0x184 + +0000018c <_exit>: + 18c: f8 94 cli + +0000018e <__stop_program>: + 18e: ff cf rjmp .-2 ; 0x18e <__stop_program> diff --git a/Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.srec b/Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.srec new file mode 100644 index 0000000..1ddea73 --- /dev/null +++ b/Microcontrollers/opdracht 3.3/Debug/opdracht 3.3.srec @@ -0,0 +1,28 @@ +S01400006F7064726163687420332E332E7372656307 +S113000045C0000060C000005EC000005CC000008D +S11300105AC0000058C0000056C0000054C0000080 +S113002052C0000069C000004EC000004CC0000077 +S11300304AC0000048C0000046C0000044C00000A0 +S113004042C0000040C000003EC000003CC00000B0 +S11300503AC0000038C0000036C0000034C00000C0 +S113006032C0000030C000002EC000002CC00000D0 +S11300702AC0000028C0000026C0000024C00000E0 +S113008022C0000020C000001EC0000011241FBEBA +S1130090CFEFD0E1DEBFCDBF11E0A0E0B1E0E0E9F9 +S11300A0F1E000E00BBF02C007900D92A230B1074F +S11300B0D9F721E0A2E0B1E001C01D92A430B2075B +S11300C0E1F75BD063C09CCF20E030E008C0EFECE8 +S11300D0F7E03197F1F700C000002F5F3F4F28177A +S11300E03907ACF308958BE983BD87B7806887BF70 +S11300F078948BE085BD08951F920F920FB60F92EE +S113010011242F933F938F939F9380910201909199 +S1130110030101969093030180930201209102014F +S11301203091030180910001909101012817390752 +S1130130D8F095B381E0892785BB10920301109212 +S1130140020180910001909101010F9739F489E136 +S113015090E0909301018093000106C08FE090E04D +S113016090930101809300019F918F913F912F9172 +S11301700F900FBE0F901F9018958FEF84BB81E0F6 +S113018085BBB1DF8AE090E09FDFFCCFF894FFCF1E +S10501900F005A +S9030000FC diff --git a/Microcontrollers/opdracht 3.3/main.c b/Microcontrollers/opdracht 3.3/main.c new file mode 100644 index 0000000..f8aa9a6 --- /dev/null +++ b/Microcontrollers/opdracht 3.3/main.c @@ -0,0 +1,57 @@ +/* + * timer_t2_ms.c + * + * Created: 21/02/2021 13:20:32 + * Author : Etienne + */ + +#define F_CPU 8e6 +#include +#include +#include + +#define BIT(x) (1 << (x)) + +// wait(): busy waiting for 'ms' millisecond +// Used library: util/delay.h +void wait( int ms ) { + for (int tms=0; tms= msThersh ) { + // Toggle bit 0 van PORTC + PORTC ^= BIT(0); + msCount = 0; + if(msThersh == 15){ + msThersh = 25; + } else { + msThersh = 15; + } // Reset ms_count value + } + +} + +int main( void ) { + DDRC = 0xFF; + PORTC = BIT(0); // set PORTC for output (toggle PC0) + timer2Init(); + + while (1) { + // do something else + wait(10); // every 10 ms (busy waiting + } +} \ No newline at end of file diff --git a/Microcontrollers/opdracht 3.3/opdracht 3.3.componentinfo.xml b/Microcontrollers/opdracht 3.3/opdracht 3.3.componentinfo.xml new file mode 100644 index 0000000..6953936 --- /dev/null +++ b/Microcontrollers/opdracht 3.3/opdracht 3.3.componentinfo.xml @@ -0,0 +1,86 @@ + + + + + + + Device + Startup + + + Atmel + 1.6.0 + C:/Program Files (x86)\Atmel\Studio\7.0\Packs + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\include\ + + include + C + + + include/ + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\include\avr\iom128.h + + header + C + JdJ7J9I/SJh965SEyyyVYw== + + include/avr/iom128.h + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\templates\main.c + template + source + C Exe + rR6mgUtO8q2QLIRcSnx1LA== + + templates/main.c + Main file (.c) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\templates\main.cpp + template + source + C Exe + mkKaE95TOoATsuBGv6jmxg== + + templates/main.cpp + Main file (.cpp) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128 + + libraryPrefix + GCC + + + gcc/dev/atmega128 + + + + + ATmega_DFP + C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.6.364/Atmel.ATmega_DFP.pdsc + 1.6.364 + true + ATmega128 + + + + Resolved + Fixed + true + + + \ No newline at end of file diff --git a/Microcontrollers/opdracht 3.3/opdracht 3.3.cproj b/Microcontrollers/opdracht 3.3/opdracht 3.3.cproj new file mode 100644 index 0000000..4ad83d2 --- /dev/null +++ b/Microcontrollers/opdracht 3.3/opdracht 3.3.cproj @@ -0,0 +1,130 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {985d5c75-f61e-49f1-a532-66a1e6141552} + ATmega128 + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + opdracht 3.3 + opdracht 3.3 + opdracht 3.3 + Native + true + false + true + true + + + true + + 2 + 0 + 0 + + + + + + + + + + + + + + + + + + -mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128" + True + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\ + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\ + + + + + + + + + -mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128" + True + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\ + + + Optimize debugging experience (-Og) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\ + + + Default (-Wa,-g) + + + + + + compile + + + + \ No newline at end of file