From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.58.214.226 with SMTP id od2mr8381196vec.1.1395015719608; Sun, 16 Mar 2014 17:21:59 -0700 (PDT) X-Received: by 10.50.254.3 with SMTP id ae3mr205566igd.5.1395015719489; Sun, 16 Mar 2014 17:21:59 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!w5no5244940qac.0!news-out.google.com!gi6ni227igc.0!nntp.google.com!l13no7263648iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 16 Mar 2014 17:21:58 -0700 (PDT) In-Reply-To: <20140316235424.674f5344@PC-8N-L> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=198.50.236.217; posting-account=TRgI1QoAAABSsYi-ox3Pi6N-JEKKU0cu NNTP-Posting-Host: 198.50.236.217 References: <2528b8c4-93a8-4fb8-a6a5-192493d5d616@googlegroups.com> <20140316235424.674f5344@PC-8N-L> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Interrupt-driven Usart not working in Ada, but in C working, why? From: "Rego, P." Injection-Date: Mon, 17 Mar 2014 00:21:59 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 7416 X-Received-Body-CRC: 2294303065 X-Original-Bytes: 7682 Xref: number.nntp.dca.giganews.com comp.lang.ada:185177 Date: 2014-03-16T17:21:58-07:00 List-Id: On Sunday, March 16, 2014 10:54:24 PM UTC, Oliver Kleinke wrote: > Which compiler/version? > If you're using the GNU toolchain then you can use "(avr-)objdump -S" > to generate an assembly listing that's interspersed with source code. > (Compile with debugging symbols '-g'.) > You can then compare the disassembly of both programs. `avr-gcc --version` answers me avr-gcc (GCC) 4.5.4 20120510 for GNAT GPL 2012 (20120509) I put the complete Ada objectdump part at http://is.gd/au08Fs. And the C part got from .lss in Atmel Studio I put in http://is.gd/qKpAuk. Anyway, the handle parts in both assemblies give, for the Ada part: procedure Handle_Interrupt_USART1_RX is 2e84: 1f 92 push r1 2e86: 0f 92 push r0 2e88: 0f b6 in r0, 0x3f ; 63 2e8a: 0f 92 push r0 2e8c: 00 90 5b 00 lds r0, 0x005B 2e90: 0f 92 push r0 2e92: 11 24 eor r1, r1 2e94: 2f 93 push r18 2e96: 8f 93 push r24 2e98: 9f 93 push r25 2e9a: ef 93 push r30 2e9c: ff 93 push r31 2e9e: df 93 push r29 2ea0: cf 93 push r28 2ea2: 0f 92 push r0 2ea4: cd b7 in r28, 0x3d ; 61 2ea6: de b7 in r29, 0x3e ; 62 Curr_Buffer : AVR.Byte_Type; begin Curr_Buffer := AVR.USART.Reg_USART1.UDR; 2ea8: 88 ec ldi r24, 0xC8 ; 200 2eaa: 90 e0 ldi r25, 0x00 ; 0 2eac: fc 01 movw r30, r24 2eae: 86 81 ldd r24, Z+6 ; 0x06 2eb0: 89 83 std Y+1, r24 ; 0x01 AVR.USART.Reg_USART1.UDR := Curr_Buffer; 2eb2: 88 ec ldi r24, 0xC8 ; 200 2eb4: 90 e0 ldi r25, 0x00 ; 0 2eb6: 29 81 ldd r18, Y+1 ; 0x01 2eb8: fc 01 movw r30, r24 2eba: 26 83 std Z+6, r18 ; 0x06 end Handle_Interrupt_USART1_RX; 2ebc: 00 00 nop 2ebe: 0f 90 pop r0 2ec0: cf 91 pop r28 2ec2: df 91 pop r29 2ec4: ff 91 pop r31 2ec6: ef 91 pop r30 2ec8: 9f 91 pop r25 2eca: 8f 91 pop r24 2ecc: 2f 91 pop r18 2ece: 0f 90 pop r0 2ed0: 00 92 5b 00 sts 0x005B, r0 2ed4: 0f 90 pop r0 2ed6: 0f be out 0x3f, r0 ; 63 2ed8: 0f 90 pop r0 2eda: 1f 90 pop r1 2edc: 18 95 reti and for the C part: ISR(USART1_RX_vect) { 114: 1f 92 push r1 116: 0f 92 push r0 118: 0f b6 in r0, 0x3f ; 63 11a: 0f 92 push r0 11c: 11 24 eor r1, r1 11e: 0b b6 in r0, 0x3b ; 59 120: 0f 92 push r0 122: 8f 93 push r24 124: ef 93 push r30 126: ff 93 push r31 char ReceivedByte; ReceivedByte = UDR1; 128: ee ec ldi r30, 0xCE ; 206 12a: f0 e0 ldi r31, 0x00 ; 0 12c: 80 81 ld r24, Z UDR1 = ReceivedByte; 12e: 80 83 st Z, r24 130: ff 91 pop r31 132: ef 91 pop r30 134: 8f 91 pop r24 136: 0f 90 pop r0 138: 0b be out 0x3b, r0 ; 59 13a: 0f 90 pop r0 13c: 0f be out 0x3f, r0 ; 63 13e: 0f 90 pop r0 140: 1f 90 pop r1 142: 18 95 reti > > Given that I have mapped the Usart registers correctly on AVR.USART > > package (because my JtagICE said so). > Code? Basically (you can also access the complete from ... http://is.gd/X9qVns), type USART_Control_And_Register_Status_Register_A_Type is record MPCM : Boolean; -- Multi-processor Communication Mode U2X : Boolean; -- Double the USART Transmission Speed UPE : Boolean; -- USART Parity Error DOR : Boolean; -- Data OverRun FE : Boolean; -- Frame Error UDRE : Boolean; -- USART Data Register Empty TXC : Boolean; -- USART Transmit Complete RXC : Boolean; -- USART Receive Complete end record; pragma Pack (USART_Control_And_Register_Status_Register_A_Type); for USART_Control_And_Register_Status_Register_A_Type'Size use BYTE_SIZE; type USART_Control_And_Register_Status_Register_B_Type is record TXB8 : Boolean; -- Transmit Data Bit 8 RXB8 : Boolean; -- Receive Data Bit 8 UCSZ2 : Boolean; -- Character Size Bit 2 TXEN : Boolean; -- Transmitter Enable RXEN : Boolean; -- Receiver Enable UDRIE : Boolean; -- USART Data Register Empty Interrupt Flag TXCIE : Boolean; -- Tx Complete Interrupt Flag RXCIE : Boolean; -- Rx Complete Interrupt Flag end record; pragma Pack (USART_Control_And_Register_Status_Register_B_Type); for USART_Control_And_Register_Status_Register_B_Type'Size use BYTE_SIZE; type USART_Control_And_Register_Status_Register_C_Type is record UCPOL : Boolean; -- Clock Polarity UCSZ0 : Boolean; -- Character Size Bit 0 UCSZ1 : Boolean; -- Character Size Bit 1 USBS : Boolean; -- Stop Bit Select UPM : Bit_Array_Type (0 .. 1); -- Parity Mode Bits UMSEL : Bit_Array_Type (0 .. 1); -- Mode Select end record; pragma Pack (USART_Control_And_Register_Status_Register_C_Type); for USART_Control_And_Register_Status_Register_C_Type'Size use BYTE_SIZE; type USART_Type is record UCSRA : USART_Control_And_Register_Status_Register_A_Type; UCSRB : USART_Control_And_Register_Status_Register_B_Type; UCSRC : USART_Control_And_Register_Status_Register_C_Type; Spare : Spare_Type (0 .. 7); UBRR : Byte_Array_Type (0 .. 1); -- USART Baud Rate Register L/H Bytes UDR : Byte_Type; -- USART I/O Data Register end record; pragma Pack (USART_Type); for USART_Type'Size use 7 * BYTE_SIZE; ...and ... Reg_USART1 : USART_Type; for Reg_USART1'Address use System'To_Address (16#C8#); when I do &Reg_USART1.<***> from the debugger it points correctly to each register position given by datasheet. For example, &Reg_USART1.UCSRA points me to (gdb) &avr.usart.reg_usart1.ucsra $2 = (access avr.usart.usart_control_and_register_status_register_a_type) 0x8000c8.