avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] ATMega16 interrupt vectors


From: Henrik Brix Andersen
Subject: [avr-gcc-list] ATMega16 interrupt vectors
Date: Sat, 10 Dec 2005 14:57:30 +0100
User-agent: Mutt/1.5.11

Hi,

I've stumbled across a problem using interrupts with the Atmel AVR
Mega16(L). I have isolated a small test-case demonstrating the
problem (attached).

The test case works as expected when compiled with the commercial
Codevision AVR C compiler, but triggers the wrong ISR when compiled
with avr-gcc. If I redefine the INT0_vect and INT1_vect values as
shown at the top of the file, it triggers the correct ISRs. The odd
thing is that the disassembly looks correct, at least to me.

The code should be self-explaining, but here's a small description of
what I expect it to do: I enable external interrupts 0 and 1 which are
both connected to push-buttons, and use them to alter the state of
PORTB, which is connected to a row of LEDs.
  * At system reset the PD7 LED is turned on.
  * Pulling INT0 low should turn on the PD0 LED.
  * Pulling INT1 low should turn on the PD1 LED.

That's how the program works when compiled with the Codevision AVR C
compiler.

But this is what actually happens when compiled with avr-gcc:
  * At system reset the PD7 LED is turned on (as expected).
  * Pulling INT0 low turns on PD1 (INT1 ISR is executed?).
  * Pulling INT1 low causes a system reset (or triggers
    __vector_default if specfied).


I've used the following software to test this:

  avr-libc-1.4.0

  $ avr-gcc --version
  avr-gcc (GCC) 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)

  $ avr-objcopy --version
  GNU objcopy 2.16.1

  The Codevision AVR C compiler used to verify this was version 1.24.6
  Standard.


These are the commands I used for compiling the test case with avr-gcc:

  $ avr-gcc -mmcu=atmega16 -Wall -c main.c
  main.c: In function `main':
  main.c:26: warning: large integer implicitly truncated to unsigned type

  $ avr-gcc -o interrupt-test.out main.o

  $ avr-objcopy -j .text -j .data -O ihex interrupt-test.out interrupt-test.hex


The resulting interrupt-test.hex file was written to the AVR using
avrdude-5.0 and an STK500v2 programmer:

  $ avrdude -c stk500v2 -p atmega16 -P /dev/ttyUSB0 -e -U 
flash:w:interrupt-test.hex


The disassembly (attached) was produced like this:

  $ avr-objdump -S interrupt-test.out > interrupt-test.s


Can someone explain the cause of this?

Regards,
Brix

PS: I hope this is the correct mailing list for this kind of questions
- couldn't find the difference between this list and the avr-libc-dev
list?
-- 
Henrik Brix Andersen <address@hidden>
Gentoo Metadistribution | Mobile computing herd

Attachment: interrupt-test.s
Description: Text document

Attachment: main.c
Description: Text Data

Attachment: pgp1SlK6c4jAi.pgp
Description: PGP signature


reply via email to

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