Loading Session2-LF/UART/Debug/UART-LF.o +2.08 KiB (8.79 KiB) File changed.No diff preview for this file type. View original file View changed file Session2-LF/UART/Debug/UART.elf +960 B (28.6 KiB) File changed.No diff preview for this file type. View original file View changed file Session2-LF/UART/Debug/UART.hex +15 −8 Original line number Diff line number Diff line Loading @@ -7,13 +7,20 @@ :100060000C945A000C945A000C945A000C945A00A8 :100070000C945A000C945A000C945A000C945A0098 :100080000C945A000C945A000C945A000C945A0088 :100090000C945A000C945A000C945A000C945A0078 :1000A00011241FBECFEFCDBFDFE3DEBF0E9476007D :1000B0000C9488000C940000E0E2F4E021E0258339 :100090000C945A000C945A000C949B000C945A0037 :1000A00011241FBECFEFCDBFDFE3DEBF0E9488006B :1000B0000C94B2000C940000E0E2F4E021E025830F :1000C0002183E0E6F8E06087BB27A92F982F872FD0 :1000D000818783E0878380EC86830895E0E6F8E0FB :1000E000948195FFFDCF8093620808956CE675E0DA :1000F00080E090E00E945C00789488E60E946E00A8 :1001000025ED88E092E0215080409040E1F7F5CF66 :04011000F894FFCF91 :1000D000818783E0878380EC868385818068858340 :1000E0000895E0E6F8E0948195FFFDCF80936208E3 :1000F0000895CF93DF93EC018881882331F0219616 :100100000E94710089918111FBCFDF91CF910895F9 :100110006CE675E080E090E00E945C00789488E6F0 :1001200091E40E94790025ED88E092E02150804022 :100130009040E1F7F4CF1F920F920FB60F92112467 :100140008F93EF93FF93E0E6F8E084818823ECF748 :1001500080916008FF91EF918F910F900FBE0F90EB :080160001F901895F894FFCFE1 :10016800446574746520657220656E2074657374C7 :020178000A007B :00000001FF Session2-LF/UART/Debug/UART.lss +141 −59 Original line number Diff line number Diff line Loading @@ -3,27 +3,31 @@ UART.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn 0 .data 00000000 00802800 00802800 00000168 2**0 0 .data 00000000 00802800 00802800 000001ee 2**0 CONTENTS, ALLOC, LOAD, DATA 1 .text 00000114 00000000 00000000 00000054 2**1 1 .text 00000168 00000000 00000000 00000074 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE 2 .comment 00000030 00000000 00000000 00000168 2**0 2 .rodata 00000012 00004168 00000168 000001dc 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .comment 00000030 00000000 00000000 000001ee 2**0 CONTENTS, READONLY 3 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 00000198 2**2 4 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 00000220 2**2 CONTENTS, READONLY 4 .debug_aranges 00000030 00000000 00000000 000001d8 2**0 5 .debug_aranges 00000040 00000000 00000000 00000260 2**0 CONTENTS, READONLY, DEBUGGING 5 .debug_info 000027ba 00000000 00000000 00000208 2**0 6 .debug_info 00002823 00000000 00000000 000002a0 2**0 CONTENTS, READONLY, DEBUGGING 6 .debug_abbrev 0000226c 00000000 00000000 000029c2 2**0 7 .debug_abbrev 000022d2 00000000 00000000 00002ac3 2**0 CONTENTS, READONLY, DEBUGGING 7 .debug_line 0000036a 00000000 00000000 00004c2e 2**0 8 .debug_line 000003c8 00000000 00000000 00004d95 2**0 CONTENTS, READONLY, DEBUGGING 8 .debug_frame 00000044 00000000 00000000 00004f98 2**2 9 .debug_frame 0000008c 00000000 00000000 00005160 2**2 CONTENTS, READONLY, DEBUGGING 9 .debug_str 000011f0 00000000 00000000 00004fdc 2**0 10 .debug_str 00001211 00000000 00000000 000051ec 2**0 CONTENTS, READONLY, DEBUGGING 10 .debug_ranges 00000020 00000000 00000000 000061cc 2**0 11 .debug_loc 000000d7 00000000 00000000 000063fd 2**0 CONTENTS, READONLY, DEBUGGING 12 .debug_ranges 00000030 00000000 00000000 000064d4 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: Loading Loading @@ -67,7 +71,7 @@ Disassembly of section .text: 8c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 90: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 94: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 98: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 98: 0c 94 9b 00 jmp 0x136 ; 0x136 <__vector_38> 9c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 000000a0 <__ctors_end>: Loading @@ -77,8 +81,8 @@ Disassembly of section .text: a6: cd bf out 0x3d, r28 ; 61 a8: df e3 ldi r29, 0x3F ; 63 aa: de bf out 0x3e, r29 ; 62 ac: 0e 94 76 00 call 0xec ; 0xec <main> b0: 0c 94 88 00 jmp 0x110 ; 0x110 <_exit> ac: 0e 94 88 00 call 0x110 ; 0x110 <main> b0: 0c 94 b2 00 jmp 0x164 ; 0x164 <_exit> 000000b4 <__bad_interrupt>: b4: 0c 94 00 00 jmp 0 ; 0x0 <__vectors> Loading @@ -87,25 +91,22 @@ Disassembly of section .text: void uart_init(unsigned long baud){ //From chapter 24.3 in datasheet //From chapter 22.3.1 in datasheet PORTB.OUTSET = (1 << 0); //Setting up TX pin as output TX_PORT.OUTSET = (1 << TX_PIN); //Setting up TX pin as output b8: e0 e2 ldi r30, 0x20 ; 32 ba: f4 e0 ldi r31, 0x04 ; 4 bc: 21 e0 ldi r18, 0x01 ; 1 be: 25 83 std Z+5, r18 ; 0x05 PORTB.DIRSET = (1 << 0); //Setting up TX pin as output TX_PORT.DIRSET = (1 << TX_PIN); //Setting up TX pin as output c0: 21 83 std Z+1, r18 ; 0x01 //USART3.BAUDH = (baud >> 8); //Shift register right by 8 bits to get the 8 high bits //USART3.BAUDL = baud; //Set baud rate without shifting to get the 8 low bits //It turns out the compiler can handle this automatically, meaning this works just as well: USART3.BAUDL = (uint8_t)baud; //Set baud rate register USART3.BAUDL = (uint8_t) baud; //Set baud rate without shifting to get the 8 low bits c2: e0 e6 ldi r30, 0x60 ; 96 c4: f8 e0 ldi r31, 0x08 ; 8 c6: 60 87 std Z+8, r22 ; 0x08 USART3.BAUDH = (uint8_t)(baud >> 8); USART3.BAUDH = (uint8_t)(baud >> 8); //Shift register right by 8 bits to get the 8 high bits c8: bb 27 eor r27, r27 ca: a9 2f mov r26, r25 cc: 98 2f mov r25, r24 Loading @@ -114,75 +115,156 @@ void uart_init(unsigned long baud){ //USART.CTRLC CMODE bits default to async, 1 stop bit, 8 bit character size USART3.CTRLC = (0x3 << 0); //Since all bits are default 0 we only need to change the character size part USART3.CTRLC = (0x3 << USART_CHSIZE0_bp); d2: 83 e0 ldi r24, 0x03 ; 3 d4: 87 83 std Z+7, r24 ; 0x07 USART3.CTRLB = (1 << USART_RXEN_bp) | (1 << USART_TXEN_bp); //Enable RX and TX //Enable RX and TX USART3.CTRLB = (1 << USART_RXEN_bp) | (1 << USART_TXEN_bp); d6: 80 ec ldi r24, 0xC0 ; 192 d8: 86 83 std Z+6, r24 ; 0x06 da: 08 95 ret 000000dc <uart_transmit>: //Enable interrupts on incoming data USART3.CTRLA |= (1 << USART_RXCIE_bp); da: 85 81 ldd r24, Z+5 ; 0x05 dc: 80 68 ori r24, 0x80 ; 128 de: 85 83 std Z+5, r24 ; 0x05 e0: 08 95 ret 000000e2 <uart_transmit>: //In this function we will be send data. //First we should check that there isn't already data being sent // if there is, we should probably wait for it to finish first while (!(USART3.STATUS & (1 << USART_DREIF_bp))){ dc: e0 e6 ldi r30, 0x60 ; 96 de: f8 e0 ldi r31, 0x08 ; 8 e0: 94 81 ldd r25, Z+4 ; 0x04 e2: 95 ff sbrs r25, 5 e4: fd cf rjmp .-6 ; 0xe0 <uart_transmit+0x4> e2: e0 e6 ldi r30, 0x60 ; 96 e4: f8 e0 ldi r31, 0x08 ; 8 e6: 94 81 ldd r25, Z+4 ; 0x04 e8: 95 ff sbrs r25, 5 ea: fd cf rjmp .-6 ; 0xe6 <uart_transmit+0x4> //wait for previous transmit to finish }; //Put our new data into se sending register //Put our new data into tx data register USART3.TXDATAL = data; e6: 80 93 62 08 sts 0x0862, r24 ; 0x800862 <__TEXT_REGION_LENGTH__+0x700862> ea: 08 95 ret ec: 80 93 62 08 sts 0x0862, r24 ; 0x800862 <__TEXT_REGION_LENGTH__+0x700862> f0: 08 95 ret 000000f2 <uart_transmit_string>: } 000000ec <main>: //To send a string we can do this void uart_transmit_string(char* data) { f2: cf 93 push r28 f4: df 93 push r29 f6: ec 01 movw r28, r24 while (*data != '\0') { f8: 88 81 ld r24, Y fa: 88 23 and r24, r24 fc: 31 f0 breq .+12 ; 0x10a <uart_transmit_string+0x18> fe: 21 96 adiw r28, 0x01 ; 1 uart_transmit(*data); 100: 0e 94 71 00 call 0xe2 ; 0xe2 <uart_transmit> } //To send a string we can do this void uart_transmit_string(char* data) { while (*data != '\0') { 104: 89 91 ld r24, Y+ 106: 81 11 cpse r24, r1 108: fb cf rjmp .-10 ; 0x100 <uart_transmit_string+0xe> uart_transmit(*data); data++; } } 10a: df 91 pop r29 10c: cf 91 pop r28 10e: 08 95 ret 00000110 <main>: int main(void) { //Initialize the UART with our function. //We will be using a baudrate of 9600 (defined as BAUD_9600 at the top of the file) uart_init(BAUD_9600); ec: 6c e6 ldi r22, 0x6C ; 108 ee: 75 e0 ldi r23, 0x05 ; 5 f0: 80 e0 ldi r24, 0x00 ; 0 f2: 90 e0 ldi r25, 0x00 ; 0 f4: 0e 94 5c 00 call 0xb8 ; 0xb8 <uart_init> 110: 6c e6 ldi r22, 0x6C ; 108 112: 75 e0 ldi r23, 0x05 ; 5 114: 80 e0 ldi r24, 0x00 ; 0 116: 90 e0 ldi r25, 0x00 ; 0 118: 0e 94 5c 00 call 0xb8 ; 0xb8 <uart_init> sei(); //Enable inerrupt, important for anything here to work f8: 78 94 sei 11c: 78 94 sei while (1) { //We don't really need to do anything here. //the ISR will handle receiving. uart_transmit('h'); fa: 88 e6 ldi r24, 0x68 ; 104 fc: 0e 94 6e 00 call 0xdc ; 0xdc <uart_transmit> uart_transmit_string("Dette er en test\n"); 11e: 88 e6 ldi r24, 0x68 ; 104 120: 91 e4 ldi r25, 0x41 ; 65 122: 0e 94 79 00 call 0xf2 ; 0xf2 <uart_transmit_string> #else //round up by default __ticks_dc = (uint32_t)(ceil(fabs(__tmp))); #endif __builtin_avr_delay_cycles(__ticks_dc); 100: 25 ed ldi r18, 0xD5 ; 213 102: 88 e0 ldi r24, 0x08 ; 8 104: 92 e0 ldi r25, 0x02 ; 2 106: 21 50 subi r18, 0x01 ; 1 108: 80 40 sbci r24, 0x00 ; 0 10a: 90 40 sbci r25, 0x00 ; 0 10c: e1 f7 brne .-8 ; 0x106 <main+0x1a> 10e: f5 cf rjmp .-22 ; 0xfa <main+0xe> 00000110 <_exit>: 110: f8 94 cli 00000112 <__stop_program>: 112: ff cf rjmp .-2 ; 0x112 <__stop_program> 126: 25 ed ldi r18, 0xD5 ; 213 128: 88 e0 ldi r24, 0x08 ; 8 12a: 92 e0 ldi r25, 0x02 ; 2 12c: 21 50 subi r18, 0x01 ; 1 12e: 80 40 sbci r24, 0x00 ; 0 130: 90 40 sbci r25, 0x00 ; 0 132: e1 f7 brne .-8 ; 0x12c <main+0x1c> 134: f4 cf rjmp .-24 ; 0x11e <main+0xe> 00000136 <__vector_38>: } } //Interrupt service routine for the receiver. ISR (USART3_RXC_vect) { 136: 1f 92 push r1 138: 0f 92 push r0 13a: 0f b6 in r0, 0x3f ; 63 13c: 0f 92 push r0 13e: 11 24 eor r1, r1 140: 8f 93 push r24 142: ef 93 push r30 144: ff 93 push r31 //In the interrupt we will read the data in the receive buffer //First we should check that new data has arrived the receive buffer while (!(USART3.STATUS & (1 << USART_RXCIF_bp))){ 146: e0 e6 ldi r30, 0x60 ; 96 148: f8 e0 ldi r31, 0x08 ; 8 14a: 84 81 ldd r24, Z+4 ; 0x04 14c: 88 23 and r24, r24 14e: ec f7 brge .-6 ; 0x14a <__vector_38+0x14> //wait for previous transmit to finish }; //Store the data in a temporarily variable uint8_t tmp = USART3.RXDATAL; 150: 80 91 60 08 lds r24, 0x0860 ; 0x800860 <__TEXT_REGION_LENGTH__+0x700860> 154: ff 91 pop r31 156: ef 91 pop r30 158: 8f 91 pop r24 15a: 0f 90 pop r0 15c: 0f be out 0x3f, r0 ; 63 15e: 0f 90 pop r0 160: 1f 90 pop r1 162: 18 95 reti 00000164 <_exit>: 164: f8 94 cli 00000166 <__stop_program>: 166: ff cf rjmp .-2 ; 0x166 <__stop_program> Session2-LF/UART/Debug/UART.map +41 −33 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ END GROUP .rela.plt *(.rela.plt) .text 0x00000000 0x114 .text 0x00000000 0x168 *(.vectors) .vectors 0x00000000 0xa0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o 0x00000000 __vector_default Loading Loading @@ -208,7 +208,6 @@ END GROUP *(.init9) *(.text) .text 0x000000b4 0x4 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o 0x000000b4 __vector_38 0x000000b4 __vector_22 0x000000b4 __vector_28 0x000000b4 __vector_1 Loading Loading @@ -251,18 +250,24 @@ END GROUP 0x000000b8 . = ALIGN (0x2) *(.text.*) .text.uart_init 0x000000b8 0x24 UART-LF.o 0x000000b8 0x2a UART-LF.o 0x000000b8 uart_init .text.uart_transmit 0x000000dc 0x10 UART-LF.o 0x000000dc uart_transmit .text.main 0x000000ec 0x24 UART-LF.o 0x000000ec main 0x00000110 . = ALIGN (0x2) 0x000000e2 0x10 UART-LF.o 0x000000e2 uart_transmit .text.uart_transmit_string 0x000000f2 0x1e UART-LF.o 0x000000f2 uart_transmit_string .text.main 0x00000110 0x26 UART-LF.o 0x00000110 main .text.__vector_38 0x00000136 0x2e UART-LF.o 0x00000136 __vector_38 0x00000164 . = ALIGN (0x2) *(.fini9) .fini9 0x00000110 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o) 0x00000110 _exit 0x00000110 exit .fini9 0x00000164 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o) 0x00000164 _exit 0x00000164 exit *(.fini9) *(.fini8) *(.fini8) Loading @@ -281,16 +286,18 @@ END GROUP *(.fini1) *(.fini1) *(.fini0) .fini0 0x00000110 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o) .fini0 0x00000164 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o) *(.fini0) 0x00000114 _etext = . 0x00000168 _etext = . .rodata .rodata 0x00004168 0x12 load address 0x00000168 *(.rodata) *(.rodata*) .rodata.str1.1 0x00004168 0x12 UART-LF.o *(.gnu.linkonce.r*) .data 0x00802800 0x0 load address 0x00000114 .data 0x00802800 0x0 load address 0x0000017a [!provide] PROVIDE (__data_start, .) *(.data) *(.data*) Loading @@ -305,8 +312,8 @@ END GROUP *(.bss*) *(COMMON) [!provide] PROVIDE (__bss_end, .) 0x00000114 __data_load_start = LOADADDR (.data) 0x00000114 __data_load_end = (__data_load_start + SIZEOF (.data)) 0x0000017a __data_load_start = LOADADDR (.data) 0x0000017a __data_load_end = (__data_load_start + SIZEOF (.data)) .noinit 0x00802800 0x0 [!provide] PROVIDE (__noinit_start, .) Loading Loading @@ -377,41 +384,42 @@ END GROUP .debug_sfnames *(.debug_sfnames) .debug_aranges 0x00000000 0x30 .debug_aranges 0x00000000 0x40 *(.debug_aranges) .debug_aranges 0x00000000 0x30 UART-LF.o 0x00000000 0x40 UART-LF.o .debug_pubnames *(.debug_pubnames) .debug_info 0x00000000 0x27ba .debug_info 0x00000000 0x2823 *(.debug_info .gnu.linkonce.wi.*) .debug_info 0x00000000 0x22b7 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o .debug_info 0x000022b7 0x503 UART-LF.o .debug_info 0x000022b7 0x56c UART-LF.o .debug_abbrev 0x00000000 0x226c .debug_abbrev 0x00000000 0x22d2 *(.debug_abbrev) .debug_abbrev 0x00000000 0x20e0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o .debug_abbrev 0x000020e0 0x18c UART-LF.o .debug_abbrev 0x000020e0 0x1f2 UART-LF.o .debug_line 0x00000000 0x36a .debug_line 0x00000000 0x3c8 *(.debug_line .debug_line.* .debug_line_end) .debug_line 0x00000000 0x187 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o .debug_line 0x00000187 0x1e3 UART-LF.o .debug_line 0x00000187 0x241 UART-LF.o .debug_frame 0x00000000 0x44 .debug_frame 0x00000000 0x8c *(.debug_frame) .debug_frame 0x00000000 0x44 UART-LF.o .debug_frame 0x00000000 0x8c UART-LF.o .debug_str 0x00000000 0x11f0 .debug_str 0x00000000 0x1211 *(.debug_str) .debug_str 0x00000000 0xe5d C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o .debug_str 0x00000e5d 0x393 UART-LF.o 0x3cc (size before relaxing) .debug_str 0x00000e5d 0x3b4 UART-LF.o 0x3ed (size before relaxing) .debug_loc .debug_loc 0x00000000 0xd7 *(.debug_loc) .debug_loc 0x00000000 0xd7 UART-LF.o .debug_macinfo *(.debug_macinfo) Loading @@ -431,9 +439,9 @@ END GROUP .debug_pubtypes *(.debug_pubtypes) .debug_ranges 0x00000000 0x20 .debug_ranges 0x00000000 0x30 *(.debug_ranges) .debug_ranges 0x00000000 0x20 UART-LF.o .debug_ranges 0x00000000 0x30 UART-LF.o .debug_macro *(.debug_macro) Loading Loading
Session2-LF/UART/Debug/UART-LF.o +2.08 KiB (8.79 KiB) File changed.No diff preview for this file type. View original file View changed file
Session2-LF/UART/Debug/UART.elf +960 B (28.6 KiB) File changed.No diff preview for this file type. View original file View changed file
Session2-LF/UART/Debug/UART.hex +15 −8 Original line number Diff line number Diff line Loading @@ -7,13 +7,20 @@ :100060000C945A000C945A000C945A000C945A00A8 :100070000C945A000C945A000C945A000C945A0098 :100080000C945A000C945A000C945A000C945A0088 :100090000C945A000C945A000C945A000C945A0078 :1000A00011241FBECFEFCDBFDFE3DEBF0E9476007D :1000B0000C9488000C940000E0E2F4E021E0258339 :100090000C945A000C945A000C949B000C945A0037 :1000A00011241FBECFEFCDBFDFE3DEBF0E9488006B :1000B0000C94B2000C940000E0E2F4E021E025830F :1000C0002183E0E6F8E06087BB27A92F982F872FD0 :1000D000818783E0878380EC86830895E0E6F8E0FB :1000E000948195FFFDCF8093620808956CE675E0DA :1000F00080E090E00E945C00789488E60E946E00A8 :1001000025ED88E092E0215080409040E1F7F5CF66 :04011000F894FFCF91 :1000D000818783E0878380EC868385818068858340 :1000E0000895E0E6F8E0948195FFFDCF80936208E3 :1000F0000895CF93DF93EC018881882331F0219616 :100100000E94710089918111FBCFDF91CF910895F9 :100110006CE675E080E090E00E945C00789488E6F0 :1001200091E40E94790025ED88E092E02150804022 :100130009040E1F7F4CF1F920F920FB60F92112467 :100140008F93EF93FF93E0E6F8E084818823ECF748 :1001500080916008FF91EF918F910F900FBE0F90EB :080160001F901895F894FFCFE1 :10016800446574746520657220656E2074657374C7 :020178000A007B :00000001FF
Session2-LF/UART/Debug/UART.lss +141 −59 Original line number Diff line number Diff line Loading @@ -3,27 +3,31 @@ UART.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn 0 .data 00000000 00802800 00802800 00000168 2**0 0 .data 00000000 00802800 00802800 000001ee 2**0 CONTENTS, ALLOC, LOAD, DATA 1 .text 00000114 00000000 00000000 00000054 2**1 1 .text 00000168 00000000 00000000 00000074 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE 2 .comment 00000030 00000000 00000000 00000168 2**0 2 .rodata 00000012 00004168 00000168 000001dc 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .comment 00000030 00000000 00000000 000001ee 2**0 CONTENTS, READONLY 3 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 00000198 2**2 4 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 00000220 2**2 CONTENTS, READONLY 4 .debug_aranges 00000030 00000000 00000000 000001d8 2**0 5 .debug_aranges 00000040 00000000 00000000 00000260 2**0 CONTENTS, READONLY, DEBUGGING 5 .debug_info 000027ba 00000000 00000000 00000208 2**0 6 .debug_info 00002823 00000000 00000000 000002a0 2**0 CONTENTS, READONLY, DEBUGGING 6 .debug_abbrev 0000226c 00000000 00000000 000029c2 2**0 7 .debug_abbrev 000022d2 00000000 00000000 00002ac3 2**0 CONTENTS, READONLY, DEBUGGING 7 .debug_line 0000036a 00000000 00000000 00004c2e 2**0 8 .debug_line 000003c8 00000000 00000000 00004d95 2**0 CONTENTS, READONLY, DEBUGGING 8 .debug_frame 00000044 00000000 00000000 00004f98 2**2 9 .debug_frame 0000008c 00000000 00000000 00005160 2**2 CONTENTS, READONLY, DEBUGGING 9 .debug_str 000011f0 00000000 00000000 00004fdc 2**0 10 .debug_str 00001211 00000000 00000000 000051ec 2**0 CONTENTS, READONLY, DEBUGGING 10 .debug_ranges 00000020 00000000 00000000 000061cc 2**0 11 .debug_loc 000000d7 00000000 00000000 000063fd 2**0 CONTENTS, READONLY, DEBUGGING 12 .debug_ranges 00000030 00000000 00000000 000064d4 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: Loading Loading @@ -67,7 +71,7 @@ Disassembly of section .text: 8c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 90: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 94: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 98: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 98: 0c 94 9b 00 jmp 0x136 ; 0x136 <__vector_38> 9c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt> 000000a0 <__ctors_end>: Loading @@ -77,8 +81,8 @@ Disassembly of section .text: a6: cd bf out 0x3d, r28 ; 61 a8: df e3 ldi r29, 0x3F ; 63 aa: de bf out 0x3e, r29 ; 62 ac: 0e 94 76 00 call 0xec ; 0xec <main> b0: 0c 94 88 00 jmp 0x110 ; 0x110 <_exit> ac: 0e 94 88 00 call 0x110 ; 0x110 <main> b0: 0c 94 b2 00 jmp 0x164 ; 0x164 <_exit> 000000b4 <__bad_interrupt>: b4: 0c 94 00 00 jmp 0 ; 0x0 <__vectors> Loading @@ -87,25 +91,22 @@ Disassembly of section .text: void uart_init(unsigned long baud){ //From chapter 24.3 in datasheet //From chapter 22.3.1 in datasheet PORTB.OUTSET = (1 << 0); //Setting up TX pin as output TX_PORT.OUTSET = (1 << TX_PIN); //Setting up TX pin as output b8: e0 e2 ldi r30, 0x20 ; 32 ba: f4 e0 ldi r31, 0x04 ; 4 bc: 21 e0 ldi r18, 0x01 ; 1 be: 25 83 std Z+5, r18 ; 0x05 PORTB.DIRSET = (1 << 0); //Setting up TX pin as output TX_PORT.DIRSET = (1 << TX_PIN); //Setting up TX pin as output c0: 21 83 std Z+1, r18 ; 0x01 //USART3.BAUDH = (baud >> 8); //Shift register right by 8 bits to get the 8 high bits //USART3.BAUDL = baud; //Set baud rate without shifting to get the 8 low bits //It turns out the compiler can handle this automatically, meaning this works just as well: USART3.BAUDL = (uint8_t)baud; //Set baud rate register USART3.BAUDL = (uint8_t) baud; //Set baud rate without shifting to get the 8 low bits c2: e0 e6 ldi r30, 0x60 ; 96 c4: f8 e0 ldi r31, 0x08 ; 8 c6: 60 87 std Z+8, r22 ; 0x08 USART3.BAUDH = (uint8_t)(baud >> 8); USART3.BAUDH = (uint8_t)(baud >> 8); //Shift register right by 8 bits to get the 8 high bits c8: bb 27 eor r27, r27 ca: a9 2f mov r26, r25 cc: 98 2f mov r25, r24 Loading @@ -114,75 +115,156 @@ void uart_init(unsigned long baud){ //USART.CTRLC CMODE bits default to async, 1 stop bit, 8 bit character size USART3.CTRLC = (0x3 << 0); //Since all bits are default 0 we only need to change the character size part USART3.CTRLC = (0x3 << USART_CHSIZE0_bp); d2: 83 e0 ldi r24, 0x03 ; 3 d4: 87 83 std Z+7, r24 ; 0x07 USART3.CTRLB = (1 << USART_RXEN_bp) | (1 << USART_TXEN_bp); //Enable RX and TX //Enable RX and TX USART3.CTRLB = (1 << USART_RXEN_bp) | (1 << USART_TXEN_bp); d6: 80 ec ldi r24, 0xC0 ; 192 d8: 86 83 std Z+6, r24 ; 0x06 da: 08 95 ret 000000dc <uart_transmit>: //Enable interrupts on incoming data USART3.CTRLA |= (1 << USART_RXCIE_bp); da: 85 81 ldd r24, Z+5 ; 0x05 dc: 80 68 ori r24, 0x80 ; 128 de: 85 83 std Z+5, r24 ; 0x05 e0: 08 95 ret 000000e2 <uart_transmit>: //In this function we will be send data. //First we should check that there isn't already data being sent // if there is, we should probably wait for it to finish first while (!(USART3.STATUS & (1 << USART_DREIF_bp))){ dc: e0 e6 ldi r30, 0x60 ; 96 de: f8 e0 ldi r31, 0x08 ; 8 e0: 94 81 ldd r25, Z+4 ; 0x04 e2: 95 ff sbrs r25, 5 e4: fd cf rjmp .-6 ; 0xe0 <uart_transmit+0x4> e2: e0 e6 ldi r30, 0x60 ; 96 e4: f8 e0 ldi r31, 0x08 ; 8 e6: 94 81 ldd r25, Z+4 ; 0x04 e8: 95 ff sbrs r25, 5 ea: fd cf rjmp .-6 ; 0xe6 <uart_transmit+0x4> //wait for previous transmit to finish }; //Put our new data into se sending register //Put our new data into tx data register USART3.TXDATAL = data; e6: 80 93 62 08 sts 0x0862, r24 ; 0x800862 <__TEXT_REGION_LENGTH__+0x700862> ea: 08 95 ret ec: 80 93 62 08 sts 0x0862, r24 ; 0x800862 <__TEXT_REGION_LENGTH__+0x700862> f0: 08 95 ret 000000f2 <uart_transmit_string>: } 000000ec <main>: //To send a string we can do this void uart_transmit_string(char* data) { f2: cf 93 push r28 f4: df 93 push r29 f6: ec 01 movw r28, r24 while (*data != '\0') { f8: 88 81 ld r24, Y fa: 88 23 and r24, r24 fc: 31 f0 breq .+12 ; 0x10a <uart_transmit_string+0x18> fe: 21 96 adiw r28, 0x01 ; 1 uart_transmit(*data); 100: 0e 94 71 00 call 0xe2 ; 0xe2 <uart_transmit> } //To send a string we can do this void uart_transmit_string(char* data) { while (*data != '\0') { 104: 89 91 ld r24, Y+ 106: 81 11 cpse r24, r1 108: fb cf rjmp .-10 ; 0x100 <uart_transmit_string+0xe> uart_transmit(*data); data++; } } 10a: df 91 pop r29 10c: cf 91 pop r28 10e: 08 95 ret 00000110 <main>: int main(void) { //Initialize the UART with our function. //We will be using a baudrate of 9600 (defined as BAUD_9600 at the top of the file) uart_init(BAUD_9600); ec: 6c e6 ldi r22, 0x6C ; 108 ee: 75 e0 ldi r23, 0x05 ; 5 f0: 80 e0 ldi r24, 0x00 ; 0 f2: 90 e0 ldi r25, 0x00 ; 0 f4: 0e 94 5c 00 call 0xb8 ; 0xb8 <uart_init> 110: 6c e6 ldi r22, 0x6C ; 108 112: 75 e0 ldi r23, 0x05 ; 5 114: 80 e0 ldi r24, 0x00 ; 0 116: 90 e0 ldi r25, 0x00 ; 0 118: 0e 94 5c 00 call 0xb8 ; 0xb8 <uart_init> sei(); //Enable inerrupt, important for anything here to work f8: 78 94 sei 11c: 78 94 sei while (1) { //We don't really need to do anything here. //the ISR will handle receiving. uart_transmit('h'); fa: 88 e6 ldi r24, 0x68 ; 104 fc: 0e 94 6e 00 call 0xdc ; 0xdc <uart_transmit> uart_transmit_string("Dette er en test\n"); 11e: 88 e6 ldi r24, 0x68 ; 104 120: 91 e4 ldi r25, 0x41 ; 65 122: 0e 94 79 00 call 0xf2 ; 0xf2 <uart_transmit_string> #else //round up by default __ticks_dc = (uint32_t)(ceil(fabs(__tmp))); #endif __builtin_avr_delay_cycles(__ticks_dc); 100: 25 ed ldi r18, 0xD5 ; 213 102: 88 e0 ldi r24, 0x08 ; 8 104: 92 e0 ldi r25, 0x02 ; 2 106: 21 50 subi r18, 0x01 ; 1 108: 80 40 sbci r24, 0x00 ; 0 10a: 90 40 sbci r25, 0x00 ; 0 10c: e1 f7 brne .-8 ; 0x106 <main+0x1a> 10e: f5 cf rjmp .-22 ; 0xfa <main+0xe> 00000110 <_exit>: 110: f8 94 cli 00000112 <__stop_program>: 112: ff cf rjmp .-2 ; 0x112 <__stop_program> 126: 25 ed ldi r18, 0xD5 ; 213 128: 88 e0 ldi r24, 0x08 ; 8 12a: 92 e0 ldi r25, 0x02 ; 2 12c: 21 50 subi r18, 0x01 ; 1 12e: 80 40 sbci r24, 0x00 ; 0 130: 90 40 sbci r25, 0x00 ; 0 132: e1 f7 brne .-8 ; 0x12c <main+0x1c> 134: f4 cf rjmp .-24 ; 0x11e <main+0xe> 00000136 <__vector_38>: } } //Interrupt service routine for the receiver. ISR (USART3_RXC_vect) { 136: 1f 92 push r1 138: 0f 92 push r0 13a: 0f b6 in r0, 0x3f ; 63 13c: 0f 92 push r0 13e: 11 24 eor r1, r1 140: 8f 93 push r24 142: ef 93 push r30 144: ff 93 push r31 //In the interrupt we will read the data in the receive buffer //First we should check that new data has arrived the receive buffer while (!(USART3.STATUS & (1 << USART_RXCIF_bp))){ 146: e0 e6 ldi r30, 0x60 ; 96 148: f8 e0 ldi r31, 0x08 ; 8 14a: 84 81 ldd r24, Z+4 ; 0x04 14c: 88 23 and r24, r24 14e: ec f7 brge .-6 ; 0x14a <__vector_38+0x14> //wait for previous transmit to finish }; //Store the data in a temporarily variable uint8_t tmp = USART3.RXDATAL; 150: 80 91 60 08 lds r24, 0x0860 ; 0x800860 <__TEXT_REGION_LENGTH__+0x700860> 154: ff 91 pop r31 156: ef 91 pop r30 158: 8f 91 pop r24 15a: 0f 90 pop r0 15c: 0f be out 0x3f, r0 ; 63 15e: 0f 90 pop r0 160: 1f 90 pop r1 162: 18 95 reti 00000164 <_exit>: 164: f8 94 cli 00000166 <__stop_program>: 166: ff cf rjmp .-2 ; 0x166 <__stop_program>
Session2-LF/UART/Debug/UART.map +41 −33 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ END GROUP .rela.plt *(.rela.plt) .text 0x00000000 0x114 .text 0x00000000 0x168 *(.vectors) .vectors 0x00000000 0xa0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o 0x00000000 __vector_default Loading Loading @@ -208,7 +208,6 @@ END GROUP *(.init9) *(.text) .text 0x000000b4 0x4 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o 0x000000b4 __vector_38 0x000000b4 __vector_22 0x000000b4 __vector_28 0x000000b4 __vector_1 Loading Loading @@ -251,18 +250,24 @@ END GROUP 0x000000b8 . = ALIGN (0x2) *(.text.*) .text.uart_init 0x000000b8 0x24 UART-LF.o 0x000000b8 0x2a UART-LF.o 0x000000b8 uart_init .text.uart_transmit 0x000000dc 0x10 UART-LF.o 0x000000dc uart_transmit .text.main 0x000000ec 0x24 UART-LF.o 0x000000ec main 0x00000110 . = ALIGN (0x2) 0x000000e2 0x10 UART-LF.o 0x000000e2 uart_transmit .text.uart_transmit_string 0x000000f2 0x1e UART-LF.o 0x000000f2 uart_transmit_string .text.main 0x00000110 0x26 UART-LF.o 0x00000110 main .text.__vector_38 0x00000136 0x2e UART-LF.o 0x00000136 __vector_38 0x00000164 . = ALIGN (0x2) *(.fini9) .fini9 0x00000110 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o) 0x00000110 _exit 0x00000110 exit .fini9 0x00000164 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o) 0x00000164 _exit 0x00000164 exit *(.fini9) *(.fini8) *(.fini8) Loading @@ -281,16 +286,18 @@ END GROUP *(.fini1) *(.fini1) *(.fini0) .fini0 0x00000110 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o) .fini0 0x00000164 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrxmega3\libgcc.a(_exit.o) *(.fini0) 0x00000114 _etext = . 0x00000168 _etext = . .rodata .rodata 0x00004168 0x12 load address 0x00000168 *(.rodata) *(.rodata*) .rodata.str1.1 0x00004168 0x12 UART-LF.o *(.gnu.linkonce.r*) .data 0x00802800 0x0 load address 0x00000114 .data 0x00802800 0x0 load address 0x0000017a [!provide] PROVIDE (__data_start, .) *(.data) *(.data*) Loading @@ -305,8 +312,8 @@ END GROUP *(.bss*) *(COMMON) [!provide] PROVIDE (__bss_end, .) 0x00000114 __data_load_start = LOADADDR (.data) 0x00000114 __data_load_end = (__data_load_start + SIZEOF (.data)) 0x0000017a __data_load_start = LOADADDR (.data) 0x0000017a __data_load_end = (__data_load_start + SIZEOF (.data)) .noinit 0x00802800 0x0 [!provide] PROVIDE (__noinit_start, .) Loading Loading @@ -377,41 +384,42 @@ END GROUP .debug_sfnames *(.debug_sfnames) .debug_aranges 0x00000000 0x30 .debug_aranges 0x00000000 0x40 *(.debug_aranges) .debug_aranges 0x00000000 0x30 UART-LF.o 0x00000000 0x40 UART-LF.o .debug_pubnames *(.debug_pubnames) .debug_info 0x00000000 0x27ba .debug_info 0x00000000 0x2823 *(.debug_info .gnu.linkonce.wi.*) .debug_info 0x00000000 0x22b7 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o .debug_info 0x000022b7 0x503 UART-LF.o .debug_info 0x000022b7 0x56c UART-LF.o .debug_abbrev 0x00000000 0x226c .debug_abbrev 0x00000000 0x22d2 *(.debug_abbrev) .debug_abbrev 0x00000000 0x20e0 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o .debug_abbrev 0x000020e0 0x18c UART-LF.o .debug_abbrev 0x000020e0 0x1f2 UART-LF.o .debug_line 0x00000000 0x36a .debug_line 0x00000000 0x3c8 *(.debug_line .debug_line.* .debug_line_end) .debug_line 0x00000000 0x187 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o .debug_line 0x00000187 0x1e3 UART-LF.o .debug_line 0x00000187 0x241 UART-LF.o .debug_frame 0x00000000 0x44 .debug_frame 0x00000000 0x8c *(.debug_frame) .debug_frame 0x00000000 0x44 UART-LF.o .debug_frame 0x00000000 0x8c UART-LF.o .debug_str 0x00000000 0x11f0 .debug_str 0x00000000 0x1211 *(.debug_str) .debug_str 0x00000000 0xe5d C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.150/gcc/dev/atmega4809/avrxmega3/crtatmega4809.o .debug_str 0x00000e5d 0x393 UART-LF.o 0x3cc (size before relaxing) .debug_str 0x00000e5d 0x3b4 UART-LF.o 0x3ed (size before relaxing) .debug_loc .debug_loc 0x00000000 0xd7 *(.debug_loc) .debug_loc 0x00000000 0xd7 UART-LF.o .debug_macinfo *(.debug_macinfo) Loading @@ -431,9 +439,9 @@ END GROUP .debug_pubtypes *(.debug_pubtypes) .debug_ranges 0x00000000 0x20 .debug_ranges 0x00000000 0x30 *(.debug_ranges) .debug_ranges 0x00000000 0x20 UART-LF.o .debug_ranges 0x00000000 0x30 UART-LF.o .debug_macro *(.debug_macro) Loading