[add] 4.1 not done yet

This commit is contained in:
stijn
2021-03-03 11:26:28 +01:00
parent 06e9ab9260
commit 5ca12382c4
10 changed files with 1136 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
################################################################################
# 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 += \
../lcd_control.c \
../main.c
PREPROCESSING_SRCS +=
ASM_SRCS +=
OBJS += \
lcd_control.o \
main.o
OBJS_AS_ARGS += \
lcd_control.o \
main.o
C_DEPS += \
lcd_control.d \
main.d
C_DEPS_AS_ARGS += \
lcd_control.d \
main.d
OUTPUT_FILE_PATH +=opdracht\ 4.1.elf
OUTPUT_FILE_PATH_AS_ARGS +="opdracht 4.1.elf"
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:= ./makedep.mk
LIB_DEP+=
LINKER_SCRIPT_DEP+=
# AVR32/GNU C Compiler
./lcd_control.o: .././lcd_control.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: $<
./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 4.1.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 4.1.elf" "opdracht 4.1.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 4.1.elf" "opdracht 4.1.eep" || exit 0
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "opdracht 4.1.elf" > "opdracht 4.1.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 4.1.elf" "opdracht 4.1.srec"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "opdracht 4.1.elf"
# Other Targets
clean:
-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)
-$(RM) $(C_DEPS_AS_ARGS)
rm -rf "opdracht 4.1.elf" "opdracht 4.1.a" "opdracht 4.1.hex" "opdracht 4.1.lss" "opdracht 4.1.eep" "opdracht 4.1.map" "opdracht 4.1.srec" "opdracht 4.1.usersignatures"

View File

@@ -0,0 +1,8 @@
################################################################################
# Automatically-generated file. Do not edit or delete the file
################################################################################
lcd_control.c
main.c

View File

@@ -0,0 +1 @@
:00000001FF

View File

