I have blamed God, the Universe, GCC and Atmel (in this order; I wrote the code alone, otherwise I would have blamed anyone else involved as well) for this, but now I think the error is due to me, but I can't figure out what is wrong with my code...
In short: I'm trying to pilot the I2C bus as master with a AT90USB647. The code is attached, and I compile it with
avr-gcc -std=c99 -W -Wall -pedantic -Wstrict-prototypes -Wundef -Werror -funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums -ffreestanding -Os -g -gdwarf-2 -DF_CPU=8000000UL -mmcu=at90usb647 -Wl,--relax -Wl,--gc-sections main.c -Wl,-Map,i2c.map -o i2c.elf
My problem is: if I declare the ISR, as anyone would do, with
then the interrupt is NOT being called. If I instead call the TWI interrupt
I have checked the list file, and there is no twist in the interrupt vectors. The TWI int is number 37 as in the datasheet, and INT6 is vector number 8 in the datasheet, so I can exclude an error in GCC's header files. I have contacted Atmel for it and they confirmed it: TWI is vector 37 on a AT90USB647.
I'm using avr-gcc v4.3.0 on Debian/Linux. There is no other interrupt initialised and no interrupt vector other than the TWI vector and the Reset vector are configured.
Has anyone an idea what I'm doing wrong? I got a similar code working as a slave on a ATmega644, so I really don't know why this version does not work at all. Any clue?