diff --git a/Microcontrollers/Microcontrollers.atsln b/Microcontrollers/Microcontrollers.atsln index 461028b..c5df7a3 100644 --- a/Microcontrollers/Microcontrollers.atsln +++ b/Microcontrollers/Microcontrollers.atsln @@ -17,6 +17,8 @@ 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", "{9154C165-89AB-43CF-8C28-23147BC26FDC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|AVR = Debug|AVR @@ -51,6 +53,10 @@ 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 + {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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Microcontrollers/Opdracht 2.2/Opdracht 2.2.cproj b/Microcontrollers/Opdracht 2.2/Opdracht 2.2.cproj index 4052ff0..24704cc 100644 --- a/Microcontrollers/Opdracht 2.2/Opdracht 2.2.cproj +++ b/Microcontrollers/Opdracht 2.2/Opdracht 2.2.cproj @@ -28,54 +28,66 @@ 0 0 + + + + + + + + + + + + - True - True - True - - - (%24DeviceMacro) - NDEBUG - - - Optimize for size (-Os) - True - True - True - - - libm - - - + True + True + True + + + (%24DeviceMacro) + NDEBUG + + + Optimize for size (-Os) + True + True + True + + + libm + + + - True - True - - - (%24DeviceMacro) - DEBUG - - - Optimize debugging experience (-Og) - True - True - Default (-g2) - True - - - libm - - - Default (-Wa,-g) - + True + True + + + (%24DeviceMacro) + DEBUG + + + Optimize debugging experience (-Og) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + diff --git a/Microcontrollers/opdracht 1.6/opdracht 1.6.cproj b/Microcontrollers/opdracht 1.6/opdracht 1.6.cproj index 614a1dc..6d889fd 100644 --- a/Microcontrollers/opdracht 1.6/opdracht 1.6.cproj +++ b/Microcontrollers/opdracht 1.6/opdracht 1.6.cproj @@ -20,74 +20,74 @@ false true true - + 0x20000000 true - + exception_table 2 0 0 - - - - - - - - - + + + + + + + + + - True - True - True - - - (%24DeviceMacro) - NDEBUG - - - Optimize for size (-Os) - True - True - True - - - libm - - - + True + True + True + + + (%24DeviceMacro) + NDEBUG + + + Optimize for size (-Os) + True + True + True + + + libm + + + - True - True - - - (%24DeviceMacro) - DEBUG - - - Optimize debugging experience (-Og) - True - True - Default (-g2) - True - - - libm - - - Default (-Wa,-g) - + True + True + + + (%24DeviceMacro) + DEBUG + + + Optimize debugging experience (-Og) + True + True + Default (-g2) + True + + + libm + + + Default (-Wa,-g) + diff --git a/Microcontrollers/opdracht 1.7a/main.c b/Microcontrollers/opdracht 1.7a/main.c index eaea0e3..87fbe33 100644 --- a/Microcontrollers/opdracht 1.7a/main.c +++ b/Microcontrollers/opdracht 1.7a/main.c @@ -1,104 +1,104 @@ -/* - * main.c - * - * Created: 08-Feb-21 10:03:33 AM - * Author: lemms - */ -# define F_CPU 10000000UL - -#include -#include - -typedef enum { - IDLE, - PERPARE_COFFEE_POWDER, - BOIL_WATER, - POUR_COFFEE - } state ; - - typedef enum { - false = 0, - true = 1 - } bool; - -state current_state; - -void wait( int ms ) -{ - for (int i=0; i 2000); - setPourPumpState(shouldPour); - - milisPouring++; - - if(!shouldPour){ - milisPouring = 0; - } - break; - } - wait(1); - } -} \ No newline at end of file +// /* +// * main.c +// * +// * Created: 08-Feb-21 10:03:33 AM +// * Author: lemms +// */ +// # define F_CPU 10000000UL +// +// #include +// #include +// +// typedef enum { +// IDLE, +// PERPARE_COFFEE_POWDER, +// BOIL_WATER, +// POUR_COFFEE +// } state ; +// +// typedef enum { +// false = 0, +// true = 1 +// } bool; +// +// state current_state; +// +// void wait( int ms ) +// { +// for (int i=0; i 2000); +// setPourPumpState(shouldPour); +// +// milisPouring++; +// +// if(!shouldPour){ +// milisPouring = 0; +// } +// break; +// } +// wait(1); +// } +// } \ No newline at end of file diff --git a/Microcontrollers/opdracht 2.1/main.c b/Microcontrollers/opdracht 2.1/main.c index 561e21a..6c74ac8 100644 --- a/Microcontrollers/opdracht 2.1/main.c +++ b/Microcontrollers/opdracht 2.1/main.c @@ -14,7 +14,7 @@ ** Author: dkroeske@gmail.com ** -------------------------------------------------------------------------*/ -#define F_CPU 8e6 +#define F_CPU 10e6 #include #include #include @@ -44,18 +44,7 @@ notes: Set PORTD.5 Version : DMK, Initial code *******************************************************************/ ISR( INT0_vect ) { - PORTD |= (1<<5); -} - -/****************************************************************** -short: ISR INT1 -inputs: -outputs: -notes: Clear PORTD.5 -Version : DMK, Initial code -*******************************************************************/ -ISR( INT1_vect ) { - PORTD &= ~(1<<5); + PORTC } /****************************************************************** @@ -70,7 +59,7 @@ int main( void ) { DDRD = 0xF0; // PORTD(7:4) output, PORTD(3:0) input // Init Interrupt hardware - EICRA |= 0x0B; // INT1 falling edge, INT0 rising edge + EICRA |= 0x00000010; // INT0 falling edge EIMSK |= 0x03; // Enable INT1 & INT0 // Enable global interrupt system @@ -78,8 +67,7 @@ int main( void ) { sei(); while (1) { - PORTD ^= (1<<7); // Toggle PORTD.7 - wait( 500 ); + } return 1; diff --git a/Microcontrollers/opdracht 2.3/Debug/Makefile b/Microcontrollers/opdracht 2.3/Debug/Makefile new file mode 100644 index 0000000..6e29a02 --- /dev/null +++ b/Microcontrollers/opdracht 2.3/Debug/Makefile @@ -0,0 +1,125 @@ +################################################################################ +# 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\ 2.3.elf + +OUTPUT_FILE_PATH_AS_ARGS +="opdracht 2.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: XC8 C Compiler : 2.31 + $(QUOTE)C:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe$(QUOTE) -mcpu=ATmega128 -mdfp="C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\xc8" -c -x c -mext=cci -D__ATmega128__ -O0 -ffunction-sections -fdata-sections -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: XC8 C Linker : 2.31 + $(QUOTE)C:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -mcpu=ATmega128 -mdfp="C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\xc8" -Wl,-Map="opdracht 2.3.map" -Wl,--start-group -Wl,--end-group -Wl,--gc-sections -O0 -ffunction-sections -fdata-sections --memorysummary,memoryfile.xml + @echo Finished building target: $@ + "C:\Program Files\Microchip\xc8\v2.31\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "opdracht 2.3.elf" "opdracht 2.3.hex" + "C:\Program Files\Microchip\xc8\v2.31\bin\avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "opdracht 2.3.elf" "opdracht 2.3.eep" || exit 0 + "C:\Program Files\Microchip\xc8\v2.31\bin\avr-objdump.exe" -h -S "opdracht 2.3.elf" > "opdracht 2.3.lss" + + + + + + + +# Other Targets +clean: + -$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES) + -$(RM) $(C_DEPS_AS_ARGS) + rm -rf "opdracht 2.3.elf" "opdracht 2.3.hex" "opdracht 2.3.eep" "opdracht 2.3.map" "opdracht 2.3.usersignatures" "opdracht 2.3.a" "opdracht 2.3.lss" + \ No newline at end of file diff --git a/Microcontrollers/opdracht 2.3/Debug/makedep.mk b/Microcontrollers/opdracht 2.3/Debug/makedep.mk new file mode 100644 index 0000000..6a14fde --- /dev/null +++ b/Microcontrollers/opdracht 2.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 2.3/Debug/memoryfile.xml b/Microcontrollers/opdracht 2.3/Debug/memoryfile.xml new file mode 100644 index 0000000..79aeaa2 --- /dev/null +++ b/Microcontrollers/opdracht 2.3/Debug/memoryfile.xml @@ -0,0 +1,17 @@ + + + + + bytes + 131072 + 769 + 130303 + + + bytes + 4096 + 2 + 4094 + + + diff --git a/Microcontrollers/opdracht 2.3/Debug/opdracht 2.3.eep b/Microcontrollers/opdracht 2.3/Debug/opdracht 2.3.eep new file mode 100644 index 0000000..7c166a1 --- /dev/null +++ b/Microcontrollers/opdracht 2.3/Debug/opdracht 2.3.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/Microcontrollers/opdracht 2.3/Debug/opdracht 2.3.lss b/Microcontrollers/opdracht 2.3/Debug/opdracht 2.3.lss new file mode 100644 index 0000000..700c25e --- /dev/null +++ b/Microcontrollers/opdracht 2.3/Debug/opdracht 2.3.lss @@ -0,0 +1,390 @@ + +opdracht 2.3.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .data 00000000 00800100 00800100 00000396 2**0 + ALLOC, LOAD, DATA + 1 .text 000000ea 00000000 00000000 00000094 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 2 .bss 00000002 00800100 00800100 00000396 2**0 + ALLOC + 3 .comment 0000002f 00000000 00000000 00000396 2**0 + CONTENTS, READONLY + 4 .debug_info 00000780 00000000 00000000 000003c5 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_abbrev 00000718 00000000 00000000 00000b45 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_line 0000016d 00000000 00000000 0000125d 2**0 + CONTENTS, READONLY, DEBUGGING + 7 .debug_str 0000027d 00000000 00000000 000013ca 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .text 00000004 000002fe 000002fe 00000392 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 9 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 00001648 2**2 + CONTENTS, READONLY, DEBUGGING + 10 .text.__vector_1 00000080 000000fa 000000fa 0000018e 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 11 .text.__vector_2 00000080 0000017a 0000017a 0000020e 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 12 .progmemx.data.Characters 0000000f 000000ea 000000ea 0000017e 2**0 + CONTENTS, ALLOC, LOAD, READONLY, PROGMEMX + 13 .text.initDisplay 0000001a 000002d6 000002d6 0000036a 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 14 .text.setDisplay 00000062 00000274 00000274 00000308 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 15 .text.main 0000007a 000001fa 000001fa 0000028e 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 16 .text.libgcc 0000000e 000002f0 000002f0 00000384 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + +Disassembly of section .text: + +00000000 <__vectors>: + 0: 0c 94 49 00 jmp 0x92 ; 0x92 <__ctors_end> + 4: 0c 94 7d 00 jmp 0xfa ; 0xfa <__vector_1> + 8: 0c 94 bd 00 jmp 0x17a ; 0x17a <__vector_2> + c: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 10: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 14: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 18: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 1c: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 20: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 24: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 28: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 2c: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 30: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 34: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 38: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 3c: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 40: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 44: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 48: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 4c: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 50: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 54: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 58: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 5c: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 60: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 64: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 68: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 6c: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 70: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 74: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 78: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 7c: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 80: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 84: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + 88: 0c 94 7f 01 jmp 0x2fe ; 0x2fe <__bad_interrupt> + +0000008c <.dinit>: + 8c: 01 00 .word 0x0001 ; ???? + 8e: 01 02 muls r16, r17 + 90: 80 00 .word 0x0080 ; ???? + +00000092 <__ctors_end>: + 92: 11 24 eor r1, r1 + 94: 1f be out 0x3f, r1 ; 63 + 96: cf ef ldi r28, 0xFF ; 255 + 98: d0 e1 ldi r29, 0x10 ; 16 + 9a: de bf out 0x3e, r29 ; 62 + 9c: cd bf out 0x3d, r28 ; 61 + +0000009e <__do_copy_data>: + 9e: ec e8 ldi r30, 0x8C ; 140 + a0: f0 e0 ldi r31, 0x00 ; 0 + a2: 40 e0 ldi r20, 0x00 ; 0 + a4: 19 c0 rjmp .+50 ; 0xd8 <__do_clear_bss+0x8> + a6: b7 91 elpm r27, Z+ + a8: a7 91 elpm r26, Z+ + aa: 37 91 elpm r19, Z+ + ac: 27 91 elpm r18, Z+ + ae: 07 91 elpm r16, Z+ + b0: 07 fd sbrc r16, 7 + b2: 0e c0 rjmp .+28 ; 0xd0 <__do_clear_bss> + b4: 97 91 elpm r25, Z+ + b6: 87 91 elpm r24, Z+ + b8: ef 01 movw r28, r30 + ba: f9 2f mov r31, r25 + bc: e8 2f mov r30, r24 + be: 0b bf out 0x3b, r16 ; 59 + c0: 07 90 elpm r0, Z+ + c2: 0d 92 st X+, r0 + c4: a2 17 cp r26, r18 + c6: b3 07 cpc r27, r19 + c8: d9 f7 brne .-10 ; 0xc0 <__do_copy_data+0x22> + ca: fe 01 movw r30, r28 + cc: 1b be out 0x3b, r1 ; 59 + ce: 04 c0 rjmp .+8 ; 0xd8 <__do_clear_bss+0x8> + +000000d0 <__do_clear_bss>: + d0: 1d 92 st X+, r1 + d2: a2 17 cp r26, r18 + d4: b3 07 cpc r27, r19 + d6: e1 f7 brne .-8 ; 0xd0 <__do_clear_bss> + d8: e1 39 cpi r30, 0x91 ; 145 + da: f4 07 cpc r31, r20 + dc: 21 f7 brne .-56 ; 0xa6 <__do_copy_data+0x8> + de: 0e 94 fd 00 call 0x1fa ; 0x1fa
+ e2: 0c 94 73 00 jmp 0xe6 ; 0xe6 <_exit> + +000000e6 <_exit>: + e6: f8 94 cli + +000000e8 <__stop_program>: + e8: ff cf rjmp .-2 ; 0xe8 <__stop_program> + +Disassembly of section .text: + +000002fe <__bad_interrupt>: + 2fe: 0c 94 00 00 jmp 0 ; 0x0 <__TEXT_REGION_ORIGIN__> + +Disassembly of section .text.__vector_1: + +000000fa <__vector_1>: + fa: 1f 92 push r1 + fc: 0f 92 push r0 + fe: 00 90 5f 00 lds r0, 0x005F ; 0x80005f <__TEXT_REGION_LENGTH__+0x7e005f> + 102: 0f 92 push r0 + 104: 11 24 eor r1, r1 + 106: 00 90 5b 00 lds r0, 0x005B ; 0x80005b <__TEXT_REGION_LENGTH__+0x7e005b> + 10a: 0f 92 push r0 + 10c: 2f 93 push r18 + 10e: 3f 93 push r19 + 110: 4f 93 push r20 + 112: 5f 93 push r21 + 114: 6f 93 push r22 + 116: 7f 93 push r23 + 118: 8f 93 push r24 + 11a: 9f 93 push r25 + 11c: af 93 push r26 + 11e: bf 93 push r27 + 120: ef 93 push r30 + 122: ff 93 push r31 + 124: cf 93 push r28 + 126: df 93 push r29 + 128: cd b7 in r28, 0x3d ; 61 + 12a: de b7 in r29, 0x3e ; 62 + 12c: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <__DATA_REGION_ORIGIN__> + 130: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 134: 01 96 adiw r24, 0x01 ; 1 + 136: 90 93 01 01 sts 0x0101, r25 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 13a: 80 93 00 01 sts 0x0100, r24 ; 0x800100 <__DATA_REGION_ORIGIN__> + 13e: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <__DATA_REGION_ORIGIN__> + 142: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 146: 0e 94 3a 01 call 0x274 ; 0x274 + 14a: 00 00 nop + 14c: df 91 pop r29 + 14e: cf 91 pop r28 + 150: ff 91 pop r31 + 152: ef 91 pop r30 + 154: bf 91 pop r27 + 156: af 91 pop r26 + 158: 9f 91 pop r25 + 15a: 8f 91 pop r24 + 15c: 7f 91 pop r23 + 15e: 6f 91 pop r22 + 160: 5f 91 pop r21 + 162: 4f 91 pop r20 + 164: 3f 91 pop r19 + 166: 2f 91 pop r18 + 168: 0f 90 pop r0 + 16a: 00 92 5b 00 sts 0x005B, r0 ; 0x80005b <__TEXT_REGION_LENGTH__+0x7e005b> + 16e: 0f 90 pop r0 + 170: 00 92 5f 00 sts 0x005F, r0 ; 0x80005f <__TEXT_REGION_LENGTH__+0x7e005f> + 174: 0f 90 pop r0 + 176: 1f 90 pop r1 + 178: 18 95 reti + +Disassembly of section .text.__vector_2: + +0000017a <__vector_2>: + 17a: 1f 92 push r1 + 17c: 0f 92 push r0 + 17e: 00 90 5f 00 lds r0, 0x005F ; 0x80005f <__TEXT_REGION_LENGTH__+0x7e005f> + 182: 0f 92 push r0 + 184: 11 24 eor r1, r1 + 186: 00 90 5b 00 lds r0, 0x005B ; 0x80005b <__TEXT_REGION_LENGTH__+0x7e005b> + 18a: 0f 92 push r0 + 18c: 2f 93 push r18 + 18e: 3f 93 push r19 + 190: 4f 93 push r20 + 192: 5f 93 push r21 + 194: 6f 93 push r22 + 196: 7f 93 push r23 + 198: 8f 93 push r24 + 19a: 9f 93 push r25 + 19c: af 93 push r26 + 19e: bf 93 push r27 + 1a0: ef 93 push r30 + 1a2: ff 93 push r31 + 1a4: cf 93 push r28 + 1a6: df 93 push r29 + 1a8: cd b7 in r28, 0x3d ; 61 + 1aa: de b7 in r29, 0x3e ; 62 + 1ac: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <__DATA_REGION_ORIGIN__> + 1b0: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 1b4: 01 97 sbiw r24, 0x01 ; 1 + 1b6: 90 93 01 01 sts 0x0101, r25 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 1ba: 80 93 00 01 sts 0x0100, r24 ; 0x800100 <__DATA_REGION_ORIGIN__> + 1be: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <__DATA_REGION_ORIGIN__> + 1c2: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 1c6: 0e 94 3a 01 call 0x274 ; 0x274 + 1ca: 00 00 nop + 1cc: df 91 pop r29 + 1ce: cf 91 pop r28 + 1d0: ff 91 pop r31 + 1d2: ef 91 pop r30 + 1d4: bf 91 pop r27 + 1d6: af 91 pop r26 + 1d8: 9f 91 pop r25 + 1da: 8f 91 pop r24 + 1dc: 7f 91 pop r23 + 1de: 6f 91 pop r22 + 1e0: 5f 91 pop r21 + 1e2: 4f 91 pop r20 + 1e4: 3f 91 pop r19 + 1e6: 2f 91 pop r18 + 1e8: 0f 90 pop r0 + 1ea: 00 92 5b 00 sts 0x005B, r0 ; 0x80005b <__TEXT_REGION_LENGTH__+0x7e005b> + 1ee: 0f 90 pop r0 + 1f0: 00 92 5f 00 sts 0x005F, r0 ; 0x80005f <__TEXT_REGION_LENGTH__+0x7e005f> + 1f4: 0f 90 pop r0 + 1f6: 1f 90 pop r1 + 1f8: 18 95 reti + +Disassembly of section .text.initDisplay: + +000002d6 : + 2d6: cf 93 push r28 + 2d8: df 93 push r29 + 2da: cd b7 in r28, 0x3d ; 61 + 2dc: de b7 in r29, 0x3e ; 62 + 2de: 8a e3 ldi r24, 0x3A ; 58 + 2e0: 90 e0 ldi r25, 0x00 ; 0 + 2e2: 2f ef ldi r18, 0xFF ; 255 + 2e4: fc 01 movw r30, r24 + 2e6: 20 83 st Z, r18 + 2e8: 00 00 nop + 2ea: df 91 pop r29 + 2ec: cf 91 pop r28 + 2ee: 08 95 ret + +Disassembly of section .text.setDisplay: + +00000274 : + 274: 0f 93 push r16 + 276: 1f 93 push r17 + 278: cf 93 push r28 + 27a: df 93 push r29 + 27c: 00 d0 rcall .+0 ; 0x27e + 27e: cd b7 in r28, 0x3d ; 61 + 280: de b7 in r29, 0x3e ; 62 + 282: 9a 83 std Y+2, r25 ; 0x02 + 284: 89 83 std Y+1, r24 ; 0x01 + 286: 89 81 ldd r24, Y+1 ; 0x01 + 288: 9a 81 ldd r25, Y+2 ; 0x02 + 28a: 40 97 sbiw r24, 0x10 ; 16 + 28c: 24 f4 brge .+8 ; 0x296 + 28e: 89 81 ldd r24, Y+1 ; 0x01 + 290: 9a 81 ldd r25, Y+2 ; 0x02 + 292: 99 23 and r25, r25 + 294: 24 f4 brge .+8 ; 0x29e + 296: 8e e0 ldi r24, 0x0E ; 14 + 298: 90 e0 ldi r25, 0x00 ; 0 + 29a: 9a 83 std Y+2, r25 ; 0x02 + 29c: 89 83 std Y+1, r24 ; 0x01 + 29e: 0b e3 ldi r16, 0x3B ; 59 + 2a0: 10 e0 ldi r17, 0x00 ; 0 + 2a2: 2a ee ldi r18, 0xEA ; 234 + 2a4: 30 e0 ldi r19, 0x00 ; 0 + 2a6: 40 e0 ldi r20, 0x00 ; 0 + 2a8: 89 81 ldd r24, Y+1 ; 0x01 + 2aa: 9a 81 ldd r25, Y+2 ; 0x02 + 2ac: 09 2e mov r0, r25 + 2ae: 00 0c add r0, r0 + 2b0: aa 0b sbc r26, r26 + 2b2: 82 0f add r24, r18 + 2b4: 93 1f adc r25, r19 + 2b6: a4 1f adc r26, r20 + 2b8: fc 01 movw r30, r24 + 2ba: 5a 2f mov r21, r26 + 2bc: 0e 94 78 01 call 0x2f0 ; 0x2f0 <__xload_1> + 2c0: 86 2f mov r24, r22 + 2c2: f8 01 movw r30, r16 + 2c4: 80 83 st Z, r24 + 2c6: 00 00 nop + 2c8: 0f 90 pop r0 + 2ca: 0f 90 pop r0 + 2cc: df 91 pop r29 + 2ce: cf 91 pop r28 + 2d0: 1f 91 pop r17 + 2d2: 0f 91 pop r16 + 2d4: 08 95 ret + +Disassembly of section .text.main: + +000001fa
: + 1fa: cf 93 push r28 + 1fc: df 93 push r29 + 1fe: cd b7 in r28, 0x3d ; 61 + 200: de b7 in r29, 0x3e ; 62 + 202: 0e 94 6b 01 call 0x2d6 ; 0x2d6 + 206: 80 e0 ldi r24, 0x00 ; 0 + 208: 90 e0 ldi r25, 0x00 ; 0 + 20a: 0e 94 3a 01 call 0x274 ; 0x274 + 20e: 81 e3 ldi r24, 0x31 ; 49 + 210: 90 e0 ldi r25, 0x00 ; 0 + 212: fc 01 movw r30, r24 + 214: 10 82 st Z, r1 + 216: 8a e6 ldi r24, 0x6A ; 106 + 218: 90 e0 ldi r25, 0x00 ; 0 + 21a: 2a e6 ldi r18, 0x6A ; 106 + 21c: 30 e0 ldi r19, 0x00 ; 0 + 21e: f9 01 movw r30, r18 + 220: 20 81 ld r18, Z + 222: 2a 60 ori r18, 0x0A ; 10 + 224: fc 01 movw r30, r24 + 226: 20 83 st Z, r18 + 228: 89 e5 ldi r24, 0x59 ; 89 + 22a: 90 e0 ldi r25, 0x00 ; 0 + 22c: 29 e5 ldi r18, 0x59 ; 89 + 22e: 30 e0 ldi r19, 0x00 ; 0 + 230: f9 01 movw r30, r18 + 232: 20 81 ld r18, Z + 234: 23 60 ori r18, 0x03 ; 3 + 236: fc 01 movw r30, r24 + 238: 20 83 st Z, r18 + 23a: 85 e3 ldi r24, 0x35 ; 53 + 23c: 90 e0 ldi r25, 0x00 ; 0 + 23e: 21 e0 ldi r18, 0x01 ; 1 + 240: fc 01 movw r30, r24 + 242: 20 83 st Z, r18 + 244: 78 94 sei + 246: 80 e3 ldi r24, 0x30 ; 48 + 248: 90 e0 ldi r25, 0x00 ; 0 + 24a: fc 01 movw r30, r24 + 24c: 80 81 ld r24, Z + 24e: 83 30 cpi r24, 0x03 ; 3 + 250: d1 f7 brne .-12 ; 0x246 + 252: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <__DATA_REGION_ORIGIN__> + 256: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 25a: 89 2b or r24, r25 + 25c: a1 f3 breq .-24 ; 0x246 + 25e: 10 92 01 01 sts 0x0101, r1 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 262: 10 92 00 01 sts 0x0100, r1 ; 0x800100 <__DATA_REGION_ORIGIN__> + 266: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <__DATA_REGION_ORIGIN__> + 26a: 90 91 01 01 lds r25, 0x0101 ; 0x800101 <__DATA_REGION_ORIGIN__+0x1> + 26e: 0e 94 3a 01 call 0x274 ; 0x274 + 272: e9 cf rjmp .-46 ; 0x246 + +Disassembly of section .text.libgcc: + +000002f0 <__xload_1>: + 2f0: 57 fd sbrc r21, 7 + 2f2: 03 c0 rjmp .+6 ; 0x2fa <__xload_1+0xa> + 2f4: 5b bf out 0x3b, r21 ; 59 + 2f6: 67 91 elpm r22, Z+ + 2f8: 08 95 ret + 2fa: 60 81 ld r22, Z + 2fc: 08 95 ret diff --git a/Microcontrollers/opdracht 2.3/main.c b/Microcontrollers/opdracht 2.3/main.c index 5bfbf00..9c93a1b 100644 --- a/Microcontrollers/opdracht 2.3/main.c +++ b/Microcontrollers/opdracht 2.3/main.c @@ -4,7 +4,7 @@ * Created: 2/10/2021 11:45:42 AM * Author: Sem */ - +#include #include #include #include @@ -15,24 +15,78 @@ void wait( int ms ) { } } -const unsigned char Numbers [10] = { - // dPgfe dcba - 0b 0011 1111, // 0 - 0b 0000 0110, // 1 - 0b 0101 1011, // 2 - 0b 0100 1111, // 3 - 0b 0110 0110, // 4 - 0b 0110 1101, // 5 - 0b 0111 1101, // 6 - 0b 0000 0111, // 7 - 0b 0111 1111, // 8 - 0b 0110 1111, // 9 +int count; +/************************************************************************/ +/* interrupt 1 +walk the light 1 down */ +/************************************************************************/ +ISR( INT0_vect ) { + + setDisplay(++count); +} + +/************************************************************************/ +/* interrupt 2 +walk the light 1 up */ +/************************************************************************/ +ISR( INT1_vect ) { + + setDisplay(--count); +} + +const unsigned char Characters [15] = { + 0b00111111, // 0 + 0b00000110, // 1 + 0b01011011, // 2 + 0b01001111, // 3 + 0b01100110, // 4 + 0b01101101, // 5 + 0b01111101, // 6 + 0b00000111, // 7 + 0b01111111, // 8 + 0b01101111, // 9 + 0b01110111, // A + 0b01111100, // B + 0b00111001, // C + 0b01011110, // D + 0b01111001, // E + 0b01110001, // F }; +void initDisplay(){ + DDRA = 0b11111111; +} + +void setDisplay(int num){ + if(num > 15 || num < 0) + num = 14; + + PORTA = Characters[num]; +} + int main(void) { + initDisplay(); + setDisplay(0); + + /* Replace with your application code */ + + // Init I/O + DDRD = 0b00000000; + + // Init Interrupt hardware + EICRA |= 0b00001010; // INT2 falling edge, INT1 rising edge + EIMSK |= 0b00000011; // Enable INT1 & INT0 + + PORTC = 0x01; // init the first bit + + sei(); // enable input mechanism + while(1) { - //TODO:: Please write your application code + if((PIND == 0b00000011) && (count != 0)){ + count = 0; + setDisplay(count); + } } -} \ No newline at end of file +} diff --git a/Microcontrollers/opdracht 2.3/opdracht 2.3.cproj b/Microcontrollers/opdracht 2.3/opdracht 2.3.cproj index fb30d94..947eaff 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 - 2285C48D-296E-43FD-A7B6-69885F64CFFD + {9154c165-89ab-43cf-8c28-23147bc26fdc} ATmega128 none Executable @@ -15,6 +15,31 @@ opdracht 2.3 opdracht 2.3 opdracht 2.3 + XC8_2.31 + true + false + true + true + + + true + + 2 + 0 + 0 + + + + + + + + + + + + +