bugAVR C Runtime Library - Bugs: bug #29964, Possible Incorrect Interrupt...

 
 

bug #29964: Possible Incorrect Interrupt Vector Addresses for mega168

Submitted by:  Jose Torres <capek>
Submitted on:  Wed 26 May 2010 03:40:05 AM UTC  
Votes:  100  
 
Category: HeaderSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Header files
Status: InvalidPercent Complete: 0%
Assigned to: NoneOpen/Closed: Closed
Release: 1.6.7Fixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 26 May 2010 05:17:44 AM UTC, comment #3:

Hi Jose,

for a simple test, you could just compile and link an empty main(),
and run it through the disassembler. That will show you the vector
table is fine for both devices. Btw., be assured if they weren't, the
Arduino folks would have told us long before. ;-)

> Are the addresses properly computed because of the following?


_VECTORS_SIZE is part of the story: if you look into gcrt1.S, you'll
notice it determines how many vectors will actually be emitted.

The size logic itself is hidden behind the XJMP macro which comes from
common/macros.inc. It uses the (misnamed) macro _AVR_MEGA_ which is
set by the compiler to determine whether to emit a JMP or RJMP
instruction (which in turn determines the size of a vector table
slot). This should use _AVR_HAVE_JMP_CALL_ instead, but this one is
only available starting with GCC 4.3, and we'd like to be backwards
compatible. We should perhaps check for the GCC version, and then use
wither _AVR_MEGA_ or _AVR_HAVE_JMP_CALL_, depending on the
version, so _AVR_MEGA_ could eventually be retired. Feel free to
submit a patch for this if you like (preferrably, tested against
different compiler versions... ;-).

Joerg Wunsch <joerg_wunsch>
Project Administrator
Wed 26 May 2010 04:36:08 AM UTC, comment #2:

Hi Joerg,

For the mega88 the following are a sampling of interrupt vector addresses:
0x000 rjmp RESET ; Reset Handler
0x001 rjmp EXT_INT0 ; IRQ0 Handler
0x002 rjmp EXT_INT1 ; IRQ1 Handler
0x003 rjmp PCINT0 ; PCINT0 Handler
0x004 rjmp PCINT1 ; PCINT1 Handler
0x005 rjmp PCINT2 ; PCINT2 Handler
0x006 rjmp WDT ; Watchdog Timer Handler
0x007 rjmp TIM2_COMPA ; Timer2 Compare A Handler
0X008 rjmp TIM2_COMPB ; Timer2 Compare B Handler

This is in line with what iomx8.h states.

I am unsure how _VECTOR() computes the addresses but they just don't seem to line up for the mega168.

Are the addresses properly computed because of the following?
#if defined (_AVR_ATmega168_)
# define _VECTORS_SIZE 104
#else
# define _VECTORS_SIZE 52
#endif

#endif /* AVR_IOM8_H */

Regards,
Jose

Jose Torres <capek>
Wed 26 May 2010 04:10:47 AM UTC, comment #1:

What do you think is incorrect?

Joerg Wunsch <joerg_wunsch>
Project Administrator
Wed 26 May 2010 03:40:05 AM UTC, original submission:

I have been running into an issue using interrupts with avr-libc 1.6.7 and an atmega168.

According to the mega168 datasheet the following are a sampling of the interrupt vector addresses:

Address Labels Code Comments
0x0000 jmp RESET ; Reset Handler
0x0002 jmp EXT_INT0 ; IRQ0 Handler
0x0004 jmp EXT_INT1 ; IRQ1 Handler
0x0006 jmp PCINT0 ; PCINT0 Handler
0x0008 jmp PCINT1 ; PCINT1 Handler
0x000A jmp PCINT2 ; PCINT2 Handler
0x000C jmp WDT ; Watchdog Timer Handler
0x000E jmp TIM2_COMPA ; Timer2 Compare A Handler
0x0010 jmp TIM2_COMPB ; Timer2 Compare B Handler
0x0012 jmp TIM2_OVF ; Timer2 Overflow Handler
0x0014 jmp TIM1_CAPT ; Timer1 Capture Handler
0x0016 jmp TIM1_COMPA ; Timer1 Compare A Handler
0x0018 jmp TIM1_COMPB ; Timer1 Compare B Handler
0x001A jmp TIM1_OVF ; Timer1 Overflow Handler
0x001C jmp TIM0_COMPA ; Timer0 Compare A Handler
0x001E jmp TIM0_COMPB ; Timer0 Compare B Handler
0x0020 jmp TIM0_OVF ; Timer0 Overflow Handler

iom168.h includes the vectors from iomx8.h.

Which state the vectors as follows:

/* External Interrupt Request 0 */
#define INT0_vect _VECTOR(1)
#define SIG_INTERRUPT0 _VECTOR(1)

/* External Interrupt Request 1 */
#define INT1_vect _VECTOR(2)
#define SIG_INTERRUPT1 _VECTOR(2)

/* Pin Change Interrupt Request 0 */
#define PCINT0_vect _VECTOR(3)
#define SIG_PIN_CHANGE0 _VECTOR(3)

/* Pin Change Interrupt Request 0 */
#define PCINT1_vect _VECTOR(4)
#define SIG_PIN_CHANGE1 _VECTOR(4)

/* Pin Change Interrupt Request 1 */
#define PCINT2_vect _VECTOR(5)
#define SIG_PIN_CHANGE2 _VECTOR(5)

/* Watchdog Time-out Interrupt */
#define WDT_vect _VECTOR(6)
#define SIG_WATCHDOG_TIMEOUT _VECTOR(6)

/* Timer/Counter2 Compare Match A */
#define TIMER2_COMPA_vect _VECTOR(7)
#define SIG_OUTPUT_COMPARE2A _VECTOR(7)

These vectors are correct for the 48 and 88 but different for the 168.

Thanks!

Jose Torres <capek>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by joerg_wunsch (Posted a comment)
  • -unavailable- added by capek (Voted in favor of this item)
  • -unavailable- added by capek (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 26 May 2010 05:17:44 AM UTCjoerg_wunschStatusNeed Info=>Invalid
      Open/ClosedOpen=>Closed
    Wed 26 May 2010 04:11:06 AM UTCjoerg_wunschStatusNone=>Need Info
    Wed 26 May 2010 03:41:42 AM UTCcapekCarbon-Copy-=>Added capek

    Back to the top


    Powered by Savane 3.1-cleanup1