[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Problem with interrupts/vector table with ATmega16
From: |
Pat Deegan |
Subject: |
[avr-gcc-list] Problem with interrupts/vector table with ATmega16 |
Date: |
Fri, 25 Jun 2004 18:43:50 -0400 |
Hello,
I've been experiencing trouble whilst trying to enable interrupts. The
code works fine but when I add the call to sei() nothing works. I
thought I figured out that the program was reseting because it was
calling an unassigned interrupt handler (thus, jumping to
__bad_interrupt and resetting). So I added a bunch of EMPTY_INTERRUPT()
signal handlers... no go.
Since that didn't work, I took a peek at the disassembled code,
specifically the vector init (included below).
I am building for the atmega16, compiling with:
avr-gcc -I. -I../include/ -g -mmcu=atmega16 -Os -fpack-struct \
-fshort-enums -funsigned-bitfields -funsigned-char -Wall \
-Wstrict-prototypes -Wa,-ahlms=file.lst \
file.c -o file.o
and linking with:
avr-gcc -Wl,-Map,midiparse.out.map -mmcu=atmega16 -lm -o prog.out \
file1.o file2.o file3.o
The vector init is (I've added comments to indicate where each line
jumps to):
00000000 <__vectors>:
0: 0c 94 0f 01 jmp 0x21e ; reset, goes to __init
4: 0c 94 c5 0d jmp 0x1b8a ; jmp to SIG_INTERRUPT0
8: 0c 94 23 0e jmp 0x1c46 ; this goes to
SIG_INTERRUPT1
c: 0c 94 4c 01 jmp 0x298 ; jmp to
SIG_OUTPUT_COMPARE2
10: 0c 94 b1 02 jmp 0x562 ; this points to
SIG_OVERFLOW2
14: 0c 94 2a 01 jmp 0x254 ; __bad_interrupt
18: 0c 94 49 01 jmp 0x292 ; SIG_OUTPUT_COMPARE1A
1c: 0c 94 4a 01 jmp 0x294 ; SIG_OUTPUT_COMPARE1B
20: 0c 94 9b 0f jmp 0x1f36 ; SIG_OVERFLOW1 handler
24: 0c 94 2f 08 jmp 0x105e ; this jmps to
SIG_OVERFLOW0
28: 0c 94 45 01 jmp 0x28a ; SIG_SPI
2c: 0c 94 2a 01 jmp 0x254 ; __bad_interrupt
30: 0c 94 2a 01 jmp 0x254 ; __bad_interrupt
34: 0c 94 2a 01 jmp 0x254 ; __bad_interrupt
38: 0c 94 50 01 jmp 0x2a0 ; SIG_ADC
3c: 0c 94 2a 01 jmp 0x254 ; __bad_interrupt
40: 0c 94 51 01 jmp 0x2a2 ; SIG_COMPARATOR
44: 0c 94 4f 01 jmp 0x29e ; SIG_2WIRE_SERIAL
48: 0c 94 47 01 jmp 0x28e ; SIG_INTERRUPT2
4c: 0c 94 48 01 jmp 0x290 ; SIG_OUTPUT_COMPARE0
50: 0c 94 46 01 jmp 0x28c ; SIG_SPM_READY
and it doesn't seem right. None
of the vectors are pointing to any of the SIG_UART* handlers (some of which are
declared as EMPTY_INTERRUPT()s) and others look like they're in the wrong spot
(though the order looks ok).
The ATmega16 specs have an interrupt table that says:
Vector No. Program Address(2) Source Interrupt Definition
1 $000(1) RESET External Pin, Power-on Reset, Brown-out Reset, Watchdog
Reset, and JTAG AVR Reset
2 $002 INT0 External Interrupt Request 0
3 $004 INT1 External Interrupt Request 1
4 $006 TIMER2 COMP Timer/Counter2 Compare Match
5 $008 TIMER2 OVF Timer/Counter2 Overflow
6 $00A TIMER1 CAPT Timer/Counter1 Capture Event
7 $00C TIMER1 COMPA Timer/Counter1 Compare Match A
8 $00E TIMER1 COMPB Timer/Counter1 Compare Match B
9 $010 TIMER1 OVF Timer/Counter1 Overflow
10 $012 TIMER0 OVF Timer/Counter0 Overflow
11 $014 SPI, STC Serial Transfer Complete
12 $016 USART, RXC USART, Rx Complete
13 $018 USART, UDRE USART Data Register Empty
14 $01A USART, TXC USART, Tx Complete
15 $01C ADC ADC Conversion Complete
16 $01E EE_RDY EEPROM Ready
17 $020 ANA_COMP Analog Comparator
18 $022 TWI Two-wire Serial Interface
19 $024 INT2 External Interrupt Request 2
20 $026 TIMER0 COMP Timer/Counter0 Compare Match
21 $028 SPM_RDY Store Program Memory Ready
Am I reading this wrong or don't these match the disassembled code?
First, it looks like the AVR expects a list of addresses 2 bytes wide
while the actual jmps take 4 bytes, which gradually shifts everything
more and more out of sync. Or is it that Atmel is refering to the
address of 16 bit words?
In any case, any idea why the UART sig handlers aren't showing up in the
vector table?
TIA.
Regards,
--
Pat Deegan
http://www.psychogenic.com/
PGP Key: http://www.keyserver.net 0x03F86A50
- [avr-gcc-list] Problem with interrupts/vector table with ATmega16,
Pat Deegan <=