[ADD] reading echo in oscilloscope

This commit is contained in:
Sem van der Hoeven
2021-03-17 12:02:02 +01:00
parent 547a4f7053
commit c8839a017d
12 changed files with 856 additions and 6 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 +=ultrasonicSensor.elf
OUTPUT_FILE_PATH_AS_ARGS +=ultrasonicSensor.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="ultrasonicSensor.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 "ultrasonicSensor.elf" "ultrasonicSensor.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 "ultrasonicSensor.elf" "ultrasonicSensor.eep" || exit 0
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "ultrasonicSensor.elf" > "ultrasonicSensor.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 "ultrasonicSensor.elf" "ultrasonicSensor.srec"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "ultrasonicSensor.elf"
# Other Targets
clean:
-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)
-$(RM) $(C_DEPS_AS_ARGS)
rm -rf "ultrasonicSensor.elf" "ultrasonicSensor.a" "ultrasonicSensor.hex" "ultrasonicSensor.lss" "ultrasonicSensor.eep" "ultrasonicSensor.map" "ultrasonicSensor.srec" "ultrasonicSensor.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,231 @@
ultrasonicSensor.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 00000000 00800100 00800100 00000166 2**0
CONTENTS, ALLOC, LOAD, DATA
1 .text 00000112 00000000 00000000 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .comment 00000030 00000000 00000000 00000166 2**0
CONTENTS, READONLY
3 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 00000198 2**2
CONTENTS, READONLY
4 .debug_aranges 00000030 00000000 00000000 000001d4 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_info 000009ad 00000000 00000000 00000204 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_abbrev 0000084e 00000000 00000000 00000bb1 2**0
CONTENTS, READONLY, DEBUGGING
7 .debug_line 0000030d 00000000 00000000 000013ff 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_frame 00000044 00000000 00000000 0000170c 2**2
CONTENTS, READONLY, DEBUGGING
9 .debug_str 0000043a 00000000 00000000 00001750 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_loc 000000d2 00000000 00000000 00001b8a 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_ranges 00000020 00000000 00000000 00001c5c 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: e2 e1 ldi r30, 0x12 ; 18
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: a0 30 cpi r26, 0x00 ; 0
ae: b1 07 cpc r27, r17
b0: d9 f7 brne .-10 ; 0xa8 <__do_copy_data+0x10>
b2: 1e d0 rcall .+60 ; 0xf0 <main>
b4: 2c c0 rjmp .+88 ; 0x10e <_exit>
000000b6 <__bad_interrupt>:
b6: a4 cf rjmp .-184 ; 0x0 <__vectors>
000000b8 <wait_us>:
#include "lcd_control.h"
void wait_us(unsigned int us)
{
for(int i = 0; i < us; i++)
b8: 20 e0 ldi r18, 0x00 ; 0
ba: 30 e0 ldi r19, 0x00 ; 0
bc: 06 c0 rjmp .+12 ; 0xca <wait_us+0x12>
#else
//round up by default
__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
#endif
__builtin_avr_delay_cycles(__ticks_dc);
be: 46 e0 ldi r20, 0x06 ; 6
c0: 4a 95 dec r20
c2: f1 f7 brne .-4 ; 0xc0 <wait_us+0x8>
c4: 00 c0 rjmp .+0 ; 0xc6 <wait_us+0xe>
c6: 2f 5f subi r18, 0xFF ; 255
c8: 3f 4f sbci r19, 0xFF ; 255
ca: 28 17 cp r18, r24
cc: 39 07 cpc r19, r25
ce: b8 f3 brcs .-18 ; 0xbe <wait_us+0x6>
{
_delay_us(1);
}
}
d0: 08 95 ret
000000d2 <wait_ms>:
void wait_ms(unsigned int ms)
{
for(int i = 0; i < ms; i++)
d2: 20 e0 ldi r18, 0x00 ; 0
d4: 30 e0 ldi r19, 0x00 ; 0
d6: 08 c0 rjmp .+16 ; 0xe8 <wait_ms+0x16>
#else
//round up by default
__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
#endif
__builtin_avr_delay_cycles(__ticks_dc);
d8: e7 e8 ldi r30, 0x87 ; 135
da: f3 e1 ldi r31, 0x13 ; 19
dc: 31 97 sbiw r30, 0x01 ; 1
de: f1 f7 brne .-4 ; 0xdc <wait_ms+0xa>
e0: 00 c0 rjmp .+0 ; 0xe2 <wait_ms+0x10>
e2: 00 00 nop
e4: 2f 5f subi r18, 0xFF ; 255
e6: 3f 4f sbci r19, 0xFF ; 255
e8: 28 17 cp r18, r24
ea: 39 07 cpc r19, r25
ec: a8 f3 brcs .-22 ; 0xd8 <wait_ms+0x6>
{
_delay_ms(1);
}
}
ee: 08 95 ret
000000f0 <main>:
int main(void)
{
DDRG = 0x01; // port g pin 0 on output, 1 on input. 0 is trig, 1 is echo
f0: 81 e0 ldi r24, 0x01 ; 1
f2: 80 93 64 00 sts 0x0064, r24 ; 0x800064 <__TEXT_REGION_LENGTH__+0x7e0064>
/* Replace with your application code */
while (1)
{
PORTG = 0x00; // 10 us low pulse
f6: c5 e6 ldi r28, 0x65 ; 101
f8: d0 e0 ldi r29, 0x00 ; 0
fa: 18 82 st Y, r1
wait_us(10);
fc: 8a e0 ldi r24, 0x0A ; 10
fe: 90 e0 ldi r25, 0x00 ; 0
100: db df rcall .-74 ; 0xb8 <wait_us>
PORTG = 0x01;
102: 81 e0 ldi r24, 0x01 ; 1
104: 88 83 st Y, r24
wait_ms(100);
106: 84 e6 ldi r24, 0x64 ; 100
108: 90 e0 ldi r25, 0x00 ; 0
10a: e3 df rcall .-58 ; 0xd2 <wait_ms>
10c: f4 cf rjmp .-24 ; 0xf6 <main+0x6>
0000010e <_exit>:
10e: f8 94 cli
00000110 <__stop_program>:
110: ff cf rjmp .-2 ; 0x110 <__stop_program>

View File

@@ -0,0 +1,20 @@
S0180000756C747261736F6E696353656E736F722E737265634E
S113000045C0000058C0000056C0000054C00000A5
S113001052C0000050C000004EC000004CC00000A0
S11300204AC0000048C0000046C0000044C00000B0
S113003042C0000040C000003EC000003CC00000C0
S11300403AC0000038C0000036C0000034C00000D0
S113005032C0000030C000002EC000002CC00000E0
S11300602AC0000028C0000026C0000024C00000F0
S113007022C0000020C000001EC000001CC0000000
S11300801AC0000018C0000016C0000011241FBED2
S1130090CFEFD0E1DEBFCDBF11E0A0E0B1E0E2E1FF
S11300A0F1E000E00BBF02C007900D92A030B10751
S11300B0D9F71ED02CC0A4CF20E030E006C046E023
S11300C04A95F1F700C02F5F3F4F28173907B8F35F
S11300D0089520E030E008C0E7E8F3E13197F1F754
S11300E000C000002F5F3F4F28173907A8F3089579
S11300F081E080936400C5E6D0E018828AE090E055
S1130100DBDF81E0888384E690E0E3DFF4CFF894DA
S1050110FFCF1B
S9030000FC