@@ -0,0 +1,505 @@
opdracht 4.1.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 0000000c 00800100 00000232 000002a6 2**0
CONTENTS, ALLOC, LOAD, DATA
1 .text 00000232 00000000 00000000 00000074 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .comment 00000030 00000000 00000000 000002b2 2**0
CONTENTS, READONLY
3 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 000002e4 2**2
CONTENTS, READONLY
4 .debug_aranges 000000b8 00000000 00000000 00000320 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_info 00000e60 00000000 00000000 000003d8 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_abbrev 00000a5b 00000000 00000000 00001238 2**0
CONTENTS, READONLY, DEBUGGING
7 .debug_line 00000693 00000000 00000000 00001c93 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_frame 00000168 00000000 00000000 00002328 2**2
CONTENTS, READONLY, DEBUGGING
9 .debug_str 0000052a 00000000 00000000 00002490 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_loc 000002c7 00000000 00000000 000029ba 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_ranges 00000098 00000000 00000000 00002c81 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00000000 <__vectors>:
0: 45 c0 rjmp .+138 ; 0x8c <__ctors_end>
2: 00 00 nop
4: 58 c0 rjmp .+176 ; 0xb6 <__bad_interrupt>
6: 00 00 nop
8: 56 c0 rjmp .+172 ; 0xb6 <__bad_interrupt>
a: 00 00 nop
c: 54 c0 rjmp .+168 ; 0xb6 <__bad_interrupt>
e: 00 00 nop
10: 52 c0 rjmp .+164 ; 0xb6 <__bad_interrupt>
12: 00 00 nop
14: 50 c0 rjmp .+160 ; 0xb6 <__bad_interrupt>
16: 00 00 nop
18: 4e c0 rjmp .+156 ; 0xb6 <__bad_interrupt>
1a: 00 00 nop
1c: 4c c0 rjmp .+152 ; 0xb6 <__bad_interrupt>
1e: 00 00 nop
20: 4a c0 rjmp .+148 ; 0xb6 <__bad_interrupt>
22: 00 00 nop
24: df c0 rjmp .+446 ; 0x1e4 <__vector_9>
26: 00 00 nop
28: 46 c0 rjmp .+140 ; 0xb6 <__bad_interrupt>
2a: 00 00 nop
2c: 44 c0 rjmp .+136 ; 0xb6 <__bad_interrupt>
2e: 00 00 nop
30: 42 c0 rjmp .+132 ; 0xb6 <__bad_interrupt>
32: 00 00 nop
34: 40 c0 rjmp .+128 ; 0xb6 <__bad_interrupt>
36: 00 00 nop
38: 3e c0 rjmp .+124 ; 0xb6 <__bad_interrupt>
3a: 00 00 nop
3c: 3c c0 rjmp .+120 ; 0xb6 <__bad_interrupt>
3e: 00 00 nop
40: 3a c0 rjmp .+116 ; 0xb6 <__bad_interrupt>
42: 00 00 nop
44: 38 c0 rjmp .+112 ; 0xb6 <__bad_interrupt>
46: 00 00 nop
48: 36 c0 rjmp .+108 ; 0xb6 <__bad_interrupt>
4a: 00 00 nop
4c: 34 c0 rjmp .+104 ; 0xb6 <__bad_interrupt>
4e: 00 00 nop
50: 32 c0 rjmp .+100 ; 0xb6 <__bad_interrupt>
52: 00 00 nop
54: 30 c0 rjmp .+96 ; 0xb6 <__bad_interrupt>
56: 00 00 nop
58: 2e c0 rjmp .+92 ; 0xb6 <__bad_interrupt>
5a: 00 00 nop
5c: 2c c0 rjmp .+88 ; 0xb6 <__bad_interrupt>
5e: 00 00 nop
60: 2a c0 rjmp .+84 ; 0xb6 <__bad_interrupt>
62: 00 00 nop
64: 28 c0 rjmp .+80 ; 0xb6 <__bad_interrupt>
66: 00 00 nop
68: 26 c0 rjmp .+76 ; 0xb6 <__bad_interrupt>
6a: 00 00 nop
6c: 24 c0 rjmp .+72 ; 0xb6 <__bad_interrupt>
6e: 00 00 nop
70: 22 c0 rjmp .+68 ; 0xb6 <__bad_interrupt>
72: 00 00 nop
74: 20 c0 rjmp .+64 ; 0xb6 <__bad_interrupt>
76: 00 00 nop
78: 1e c0 rjmp .+60 ; 0xb6 <__bad_interrupt>
7a: 00 00 nop
7c: 1c c0 rjmp .+56 ; 0xb6 <__bad_interrupt>
7e: 00 00 nop
80: 1a c0 rjmp .+52 ; 0xb6 <__bad_interrupt>
82: 00 00 nop
84: 18 c0 rjmp .+48 ; 0xb6 <__bad_interrupt>
86: 00 00 nop
88: 16 c0 rjmp .+44 ; 0xb6 <__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: e2 e3 ldi r30, 0x32 ; 50
a0: f2 e0 ldi r31, 0x02 ; 2
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: ac 30 cpi r26, 0x0C ; 12
ae: b1 07 cpc r27, r17
b0: d9 f7 brne .-10 ; 0xa8 <__do_copy_data+0x10>
b2: a2 d0 rcall .+324 ; 0x1f8 <main>
b4: bc c0 rjmp .+376 ; 0x22e <_exit>
000000b6 <__bad_interrupt>:
b6: a4 cf rjmp .-184 ; 0x0 <__vectors>
000000b8 <sbi_porta>:
void cbi_portc(int index){
PORTC &= ~(1<<index);
}
void sbi_porta(int index){
PORTA |= (1<<index);
b8: 9b b3 in r25, 0x1b ; 27
ba: 21 e0 ldi r18, 0x01 ; 1
bc: 30 e0 ldi r19, 0x00 ; 0
be: 02 c0 rjmp .+4 ; 0xc4 <sbi_porta+0xc>
c0: 22 0f add r18, r18
c2: 33 1f adc r19, r19
c4: 8a 95 dec r24
c6: e2 f7 brpl .-8 ; 0xc0 <sbi_porta+0x8>
c8: 29 2b or r18, r25
ca: 2b bb out 0x1b, r18 ; 27
cc: 08 95 ret
000000ce <cbi_porta>:
}
void cbi_porta(int index){
PORTA &= ~(1<<index);
ce: 9b b3 in r25, 0x1b ; 27
d0: 21 e0 ldi r18, 0x01 ; 1
d2: 30 e0 ldi r19, 0x00 ; 0
d4: 02 c0 rjmp .+4 ; 0xda <cbi_porta+0xc>
d6: 22 0f add r18, r18
d8: 33 1f adc r19, r19
da: 8a 95 dec r24
dc: e2 f7 brpl .-8 ; 0xd6 <cbi_porta+0x8>
de: 20 95 com r18
e0: 29 23 and r18, r25
e2: 2b bb out 0x1b, r18 ; 27
e4: 08 95 ret
000000e6 <lcd_strobe_lcd_e>:
lcd_write_command (0x80); //Cursor terug naar start
}
void lcd_strobe_lcd_e(void) {
sbi_porta(LCD_E); // E high
e6: 86 e0 ldi r24, 0x06 ; 6
e8: 90 e0 ldi r25, 0x00 ; 0
ea: e6 df rcall .-52 ; 0xb8 <sbi_porta>
#else
//round up by default
__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
#endif
__builtin_avr_delay_cycles(__ticks_dc);
ec: 89 ef ldi r24, 0xF9 ; 249
ee: 90 e0 ldi r25, 0x00 ; 0
f0: 01 97 sbiw r24, 0x01 ; 1
f2: f1 f7 brne .-4 ; 0xf0 <lcd_strobe_lcd_e+0xa>
f4: 00 c0 rjmp .+0 ; 0xf6 <lcd_strobe_lcd_e+0x10>
f6: 00 00 nop
_delay_ms(1);
cbi_porta(LCD_E); // E low
f8: 86 e0 ldi r24, 0x06 ; 6
fa: 90 e0 ldi r25, 0x00 ; 0
fc: e8 df rcall .-48 ; 0xce <cbi_porta>
fe: 89 ef ldi r24, 0xF9 ; 249
100: 90 e0 ldi r25, 0x00 ; 0
102: 01 97 sbiw r24, 0x01 ; 1
104: f1 f7 brne .-4 ; 0x102 <lcd_strobe_lcd_e+0x1c>
106: 00 c0 rjmp .+0 ; 0x108 <lcd_strobe_lcd_e+0x22>
108: 00 00 nop
10a: 08 95 ret
0000010c <lcd_write_character>:
// return home
lcd_write_command(0x02);
lcd_strobe_lcd_e();
}
void lcd_write_character(unsigned char byte){
10c: cf 93 push r28
10e: c8 2f mov r28, r24
//upper nibble
PORTC = byte;
110: 85 bb out 0x15, r24 ; 21
sbi_porta(LCD_RS);
112: 84 e0 ldi r24, 0x04 ; 4
114: 90 e0 ldi r25, 0x00 ; 0
116: d0 df rcall .-96 ; 0xb8 <sbi_porta>
lcd_strobe_lcd_e();
118: e6 df rcall .-52 ; 0xe6 <lcd_strobe_lcd_e>
11a: c2 95 swap r28
//lower nibble
PORTC = (byte<<4);
11c: c0 7f andi r28, 0xF0 ; 240
11e: c5 bb out 0x15, r28 ; 21
120: 84 e0 ldi r24, 0x04 ; 4
sbi_porta(LCD_RS);
122: 90 e0 ldi r25, 0x00 ; 0
124: c9 df rcall .-110 ; 0xb8 <sbi_porta>
lcd_strobe_lcd_e();
126: df df rcall .-66 ; 0xe6 <lcd_strobe_lcd_e>
128: cf 91 pop r28
}
12a: 08 95 ret
0000012c <lcd_write_command>:
12c: cf 93 push r28
void lcd_write_command(unsigned char byte){
12e: c8 2f mov r28, r24
//upper nibble
PORTC = byte;
130: 85 bb out 0x15, r24 ; 21
cbi_porta(LCD_RS);
132: 84 e0 ldi r24, 0x04 ; 4
134: 90 e0 ldi r25, 0x00 ; 0
136: cb df rcall .-106 ; 0xce <cbi_porta>
lcd_strobe_lcd_e();
138: d6 df rcall .-84 ; 0xe6 <lcd_strobe_lcd_e>
13a: c2 95 swap r28
//lower nibble
PORTC = (byte<<4);
13c: c0 7f andi r28, 0xF0 ; 240
13e: c5 bb out 0x15, r28 ; 21
140: 84 e0 ldi r24, 0x04 ; 4
cbi_porta(LCD_RS);
142: 90 e0 ldi r25, 0x00 ; 0
144: c4 df rcall .-120 ; 0xce <cbi_porta>
lcd_strobe_lcd_e();
146: cf df rcall .-98 ; 0xe6 <lcd_strobe_lcd_e>
148: cf 91 pop r28
}
14a: 08 95 ret
0000014c <lcd_clear>:
14c: 81 e0 ldi r24, 0x01 ; 1
#include "lcd_control.h"
void _delay_ms(double __ms);
void lcd_clear() {
lcd_write_command (0x01); //Leeg display
14e: ee df rcall .-36 ; 0x12c <lcd_write_command>
150: 83 ef ldi r24, 0xF3 ; 243
152: 91 e0 ldi r25, 0x01 ; 1
154: 01 97 sbiw r24, 0x01 ; 1
156: f1 f7 brne .-4 ; 0x154 <lcd_clear+0x8>
158: 00 c0 rjmp .+0 ; 0x15a <lcd_clear+0xe>
15a: 00 00 nop
_delay_ms(2);
lcd_write_command (0x80); //Cursor terug naar start
15c: 80 e8 ldi r24, 0x80 ; 128
15e: e6 cf rjmp .-52 ; 0x12c <lcd_write_command>
160: 08 95 ret
00000162 <init_4bits_mode>:
void cbi_porta(int index){
PORTA &= ~(1<<index);
}
void init_4bits_mode(void) {
162: cf 93 push r28
// PORTC output mode and all low (also E and RS pin)
// Init I/O
DDRC = 0xFF; // PORTD(7) output, PORTD(6:0) input
164: 8f ef ldi r24, 0xFF ; 255
166: 84 bb out 0x14, r24 ; 20
PORTC = 0xFF;
168: 85 bb out 0x15, r24 ; 21
DDRA = 0xFF;
16a: 8a bb out 0x1a, r24 ; 26
PORTC = 0x00;
16c: 15 ba out 0x15, r1 ; 21
PORTA = 0x00;
16e: 1b ba out 0x1b, r1 ; 27
PORTC = 0x20; // function for 4-bit 1 row
170: c0 e2 ldi r28, 0x20 ; 32
172: c5 bb out 0x15, r28 ; 21
lcd_strobe_lcd_e();
174: b8 df rcall .-144 ; 0xe6 <lcd_strobe_lcd_e>
PORTC = 0x20; // function high nibble 4-bit 2 row
lcd_strobe_lcd_e();
176: c5 bb out 0x15, r28 ; 21
178: b6 df rcall .-148 ; 0xe6 <lcd_strobe_lcd_e>
PORTC = 0x80; // function low nibble 4-bit 2 row
17a: 80 e8 ldi r24, 0x80 ; 128
lcd_strobe_lcd_e();
17c: 85 bb out 0x15, r24 ; 21
PORTC = 0x00; // function high nibble turn on visible blinking-block cursor
17e: b3 df rcall .-154 ; 0xe6 <lcd_strobe_lcd_e>
lcd_strobe_lcd_e();
180: 15 ba out 0x15, r1 ; 21
PORTC = 0xF0; // function low nibble turn on visible blinking-block cursor
182: b1 df rcall .-158 ; 0xe6 <lcd_strobe_lcd_e>
lcd_strobe_lcd_e();
184: 80 ef ldi r24, 0xF0 ; 240
PORTC = 0x00; // Entry mode set high nibble
186: 85 bb out 0x15, r24 ; 21
lcd_strobe_lcd_e();
188: ae df rcall .-164 ; 0xe6 <lcd_strobe_lcd_e>
PORTC = 0x60; // Entry mode set low nibble
18a: 15 ba out 0x15, r1 ; 21
18c: ac df rcall .-168 ; 0xe6 <lcd_strobe_lcd_e>
lcd_strobe_lcd_e();
18e: 80 e6 ldi r24, 0x60 ; 96
190: 85 bb out 0x15, r24 ; 21
// return home
lcd_write_command(0x02);
192: a9 df rcall .-174 ; 0xe6 <lcd_strobe_lcd_e>
194: 82 e0 ldi r24, 0x02 ; 2
196: ca df rcall .-108 ; 0x12c <lcd_write_command>
lcd_strobe_lcd_e();
198: a6 df rcall .-180 ; 0xe6 <lcd_strobe_lcd_e>
19a: cf 91 pop r28
}
19c: 08 95 ret
0000019e <lcd_write_string>:
19e: cf 93 push r28
cbi_porta(LCD_RS);
lcd_strobe_lcd_e();
}
void lcd_write_string(const char *str) {
1a0: df 93 push r29
1a2: ec 01 movw r28, r24
for(;*str; str++){
1a4: 02 c0 rjmp .+4 ; 0x1aa <lcd_write_string+0xc>
lcd_write_character(*str);
1a6: b2 df rcall .-156 ; 0x10c <lcd_write_character>
}
void lcd_write_string(const char *str) {
for(;*str; str++){
1a8: 21 96 adiw r28, 0x01 ; 1
1aa: 88 81 ld r24, Y
1ac: 81 11 cpse r24, r1
1ae: fb cf rjmp .-10 ; 0x1a6 <lcd_write_string+0x8>
lcd_write_character(*str);
}
}
1b0: df 91 pop r29
1b2: cf 91 pop r28
1b4: 08 95 ret
000001b6 <lcd_move_right>:
void lcd_move_right(void){
lcd_write_command(0x1E);
1b6: 8e e1 ldi r24, 0x1E ; 30
1b8: b9 cf rjmp .-142 ; 0x12c <lcd_write_command>
1ba: 08 95 ret
000001bc <wait>:
int value = 0;
value = ADCH;
value <<= 2;
value += ADCL;
return value;
}
1bc: 20 e0 ldi r18, 0x00 ; 0
1be: 30 e0 ldi r19, 0x00 ; 0
1c0: 08 c0 rjmp .+16 ; 0x1d2 <wait+0x16>
1c2: e3 ec ldi r30, 0xC3 ; 195
1c4: f9 e0 ldi r31, 0x09 ; 9
1c6: 31 97 sbiw r30, 0x01 ; 1
1c8: f1 f7 brne .-4 ; 0x1c6 <wait+0xa>
1ca: 00 c0 rjmp .+0 ; 0x1cc <wait+0x10>
1cc: 00 00 nop
1ce: 2f 5f subi r18, 0xFF ; 255
1d0: 3f 4f sbci r19, 0xFF ; 255
1d2: 28 17 cp r18, r24
1d4: 39 07 cpc r19, r25
1d6: ac f3 brlt .-22 ; 0x1c2 <wait+0x6>
1d8: 08 95 ret
000001da <adcInit>:
1da: 80 ee ldi r24, 0xE0 ; 224
1dc: 87 b9 out 0x07, r24 ; 7
1de: 86 e8 ldi r24, 0x86 ; 134
1e0: 86 b9 out 0x06, r24 ; 6
1e2: 08 95 ret
000001e4 <__vector_9>:
1e4: 1f 92 push r1
1e6: 0f 92 push r0
1e8: 0f b6 in r0, 0x3f ; 63
1ea: 0f 92 push r0
1ec: 11 24 eor r1, r1
1ee: 0f 90 pop r0
1f0: 0f be out 0x3f, r0 ; 63
1f2: 0f 90 pop r0
1f4: 1f 90 pop r1
1f6: 18 95 reti
000001f8 <main>:
int main(void)
{
/* Replace with your application code */
DDRF = 0x00; // set port F input.
1f8: 10 92 61 00 sts 0x0061, r1 ; 0x800061 <__TEXT_REGION_LENGTH__+0x7e0061>
DDRE = 0xFF; // all port A output.
1fc: 8f ef ldi r24, 0xFF ; 255
1fe: 82 b9 out 0x02, r24 ; 2
adcInit();
200: ec df rcall .-40 ; 0x1da <adcInit>
init_4bits_mode();
202: af df rcall .-162 ; 0x162 <init_4bits_mode>
lcd_clear();
204: a3 df rcall .-186 ; 0x14c <lcd_clear>
lcd_move_right();
206: d7 df rcall .-82 ; 0x1b6 <lcd_move_right>
lcd_move_right();
208: d6 df rcall .-84 ; 0x1b6 <lcd_move_right>
20a: 80 e0 ldi r24, 0x00 ; 0
lcd_write_string("MOOOOOOOOO");
20c: 91 e0 ldi r25, 0x01 ; 1
20e: c7 df rcall .-114 ; 0x19e <lcd_write_string>
210: 87 ea ldi r24, 0xA7 ; 167
212: 91 e6 ldi r25, 0x61 ; 97
214: 01 97 sbiw r24, 0x01 ; 1
216: f1 f7 brne .-4 ; 0x214 <main+0x1c>
218: 00 c0 rjmp .+0 ; 0x21a <main+0x22>
21a: 00 00 nop
21c: 86 b1 in r24, 0x06 ; 6
21e: 80 64 ori r24, 0x40 ; 64
_delay_ms(10);
//timer2Init();
while (1)
{
ADCSRA |= BIT(6);
220: 86 b9 out 0x06, r24 ; 6
222: 85 b1 in r24, 0x05 ; 5
PORTE = ADCH;
224: 83 b9 out 0x03, r24 ; 3
226: 8a e0 ldi r24, 0x0A ; 10
//lcd_clear();
//lcd_write_character(getADCValue());
wait(10);
228: 90 e0 ldi r25, 0x00 ; 0
22a: c8 df rcall .-112 ; 0x1bc <wait>
22c: f7 cf rjmp .-18 ; 0x21c <main+0x24>
0000022e <_exit>:
22e: f8 94 cli
00000230 <__stop_program>:
230: ff cf rjmp .-2 ; 0x230 <__stop_program>

View File

@@ -0,0 +1,39 @@
S01400006F7064726163687420342E312E7372656308
S113000045C0000058C0000056C0000054C00000A5
S113001052C0000050C000004EC000004CC00000A0
S11300204AC00000DFC0000046C0000044C0000019
S113003042C0000040C000003EC000003CC00000C0
S11300403AC0000038C0000036C0000034C00000D0
S113005032C0000030C000002EC000002CC00000E0
S11300602AC0000028C0000026C0000024C00000F0
S113007022C0000020C000001EC000001CC0000000
S11300801AC0000018C0000016C0000011241FBED2
S1130090CFEFD0E1DEBFCDBF11E0A0E0B1E0E2E3FD
S11300A0F2E000E00BBF02C007900D92AC30B10744
S11300B0D9F7A2D0BCC0A4CF9BB321E030E002C0EA
S11300C0220F331F8A95E2F7292B2BBB08959BB38C
S11300D021E030E002C0220F331F8A95E2F7209519
S11300E029232BBB089586E090E0E6DF89EF90E0BA
S11300F00197F1F700C0000086E090E0E8DF89EFA7
S113010090E00197F1F700C000000895CF93C82F45
S113011085BB84E090E0D0DFE6DFC295C07FC5BB3D
S113012084E090E0C9DFDFDFCF910895CF93C82F3B
S113013085BB84E090E0CBDFD6DFC295C07FC5BB32
S113014084E090E0C4DFCFDFCF91089581E0EEDF5B
S113015083EF91E00197F1F700C0000080E8E6CF5B
S11301600895CF938FEF84BB85BB8ABB15BA1BBAA6
S1130170C0E2C5BBB8DFC5BBB6DF80E885BBB3DF73
S113018015BAB1DF80EF85BBAEDF15BAACDF80E610
S113019085BBA9DF82E0CADFA6DFCF910895CF93A4
S11301A0DF93EC0102C0B2DF219688818111FBCF7D
S11301B0DF91CF9108958EE1B9CF089520E030E02A
S11301C008C0E3ECF9E03197F1F700C000002F5FBD
S11301D03F4F28173907ACF3089580EE87B986E8B6
S11301E086B908951F920F920FB60F9211240F90A3
S11301F00FBE0F901F901895109261008FEF82B977
S1130200ECDFAFDFA3DFD7DFD6DF80E091E0C7DF2D
S113021087EA91E60197F1F700C0000086B1806497
S113022086B985B183B98AE090E0C8DFF7CFF89446
S1050230FFCFFA
S10F02324D4F4F4F4F4F4F4F4F4F0000A8
S9030000FC

View File

@@ -0,0 +1,122 @@
/*
* lcd_controlc.c
*
* Created: 24-2-2021 11:55:12
* Author: Sem
*/
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include "lcd_control.h"
void _delay_ms(double __ms);
void lcd_clear() {
lcd_write_command (0x01); //Leeg display
_delay_ms(2);
lcd_write_command (0x80); //Cursor terug naar start
}
void lcd_strobe_lcd_e(void) {
sbi_porta(LCD_E); // E high
_delay_ms(1);
cbi_porta(LCD_E); // E low
_delay_ms(1);
}
void sbi_portc(int index){
PORTC |= (1<<index);
}
void cbi_portc(int index){
PORTC &= ~(1<<index);
}
void sbi_porta(int index){
PORTA |= (1<<index);
}
void cbi_porta(int index){
PORTA &= ~(1<<index);
}
void init_4bits_mode(void) {
// PORTC output mode and all low (also E and RS pin)
// Init I/O
DDRC = 0xFF; // PORTD(7) output, PORTD(6:0) input
PORTC = 0xFF;
DDRA = 0xFF;
PORTC = 0x00;
PORTA = 0x00;
PORTC = 0x20; // function for 4-bit 1 row
lcd_strobe_lcd_e();
PORTC = 0x20; // function high nibble 4-bit 2 row
lcd_strobe_lcd_e();
PORTC = 0x80; // function low nibble 4-bit 2 row
lcd_strobe_lcd_e();
PORTC = 0x00; // function high nibble turn on visible blinking-block cursor
lcd_strobe_lcd_e();
PORTC = 0xF0; // function low nibble turn on visible blinking-block cursor
lcd_strobe_lcd_e();
PORTC = 0x00; // Entry mode set high nibble
lcd_strobe_lcd_e();
PORTC = 0x60; // Entry mode set low nibble
lcd_strobe_lcd_e();
// return home
lcd_write_command(0x02);
lcd_strobe_lcd_e();
}
void lcd_write_character(unsigned char byte){
//upper nibble
PORTC = byte;
sbi_porta(LCD_RS);
lcd_strobe_lcd_e();
//lower nibble
PORTC = (byte<<4);
sbi_porta(LCD_RS);
lcd_strobe_lcd_e();
}
void lcd_write_command(unsigned char byte){
//upper nibble
PORTC = byte;
cbi_porta(LCD_RS);
lcd_strobe_lcd_e();
//lower nibble
PORTC = (byte<<4);
cbi_porta(LCD_RS);
lcd_strobe_lcd_e();
}
void lcd_write_string(const char *str) {
for(;*str; str++){
lcd_write_character(*str);
}
}
void lcd_move_right(void){
lcd_write_command(0x1E);
}

View File

@@ -0,0 +1,30 @@
/*
* lcd_control.h
*
* Created: 24-2-2021 11:56:16
* Author: Sem
*/
#ifndef LCD_CONTROL_H_
#define LCD_CONTROL_H_
#define LCD_E 6
#define LCD_RS 4
void _delay_ms(double __ms);
void lcd_strobe_lcd_e(void);
void sbi_portc(int index);
void cbi_portc(int index);
void sbi_porta(int index);
void cbi_porta(int index);
void init_4bits_mode(void);
void lcd_write_string(const char *str);
void lcd_write_character(unsigned char byte);
void lcd_write_command(unsigned char byte);
void lcd_move_right(void);
void lcd_clear();
#endif /* LCD_CONTROL_H_ */

View File

@@ -0,0 +1,70 @@
/*
* opdracht 4.1.c
*
* Created: 03-Mar-21 9:26:31 AM
* Author : lemms
*/
#define F_CPU 10e6
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include "lcd_control.h"
#define BIT(x) (1 << (x))
void wait( int ms ) {
for (int tms=0; tms<ms; tms++) {
_delay_ms( 1 ); // library function (max 30 ms at 8MHz)
}
}
void adcInit(){
ADMUX = 0b11100000; // internal reference: 2.56V and SEI on ADC0 and left-adjusted.
ADCSRA = 0b10000110; // enable ADC. No free-run. Clock 64 D-factor.
}
void timer2Init( void ) {
TIMSK |= BIT(7); // T2 compare match interrupt enable
sei(); // turn_on interrupt all
TCCR2 = 0b00000011; // Initialize T2: timer, pre-scaler=64
}
ISR( TIMER2_COMP_vect ) {
}
int getADCValue(){
int value = 0;
value = ADCH;
value <<= 2;
value += ADCL;
return value;
}
int main(void)
{
/* Replace with your application code */
DDRF = 0x00; // set port F input.
DDRE = 0xFF; // all port A output.
adcInit();
init_4bits_mode();
lcd_clear();
lcd_move_right();
lcd_move_right();
lcd_write_string("MOOOOOOOOO");
_delay_ms(10);
//timer2Init();
while (1)
{
ADCSRA |= BIT(6);
PORTE = ADCH;
//lcd_clear();
//lcd_write_character(getADCValue());
wait(10);
}
}

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Store xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="AtmelPackComponentManagement">
<ProjectComponents>
<ProjectComponent z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<CApiVersion></CApiVersion>
<CBundle></CBundle>
<CClass>Device</CClass>
<CGroup>Startup</CGroup>
<CSub></CSub>
<CVariant></CVariant>
<CVendor>Atmel</CVendor>
<CVersion>1.6.0</CVersion>
<DefaultRepoPath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs</DefaultRepoPath>
<DependentComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<Description></Description>
<Files xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\include\</AbsolutePath>
<Attribute></Attribute>
<Category>include</Category>
<Condition>C</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>include/</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\include\avr\iom128.h</AbsolutePath>
<Attribute></Attribute>
<Category>header</Category>
<Condition>C</Condition>
<FileContentHash>JdJ7J9I/SJh965SEyyyVYw==</FileContentHash>
<FileVersion></FileVersion>
<Name>include/avr/iom128.h</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\templates\main.c</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>ocUBw/Ju1i9iTulaRbeRxg==</FileContentHash>
<FileVersion></FileVersion>
<Name>templates/main.c</Name>
<SelectString>Main file (.c)</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\templates\main.cpp</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>mkKaE95TOoATsuBGv6jmxg==</FileContentHash>
<FileVersion></FileVersion>
<Name>templates/main.cpp</Name>
<SelectString>Main file (.cpp)</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128</AbsolutePath>
<Attribute></Attribute>
<Category>libraryPrefix</Category>
<Condition>GCC</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>gcc/dev/atmega128</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>ATmega_DFP</PackName>
<PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.6.364/Atmel.ATmega_DFP.pdsc</PackPath>
<PackVersion>1.6.364</PackVersion>
<PresentInProject>true</PresentInProject>
<ReferenceConditionId>ATmega128</ReferenceConditionId>
<RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:string></d4p1:string>
</RteComponents>
<Status>Resolved</Status>
<VersionMode>Fixed</VersionMode>
<IsComponentInAtProject>true</IsComponentInAtProject>
</ProjectComponent>
</ProjectComponents>
</Store>

View File

@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>7.0</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
<ProjectGuid>{2432e6bf-da1e-4668-99bb-59fea1f5b8a2}</ProjectGuid>
<avrdevice>ATmega128</avrdevice>
<avrdeviceseries>none</avrdeviceseries>
<OutputType>Executable</OutputType>
<Language>C</Language>
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
<OutputFileExtension>.elf</OutputFileExtension>
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
<AssemblyName>opdracht 4.1</AssemblyName>
<Name>opdracht 4.1</Name>
<RootNamespace>opdracht 4.1</RootNamespace>
<ToolchainFlavour>Native</ToolchainFlavour>
<KeepTimersRunning>true</KeepTimersRunning>
<OverrideVtor>false</OverrideVtor>
<CacheFlash>true</CacheFlash>
<ProgFlashFromRam>true</ProgFlashFromRam>
<RamSnippetAddress />
<UncachedRange />
<preserveEEPROM>true</preserveEEPROM>
<OverrideVtorValue />
<BootSegment>2</BootSegment>
<ResetRule>0</ResetRule>
<eraseonlaunchrule>0</eraseonlaunchrule>
<EraseKey />
<AsfFrameworkConfig>
<framework-data xmlns="">
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.49.1" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128"</avrgcc.common.Device>
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atmega128 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega128"</avrgcc.common.Device>
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize debugging experience (-Og)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
<Compile Include="lcd_control.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="lcd_control.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="main.c">
<SubType>compile</SubType>
</Compile>
</ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
</Project>