diff --git a/Microcontrollers/opdracht 2.4/Debug/Makefile b/Microcontrollers/opdracht 2.4/Debug/Makefile new file mode 100644 index 0000000..fcf2cfb --- /dev/null +++ b/Microcontrollers/opdracht 2.4/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.4.elf + +OUTPUT_FILE_PATH_AS_ARGS +="opdracht 2.4.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 -funsigned-char -funsigned-bitfields -mext=cci -D__ATmega128__ -DDEBUG -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -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.4.map" -funsigned-char -funsigned-bitfields -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums --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.4.elf" "opdracht 2.4.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.4.elf" "opdracht 2.4.eep" || exit 0 + "C:\Program Files\Microchip\xc8\v2.31\bin\avr-objdump.exe" -h -S "opdracht 2.4.elf" > "opdracht 2.4.lss" + + + + + + + +# Other Targets +clean: + -$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES) + -$(RM) $(C_DEPS_AS_ARGS) + rm -rf "opdracht 2.4.elf" "opdracht 2.4.hex" "opdracht 2.4.eep" "opdracht 2.4.map" "opdracht 2.4.usersignatures" "opdracht 2.4.a" "opdracht 2.4.lss" + \ No newline at end of file diff --git a/Microcontrollers/opdracht 2.4/Debug/makedep.mk b/Microcontrollers/opdracht 2.4/Debug/makedep.mk new file mode 100644 index 0000000..6a14fde --- /dev/null +++ b/Microcontrollers/opdracht 2.4/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.4/Debug/memoryfile.xml b/Microcontrollers/opdracht 2.4/Debug/memoryfile.xml new file mode 100644 index 0000000..779875d --- /dev/null +++ b/Microcontrollers/opdracht 2.4/Debug/memoryfile.xml @@ -0,0 +1,17 @@ + + + + + bytes + 131072 + 468 + 130604 + + + bytes + 4096 + 144 + 3952 + + + diff --git a/Microcontrollers/opdracht 2.4/Debug/opdracht 2.4.eep b/Microcontrollers/opdracht 2.4/Debug/opdracht 2.4.eep new file mode 100644 index 0000000..7c166a1 --- /dev/null +++ b/Microcontrollers/opdracht 2.4/Debug/opdracht 2.4.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/Microcontrollers/opdracht 2.4/Debug/opdracht 2.4.lss b/Microcontrollers/opdracht 2.4/Debug/opdracht 2.4.lss new file mode 100644 index 0000000..05f745d --- /dev/null +++ b/Microcontrollers/opdracht 2.4/Debug/opdracht 2.4.lss @@ -0,0 +1,235 @@ + +opdracht 2.4.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .data 00000000 00800100 000001d4 00000248 2**0 + ALLOC, LOAD, DATA + 1 .text 000000ec 00000000 00000000 00000074 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 2 .comment 0000002f 00000000 00000000 00000248 2**0 + CONTENTS, READONLY + 3 .debug_aranges 00000028 00000000 00000000 00000277 2**0 + CONTENTS, READONLY, DEBUGGING + 4 .debug_info 00000b85 00000000 00000000 0000029f 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_abbrev 00000854 00000000 00000000 00000e24 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_line 000002b1 00000000 00000000 00001678 2**0 + CONTENTS, READONLY, DEBUGGING + 7 .debug_frame 00000034 00000000 00000000 0000192c 2**2 + CONTENTS, READONLY, DEBUGGING + 8 .debug_str 0000027d 00000000 00000000 00001960 2**0 + CONTENTS, READONLY, DEBUGGING + 9 .debug_loc 000000b2 00000000 00000000 00001bdd 2**0 + CONTENTS, READONLY, DEBUGGING + 10 .debug_ranges 00000030 00000000 00000000 00001c8f 2**0 + CONTENTS, READONLY, DEBUGGING + 11 .text 00000004 00000140 00000140 000001b4 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 12 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 00001cc0 2**2 + CONTENTS, READONLY, DEBUGGING + 13 .text.wait 0000001e 00000122 00000122 00000196 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 14 .text.main 00000036 000000ec 000000ec 00000160 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 15 .data.segments 00000090 00800100 00000144 000001b8 2**0 + CONTENTS, ALLOC, LOAD, DATA + +Disassembly of section .text: + +00000000 <__vectors>: + 0: 0c 94 4a 00 jmp 0x94 ; 0x94 <__ctors_end> + 4: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 8: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + c: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 10: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 14: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 18: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 1c: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 20: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 24: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 28: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 2c: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 30: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 34: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 38: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 3c: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 40: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 44: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 48: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 4c: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 50: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 54: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 58: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 5c: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 60: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 64: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 68: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 6c: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 70: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 74: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 78: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 7c: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 80: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 84: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + 88: 0c 94 a0 00 jmp 0x140 ; 0x140 <__bad_interrupt> + +0000008c <.dinit>: + 8c: 01 00 .word 0x0001 ; ???? + 8e: 01 90 ld r0, Z+ + 90: 00 01 movw r0, r0 + 92: 44 00 .word 0x0044 ; ???? + +00000094 <__ctors_end>: + 94: 11 24 eor r1, r1 + 96: 1f be out 0x3f, r1 ; 63 + 98: cf ef ldi r28, 0xFF ; 255 + 9a: d0 e1 ldi r29, 0x10 ; 16 + 9c: de bf out 0x3e, r29 ; 62 + 9e: cd bf out 0x3d, r28 ; 61 + +000000a0 <__do_copy_data>: + a0: ec e8 ldi r30, 0x8C ; 140 + a2: f0 e0 ldi r31, 0x00 ; 0 + a4: 40 e0 ldi r20, 0x00 ; 0 + a6: 19 c0 rjmp .+50 ; 0xda <__do_clear_bss+0x8> + a8: b7 91 elpm r27, Z+ + aa: a7 91 elpm r26, Z+ + ac: 37 91 elpm r19, Z+ + ae: 27 91 elpm r18, Z+ + b0: 07 91 elpm r16, Z+ + b2: 07 fd sbrc r16, 7 + b4: 0e c0 rjmp .+28 ; 0xd2 <__do_clear_bss> + b6: 97 91 elpm r25, Z+ + b8: 87 91 elpm r24, Z+ + ba: ef 01 movw r28, r30 + bc: f9 2f mov r31, r25 + be: e8 2f mov r30, r24 + c0: 0b bf out 0x3b, r16 ; 59 + c2: 07 90 elpm r0, Z+ + c4: 0d 92 st X+, r0 + c6: a2 17 cp r26, r18 + c8: b3 07 cpc r27, r19 + ca: d9 f7 brne .-10 ; 0xc2 <__do_copy_data+0x22> + cc: fe 01 movw r30, r28 + ce: 1b be out 0x3b, r1 ; 59 + d0: 04 c0 rjmp .+8 ; 0xda <__do_clear_bss+0x8> + +000000d2 <__do_clear_bss>: + d2: 1d 92 st X+, r1 + d4: a2 17 cp r26, r18 + d6: b3 07 cpc r27, r19 + d8: e1 f7 brne .-8 ; 0xd2 <__do_clear_bss> + da: e3 39 cpi r30, 0x93 ; 147 + dc: f4 07 cpc r31, r20 + de: 21 f7 brne .-56 ; 0xa8 <__do_copy_data+0x8> + e0: 0e 94 76 00 call 0xec ; 0xec <_etext> + e4: 0c 94 74 00 jmp 0xe8 ; 0xe8 <_exit> + +000000e8 <_exit>: + e8: f8 94 cli + +000000ea <__stop_program>: + ea: ff cf rjmp .-2 ; 0xea <__stop_program> + +Disassembly of section .text: + +00000140 <__bad_interrupt>: + 140: 0c 94 00 00 jmp 0 ; 0x0 <__TEXT_REGION_ORIGIN__> + +Disassembly of section .text.wait: + +00000122 : +waits a specific amount of miliseconds */ +/************************************************************************/ +void wait( int ms ) + +{ + for (int i=0; i + #else + //round up by default + __ticks_dc = (uint32_t)(ceil(fabs(__tmp))); + #endif + + __builtin_avr_delay_cycles(__ticks_dc); + 128: e3 ec ldi r30, 0xC3 ; 195 + 12a: f9 e0 ldi r31, 0x09 ; 9 + 12c: 31 97 sbiw r30, 0x01 ; 1 + 12e: f1 f7 brne .-4 ; 0x12c + 130: 00 c0 rjmp .+0 ; 0x132 + 132: 00 00 nop + 134: 2f 5f subi r18, 0xFF ; 255 + 136: 3f 4f sbci r19, 0xFF ; 255 + 138: 28 17 cp r18, r24 + 13a: 39 07 cpc r19, r25 + 13c: ac f3 brlt .-22 ; 0x128 + { + _delay_ms( 1 ); // library function (max 30 ms at 8MHz) + } +} + 13e: 08 95 ret + +Disassembly of section .text.main: + +000000ec
: + +int main( void ) +{ + DDRA = 0xFF; + ec: 8f ef ldi r24, 0xFF ; 255 + ee: 8a bb out 0x1a, r24 ; 26 + while (1==1) + { + // Set index to begin of pattern array + int index = 0; + // as long as delay has meaningful content + for (int i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) + f0: 00 e0 ldi r16, 0x00 ; 0 + f2: 10 e0 ldi r17, 0x00 ; 0 + + + while (1==1) + { + // Set index to begin of pattern array + int index = 0; + f4: c0 e0 ldi r28, 0x00 ; 0 + f6: d0 e0 ldi r29, 0x00 ; 0 + // as long as delay has meaningful content + for (int i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) + f8: 10 c0 rjmp .+32 ; 0x11a + { + // Write data to PORTA + PORTA = segments[index].data; + fa: fe 01 movw r30, r28 + fc: ee 0f add r30, r30 + fe: ff 1f adc r31, r31 + 100: ec 0f add r30, r28 + 102: fd 1f adc r31, r29 + 104: e0 50 subi r30, 0x00 ; 0 + 106: ff 4f sbci r31, 0xFF ; 255 + 108: 80 81 ld r24, Z + 10a: 8b bb out 0x1b, r24 ; 27 + // wait + wait(segments[index].delay); + 10c: 81 81 ldd r24, Z+1 ; 0x01 + 10e: 92 81 ldd r25, Z+2 ; 0x02 + 110: 0e 94 91 00 call 0x122 ; 0x122 + // increment for next round + index++; + 114: 21 96 adiw r28, 0x01 ; 1 + while (1==1) + { + // Set index to begin of pattern array + int index = 0; + // as long as delay has meaningful content + for (int i = 0; i < sizeof(segments)/sizeof(segments[0]); i++) + 116: 0f 5f subi r16, 0xFF ; 255 + 118: 1f 4f sbci r17, 0xFF ; 255 + 11a: 00 33 cpi r16, 0x30 ; 48 + 11c: 11 05 cpc r17, r1 + 11e: 68 f3 brcs .-38 ; 0xfa + 120: e7 cf rjmp .-50 ; 0xf0 diff --git a/Microcontrollers/opdracht 2.4/main.c b/Microcontrollers/opdracht 2.4/main.c new file mode 100644 index 0000000..f77fa31 --- /dev/null +++ b/Microcontrollers/opdracht 2.4/main.c @@ -0,0 +1,79 @@ +/* --------------------------------------------------------------------------- +** This software is in the public domain, furnished "as is", without technical +** support, and with no warranty, express or implied, as to its usefulness for +** any purpose. +** +** lookup.c +** +** Beschrijving: Ledpatroon op PORTD dmv table lookup (scheiding logica en data) +** Target: AVR mcu +** Build: avr-gcc -std=c99 -Wall -O3 -mmcu=atmega128 -D F_CPU=8000000UL -c switch.c +** avr-gcc -g -mmcu=atmega128 -o lookup.elf lookup.o +** avr-objcopy -O ihex lookup.elf lookup.hex +** or type 'make' +** Author: dkroeske@gmail.com +** -------------------------------------------------------------------------*/ + +#define F_CPU 10e6 +#include +#include +#include + +typedef struct { + unsigned char data; + unsigned int delay; + } SEGMENT_DELAY; + +SEGMENT_DELAY segments[] = { + /* go around the outer layer twice */ + // 0 a b c d e f + {0x00,100},{0x01,100},{0x02,100},{0x04,100},{0x08,100},{0x10,100},{0x20,100},{0x01,100},{0x02,100},{0x04,100},{0x08,100},{0x10,100},{0x20,100}, + /* then fill it starting at a */ + {0x01,100},{0x03,100},{0x07,100},{0x0F,100},{0x1F,100},{0x3F,100},{0b00111110,100},{0b00111100,100},{0b00111000,100},{0b00110000,100},{0b00100000,100}, + /* blink the 3 horizontal bars 2 times from top to bottom*/ + {0x01,50},{0x00,50},{0x01,50},{0x00,50},{0x01,50},{0x00,50},{0x01,50},{0x00,50}, + {0b01000000,50},{0x00,50},{0b01000000,50},{0x00,50},{0b01000000,50},{0x00,50},{0b01000000,50},{0x00,50}, + {0x08,50},{0x00,50},{0x08,50},{0x00,50},{0x08,50},{0x00,50},{0x08,50},{0x00,50} + /* go in a figure 8 pattern pattern*/ + +}; + + +/************************************************************************/ +/* wait method +waits a specific amount of miliseconds */ +/************************************************************************/ +void wait( int ms ) + +{ + for (int i=0; i + + + + + + 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\xc8\avr\include\avr\iom128.h + + header + XC + JdJ7J9I/SJh965SEyyyVYw== + + xc8/avr/include/avr/iom128.h + + + + + 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 2.4/opdracht 2.4.cproj b/Microcontrollers/opdracht 2.4/opdracht 2.4.cproj new file mode 100644 index 0000000..f7f985b --- /dev/null +++ b/Microcontrollers/opdracht 2.4/opdracht 2.4.cproj @@ -0,0 +1,87 @@ + + + + 2.0 + 7.0 + com.microchip.xc8 + {0fa0c637-5ac0-44f3-999b-49c114b97183} + ATmega128 + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + opdracht 2.4 + opdracht 2.4 + opdracht 2.4 + XC8_2.31 + true + false + true + true + + + true + + 2 + 0 + 0 + + + + + + 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) + + + + + + compile + + + + \ No newline at end of file