diff --git a/Microcontrollers/Microcontrollers.atsln b/Microcontrollers/Microcontrollers.atsln index b8dfdb7..2d3ad28 100644 --- a/Microcontrollers/Microcontrollers.atsln +++ b/Microcontrollers/Microcontrollers.atsln @@ -21,6 +21,8 @@ Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "opdracht 2.3", "opdracht 2. 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}") = "testlcd", "testlcd\testlcd.cproj", "{B964892D-A92F-44D4-AF99-3ADC61820917}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|AVR = Debug|AVR @@ -63,6 +65,10 @@ Global {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 + {B964892D-A92F-44D4-AF99-3ADC61820917}.Debug|AVR.ActiveCfg = Debug|AVR + {B964892D-A92F-44D4-AF99-3ADC61820917}.Debug|AVR.Build.0 = Debug|AVR + {B964892D-A92F-44D4-AF99-3ADC61820917}.Release|AVR.ActiveCfg = Release|AVR + {B964892D-A92F-44D4-AF99-3ADC61820917}.Release|AVR.Build.0 = Release|AVR EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Microcontrollers/testlcd/Debug/Makefile b/Microcontrollers/testlcd/Debug/Makefile new file mode 100644 index 0000000..c3b7b04 --- /dev/null +++ b/Microcontrollers/testlcd/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 +=testlcd.elf + +OUTPUT_FILE_PATH_AS_ARGS +=testlcd.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="testlcd.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 "testlcd.elf" "testlcd.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 "testlcd.elf" "testlcd.eep" || exit 0 + "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "testlcd.elf" > "testlcd.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 "testlcd.elf" "testlcd.srec" + "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "testlcd.elf" + + + + + + + +# Other Targets +clean: + -$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES) + -$(RM) $(C_DEPS_AS_ARGS) + rm -rf "testlcd.elf" "testlcd.a" "testlcd.hex" "testlcd.lss" "testlcd.eep" "testlcd.map" "testlcd.srec" "testlcd.usersignatures" + \ No newline at end of file diff --git a/Microcontrollers/testlcd/Debug/makedep.mk b/Microcontrollers/testlcd/Debug/makedep.mk new file mode 100644 index 0000000..6a14fde --- /dev/null +++ b/Microcontrollers/testlcd/Debug/makedep.mk @@ -0,0 +1,6 @@ +################################################################################ +# Automatically-generated file. Do not edit or delete the file +################################################################################ + +main.c + diff --git a/Microcontrollers/testlcd/Debug/testlcd.eep b/Microcontrollers/testlcd/Debug/testlcd.eep new file mode 100644 index 0000000..7c166a1 --- /dev/null +++ b/Microcontrollers/testlcd/Debug/testlcd.eep @@ -0,0 +1 @@ +:00000001FF diff --git a/Microcontrollers/testlcd/Debug/testlcd.lss b/Microcontrollers/testlcd/Debug/testlcd.lss new file mode 100644 index 0000000..0a359c6 --- /dev/null +++ b/Microcontrollers/testlcd/Debug/testlcd.lss @@ -0,0 +1,430 @@ + +testlcd.elf: file format elf32-avr + +Sections: +Idx Name Size VMA LMA File off Algn + 0 .data 0000000e 00800100 000001ce 00000242 2**0 + CONTENTS, ALLOC, LOAD, DATA + 1 .text 000001ce 00000000 00000000 00000074 2**1 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 2 .comment 00000030 00000000 00000000 00000250 2**0 + CONTENTS, READONLY + 3 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 00000280 2**2 + CONTENTS, READONLY + 4 .debug_aranges 00000058 00000000 00000000 000002bc 2**0 + CONTENTS, READONLY, DEBUGGING + 5 .debug_info 00000b5a 00000000 00000000 00000314 2**0 + CONTENTS, READONLY, DEBUGGING + 6 .debug_abbrev 0000088d 00000000 00000000 00000e6e 2**0 + CONTENTS, READONLY, DEBUGGING + 7 .debug_line 00000470 00000000 00000000 000016fb 2**0 + CONTENTS, READONLY, DEBUGGING + 8 .debug_frame 000000b8 00000000 00000000 00001b6c 2**2 + CONTENTS, READONLY, DEBUGGING + 9 .debug_str 00000479 00000000 00000000 00001c24 2**0 + CONTENTS, READONLY, DEBUGGING + 10 .debug_loc 00000299 00000000 00000000 0000209d 2**0 + CONTENTS, READONLY, DEBUGGING + 11 .debug_ranges 00000048 00000000 00000000 00002336 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: 48 c0 rjmp .+144 ; 0xb6 <__bad_interrupt> + 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: ee ec ldi r30, 0xCE ; 206 + 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: ae 30 cpi r26, 0x0E ; 14 + ae: b1 07 cpc r27, r17 + b0: d9 f7 brne .-10 ; 0xa8 <__do_copy_data+0x10> + b2: 75 d0 rcall .+234 ; 0x19e
+ b4: 8a c0 rjmp .+276 ; 0x1ca <_exit> + +000000b6 <__bad_interrupt>: + b6: a4 cf rjmp .-184 ; 0x0 <__vectors> + +000000b8 : +clock value is set. This is used by _delay_ms inside +util/delay.h +Version : DMK, Initial code +*******************************************************************/ +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); + be: ef ec ldi r30, 0xCF ; 207 + c0: f7 e0 ldi r31, 0x07 ; 7 + c2: 31 97 sbiw r30, 0x01 ; 1 + c4: f1 f7 brne .-4 ; 0xc2 + c6: 00 c0 rjmp .+0 ; 0xc8 + c8: 00 00 nop + ca: 2f 5f subi r18, 0xFF ; 255 + cc: 3f 4f sbci r19, 0xFF ; 255 + ce: 28 17 cp r18, r24 + d0: 39 07 cpc r19, r25 + d2: ac f3 brlt .-22 ; 0xbe + _delay_ms( 1 ); // library function (max 30 ms at 8MHz) + } +} + d4: 08 95 ret + +000000d6 : +outputs: +notes: According datasheet HD44780 +Version : DMK, Initial code +*******************************************************************/ +void lcd_strobe_lcd_e(void) { + PORTA |= (1< + e4: 00 c0 rjmp .+0 ; 0xe6 + e6: 00 00 nop + _delay_ms(1); // nodig + PORTA &= ~(1< + f6: 00 c0 rjmp .+0 ; 0xf8 + f8: 00 00 nop + fa: 08 95 ret + +000000fc : +inputs: +outputs: +notes: According datasheet HD44780 table 12 +Version : DMK, Initial code +*******************************************************************/ +void init_4bits_mode(void) { + fc: cf 93 push r28 + // PORTC output mode and all low (also E and RS pin) + DDRD = 0xFF; + fe: 8f ef ldi r24, 0xFF ; 255 + 100: 81 bb out 0x11, r24 ; 17 + DDRA = 0xFF; + 102: 8a bb out 0x1a, r24 ; 26 + PORTC = 0x00; + 104: 15 ba out 0x15, r1 ; 21 + PORTA = 0x00; + 106: 1b ba out 0x1b, r1 ; 27 + //PORTA = 0xFF; + + // Step 2 (table 12) + PORTC = 0x20; // function set + 108: c0 e2 ldi r28, 0x20 ; 32 + 10a: c5 bb out 0x15, r28 ; 21 + lcd_strobe_lcd_e(); + 10c: e4 df rcall .-56 ; 0xd6 + + // Step 3 (table 12) + PORTC = 0x20; // function set + lcd_strobe_lcd_e(); + 10e: c5 bb out 0x15, r28 ; 21 + 110: e2 df rcall .-60 ; 0xd6 + PORTC = 0x80; + 112: 80 e8 ldi r24, 0x80 ; 128 + lcd_strobe_lcd_e(); + 114: 85 bb out 0x15, r24 ; 21 + + // Step 4 (table 12) + PORTC = 0x00; // Display on/off control + 116: df df rcall .-66 ; 0xd6 + lcd_strobe_lcd_e(); + 118: 15 ba out 0x15, r1 ; 21 + PORTC = 0xF0; + 11a: dd df rcall .-70 ; 0xd6 + lcd_strobe_lcd_e(); + 11c: 80 ef ldi r24, 0xF0 ; 240 + + // Step 4 (table 12) + PORTC = 0x00; // Entry mode set + 11e: 85 bb out 0x15, r24 ; 21 + lcd_strobe_lcd_e(); + 120: da df rcall .-76 ; 0xd6 + 122: 15 ba out 0x15, r1 ; 21 + PORTC = 0x60; + 124: d8 df rcall .-80 ; 0xd6 + 126: 80 e6 ldi r24, 0x60 ; 96 + lcd_strobe_lcd_e(); + 128: 85 bb out 0x15, r24 ; 21 + 12a: d5 df rcall .-86 ; 0xd6 +} + 12c: cf 91 pop r28 + 12e: 08 95 ret + +00000130 : +inputs: byte - written to LCD +outputs: +notes: According datasheet HD44780 table 12 +Version : DMK, Initial code +*******************************************************************/ +void lcd_write_data(unsigned char byte) { + 130: cf 93 push r28 + 132: c8 2f mov r28, r24 + // First nibble. + PORTC = byte; + 134: 85 bb out 0x15, r24 ; 21 + PORTA |= (1< + + // Second nibble + PORTC = (byte<<4); + 13e: c2 95 swap r28 + 140: c0 7f andi r28, 0xF0 ; 240 + 142: c5 bb out 0x15, r28 ; 21 + PORTA |= (1< +} + 14c: cf 91 pop r28 + 14e: 08 95 ret + +00000150 : +inputs: +outputs: +notes: According datasheet HD44780 table 12 +Version : DMK, Initial code +*******************************************************************/ +void lcd_write_string(char *str) { + 150: cf 93 push r28 + 152: df 93 push r29 + 154: ec 01 movw r28, r24 + // while(*str) { + // lcd_write_data(*str++); + // } + + // of met een for: + for(;*str; str++){ + 156: 02 c0 rjmp .+4 ; 0x15c + lcd_write_data(*str); + 158: eb df rcall .-42 ; 0x130 + // while(*str) { + // lcd_write_data(*str++); + // } + + // of met een for: + for(;*str; str++){ + 15a: 21 96 adiw r28, 0x01 ; 1 + 15c: 88 81 ld r24, Y + 15e: 81 11 cpse r24, r1 + 160: fb cf rjmp .-10 ; 0x158 + lcd_write_data(*str); + } +} + 162: df 91 pop r29 + 164: cf 91 pop r28 + 166: 08 95 ret + +00000168 : +inputs: byte - written to LCD +outputs: +notes: According datasheet HD44780 table 12 +Version : DMK, Initial code +*******************************************************************/ +void lcd_write_command(unsigned char byte) { + 168: cf 93 push r28 + 16a: c8 2f mov r28, r24 + // First nibble. + PORTC = byte; + 16c: 85 bb out 0x15, r24 ; 21 + PORTA &= ~(1< + + // Second nibble + PORTC = (byte<<4); + 176: c2 95 swap r28 + 178: c0 7f andi r28, 0xF0 ; 240 + 17a: c5 bb out 0x15, r28 ; 21 + PORTA &= ~(1< +} + 184: cf 91 pop r28 + 186: 08 95 ret + +00000188 : + + +void lcd_clear() { + lcd_write_command (0x01); //Leeg display + 188: 81 e0 ldi r24, 0x01 ; 1 + 18a: ee df rcall .-36 ; 0x168 + 18c: 8f e9 ldi r24, 0x9F ; 159 + 18e: 9f e0 ldi r25, 0x0F ; 15 + 190: 01 97 sbiw r24, 0x01 ; 1 + 192: f1 f7 brne .-4 ; 0x190 + 194: 00 c0 rjmp .+0 ; 0x196 + 196: 00 00 nop + _delay_ms(2); + lcd_write_command (0x80); //Cursor terug naar start + 198: 80 e8 ldi r24, 0x80 ; 128 + 19a: e6 cf rjmp .-52 ; 0x168 + 19c: 08 95 ret + +0000019e
: +notes: Slow background task after init ISR +Version : DMK, Initial code +*******************************************************************/ +int main( void ) { + // Init I/O + DDRC = 0xFF; // PORTD(7) output, PORTD(6:0) input + 19e: 8f ef ldi r24, 0xFF ; 255 + 1a0: 84 bb out 0x14, r24 ; 20 + PORTC = 0xFF; + 1a2: 85 bb out 0x15, r24 ; 21 + + // Init LCD + init_4bits_mode(); + 1a4: ab df rcall .-170 ; 0xfc + 1a6: 8f e1 ldi r24, 0x1F ; 31 + 1a8: 9e e4 ldi r25, 0x4E ; 78 + 1aa: 01 97 sbiw r24, 0x01 ; 1 + 1ac: f1 f7 brne .-4 ; 0x1aa + 1ae: 00 c0 rjmp .+0 ; 0x1b0 + + _delay_ms(10); + + lcd_clear(); + 1b0: 00 00 nop + 1b2: ea df rcall .-44 ; 0x188 + + // Write sample string + lcd_write_string("Hello world!"); + 1b4: 80 e0 ldi r24, 0x00 ; 0 + 1b6: 91 e0 ldi r25, 0x01 ; 1 + 1b8: cb df rcall .-106 ; 0x150 + + // Loop forever + while (1) { + PORTC ^= (1<<0); // Toggle PORTD.7 + 1ba: 95 b3 in r25, 0x15 ; 21 + 1bc: 81 e0 ldi r24, 0x01 ; 1 + 1be: 89 27 eor r24, r25 + wait( 250 ); + 1c0: 85 bb out 0x15, r24 ; 21 + 1c2: 8a ef ldi r24, 0xFA ; 250 + 1c4: 90 e0 ldi r25, 0x00 ; 0 + 1c6: 78 df rcall .-272 ; 0xb8 + 1c8: f8 cf rjmp .-16 ; 0x1ba + +000001ca <_exit>: + 1ca: f8 94 cli + +000001cc <__stop_program>: + 1cc: ff cf rjmp .-2 ; 0x1cc <__stop_program> diff --git a/Microcontrollers/testlcd/Debug/testlcd.srec b/Microcontrollers/testlcd/Debug/testlcd.srec new file mode 100644 index 0000000..2da1b20 --- /dev/null +++ b/Microcontrollers/testlcd/Debug/testlcd.srec @@ -0,0 +1,32 @@ +S00F0000746573746C63642E7372656322 +S113000045C0000058C0000056C0000054C00000A5 +S113001052C0000050C000004EC000004CC00000A0 +S11300204AC0000048C0000046C0000044C00000B0 +S113003042C0000040C000003EC000003CC00000C0 +S11300403AC0000038C0000036C0000034C00000D0 +S113005032C0000030C000002EC000002CC00000E0 +S11300602AC0000028C0000026C0000024C00000F0 +S113007022C0000020C000001EC000001CC0000000 +S11300801AC0000018C0000016C0000011241FBED2 +S1130090CFEFD0E1DEBFCDBF11E0A0E0B1E0EEECE8 +S11300A0F1E000E00BBF02C007900D92AE30B10743 +S11300B0D9F775D08AC0A4CF20E030E008C0EFECB7 +S11300C0F7E03197F1F700C000002F5F3F4F28178A +S11300D03907ACF308958BB380648BBB8FEC97E046 +S11300E00197F1F700C000008BB38F7B8BBB8FECC3 +S11300F097E00197F1F700C000000895CF938FEFC8 +S113010081BB8ABB15BA1BBAC0E2C5BBE4DFC5BB61 +S1130110E2DF80E885BBDFDF15BADDDF80EF85BB7A +S1130120DADF15BAD8DF80E685BBD5DFCF91089535 +S1130130CF93C82F85BB8BB380618BBBCCDFC295BB +S1130140C07FC5BB8BB380618BBBC5DFCF910895E6 +S1130150CF93DF93EC0102C0EBDF219688818111FC +S1130160FBCFDF91CF910895CF93C82F85BB8BB37D +S11301708F7E8BBBB0DFC295C07FC5BB8BB38F7E38 +S11301808BBBA9DFCF91089581E0EEDF8FE99FE07B +S11301900197F1F700C0000080E8E6CF08958FEFE3 +S11301A084BB85BBABDF8FE19EE40197F1F700C010 +S11301B00000EADF80E091E0CBDF95B381E089279E +S11101C085BB8AEF90E078DFF8CFF894FFCF8C +S11101CE48656C6C6F20776F726C64210000C2 +S9030000FC diff --git a/Microcontrollers/testlcd/main.c b/Microcontrollers/testlcd/main.c new file mode 100644 index 0000000..7b76a0a --- /dev/null +++ b/Microcontrollers/testlcd/main.c @@ -0,0 +1,200 @@ +/* --------------------------------------------------------------------------- +** 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. +** +** ioisr.c +** +** Beschrijving: BigAVR LCD module +** Target: AVR mcu +** Build: avr-gcc -std=c99 -Wall -O3 -mmcu=atmega128 -D F_CPU=8000000UL -c lcd.c +** avr-gcc -g -mmcu=atmega128 -o lcd.elf lcd.o +** avr-objcopy -O ihex lcd.elf lcd.hex +** or type 'make' +** Author: dkroeske@gmail.com +** -------------------------------------------------------------------------*/ + +#define F_CPU 8e6 + +#include +#include +#include + +#define LCD_E 6 // RA6 UNI-6 +#define LCD_RS 4 // RA4 UNI-6 + +void lcd_strobe_lcd_e(void); +void init_4bits_mode(void); +void lcd_write_string(char *str); +void lcd_write_data(unsigned char byte); +void lcd_write_cmd(unsigned char byte); +void lcd_clear(void); + + +/****************************************************************** +short: Busy wait number of millisecs +inputs: int ms (Number of millisecs to busy wait) +outputs: +notes: Busy wait, not very accurate. Make sure (external) +clock value is set. This is used by _delay_ms inside +util/delay.h +Version : DMK, Initial code +*******************************************************************/ +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\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 + acTgQvo2LQZomOc3SBvMjw== + + 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/testlcd/testlcd.cproj b/Microcontrollers/testlcd/testlcd.cproj new file mode 100644 index 0000000..7df6d59 --- /dev/null +++ b/Microcontrollers/testlcd/testlcd.cproj @@ -0,0 +1,146 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + {b964892d-a92f-44d4-af99-3adc61820917} + ATmega128 + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + testlcd + testlcd + testlcd + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + 0 + + + + + + + + + + + + + + com.atmel.avrdbg.tool.atmelice + J42700011096 + 0x1E9702 + + + + 2000000 + + JTAG + + com.atmel.avrdbg.tool.atmelice + J42700011096 + Atmel-ICE + + JTAG + 2000000 + + + + + -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