avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] mega32 timer 2 confused


From: Klaus Rudolph
Subject: Re: [avr-chat] mega32 timer 2 confused
Date: Wed, 07 Mar 2012 21:55:19 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Hi Thomas,

thanks for the ideas, but the solution is quite simple:

I linked without -mmcu option which defaults to 8515 device without any
warning or error.

The result is a broken vector table but the rest of the prog is running
as expected. This makes finding the problem a bit hard.

Looking in the disassembly also looks well, but only on the first view:

00000000 <__vectors>:
   0:   0c c0           rjmp    .+24            ; 0x1a <__ctors_end>
   2:   27 c0           rjmp    .+78            ; 0x52 <__bad_interrupt>
   4:   26 c0           rjmp    .+76            ; 0x52 <__bad_interrupt>
   6:   25 c0           rjmp    .+74            ; 0x52 <__bad_interrupt>
   8:   b0 c2           rjmp    .+1376          ; 0x56a <__vector_4>
   a:   23 c0           rjmp    .+70            ; 0x52 <__bad_interrupt>
   c:   22 c0           rjmp    .+68            ; 0x52 <__bad_interrupt>
   e:   21 c0           rjmp    .+66            ; 0x52 <__bad_interrupt>
  10:   20 c0           rjmp    .+64            ; 0x52 <__bad_interrupt>
  12:   1f c0           rjmp    .+62            ; 0x52 <__bad_interrupt>
  14:   1e c0           rjmp    .+60            ; 0x52 <__bad_interrupt>
  16:   1d c0           rjmp    .+58            ; 0x52 <__bad_interrupt>
  18:   1c c0           rjmp    .+56            ; 0x52 <__bad_interrupt>


The vector number is ok and also the offset is ok. Yes, but the second
view gives the solution: Each vector only contains 2 bytes instead of 4.
This shifts all vectors but the reset vector is ok.

Nice mistake!

The correct table looks like that:00000000 <__vectors>:
   0:   0c 94 2a 00     jmp     0x54    ; 0x54 <__ctors_end>
   4:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
   8:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
   c:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  10:   0c 94 d4 02     jmp     0x5a8   ; 0x5a8 <__vector_4>
  14:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  18:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  1c:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  20:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  24:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  28:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  2c:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  30:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  34:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  38:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>
  3c:   0c 94 47 00     jmp     0x8e    ; 0x8e <__bad_interrupt>


In hope you will never do such stupid things :-)

Regards
 Klaus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]