[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Can't capture INT0 external interrupt...
From: |
Vincent Trouilliez |
Subject: |
[avr-gcc-list] Can't capture INT0 external interrupt... |
Date: |
Sat, 03 Sep 2005 22:53:44 +0200 |
Hi,
I am trying to demonstrate the INT0 interrupt using a tiny sample
program, but doesn't seem to work.
I wired an LED to pin PD5, configured it as output, and INTO (PD2) as
input. The LED is turned off at power-up, then when a rising edge is
detected on INT0, the ISR is supposed to light the LED, to prove me that
the interrupt event got captured and the ISR executed properly.
Problem is that the LED never lights :-/
I read in avr-libc that if you get the spelling of signal handler in the
ISR wrong, the compiler won't give you any warning. So I triple checked
I typed it correctly : SIG_INTERRUPT0, then double checked after
compilation, in the 'lst' file to make sure that the vector table
pointed correctly at my ISR, and it does. I configured the INT0 for
rising edge event, then enabled its interrupt, then the global interrupt
bit....so should work ?!
I am using avr-libc 1.1.2.3.3 which I think is a bit old ? Still, the
'lst' file look sfine to me... well from what I can see.
Any pointers very much welcome... :-)
Regards,
--
Vince
PS : yes, I made sure that I do get a proper rising edge signal on the
INT0 port pin...
/* Test program to demonstrate INT0 capture.
* LED connected to PD5 gets lit when INT0 occurs
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
SIGNAL (SIG_INTERRUPT0){
PORTB |= 0x20; //light LED
}
void ioinit (void)
{
DDRD = 0x20; //PD2 INT0 input, PD5 LED output
PORTD = 0x00; //turn LED off at boot.
MCUCR |= 0x03; //set INT0 int. req. on rising edge
GICR |= 0x40; //enable INT0 interrupt request
sei(); //enable interrupts
}
int main (void)
{
ioinit ();
for(;;){ //wait for INTO interrupt to light LED
}
}
****************************************
**** LST file ******
****************************************
timer0.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000000c8 00000000 00000000 00000094 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00800060 000000c8 0000015c 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00800060 000000c8 0000015c 2**0
ALLOC
3 .noinit 00000000 00800060 00800060 0000015c 2**0
CONTENTS
4 .eeprom 00000000 00810000 00810000 0000015c 2**0
CONTENTS
5 .stab 00000570 00000000 00000000 0000015c 2**2
CONTENTS, READONLY, DEBUGGING
6 .stabstr 0000061b 00000000 00000000 000006cc 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00000000 <__vectors>:
0: 0c 94 2a 00 jmp 0x54
4: 0c 94 47 00 jmp 0x8e
8: 0c 94 45 00 jmp 0x8a
c: 0c 94 45 00 jmp 0x8a
10: 0c 94 45 00 jmp 0x8a
14: 0c 94 45 00 jmp 0x8a
18: 0c 94 45 00 jmp 0x8a
1c: 0c 94 45 00 jmp 0x8a
20: 0c 94 45 00 jmp 0x8a
24: 0c 94 45 00 jmp 0x8a
28: 0c 94 45 00 jmp 0x8a
2c: 0c 94 45 00 jmp 0x8a
30: 0c 94 45 00 jmp 0x8a
34: 0c 94 45 00 jmp 0x8a
38: 0c 94 45 00 jmp 0x8a
3c: 0c 94 45 00 jmp 0x8a
40: 0c 94 45 00 jmp 0x8a
44: 0c 94 45 00 jmp 0x8a
48: 0c 94 45 00 jmp 0x8a
4c: 0c 94 45 00 jmp 0x8a
50: 0c 94 45 00 jmp 0x8a
00000054 <__ctors_end>:
54: 11 24 eor r1, r1
56: 1f be out 0x3f, r1 ; 63
58: cf e5 ldi r28, 0x5F ; 95
5a: d8 e0 ldi r29, 0x08 ; 8
5c: de bf out 0x3e, r29 ; 62
5e: cd bf out 0x3d, r28 ; 61
00000060 <__do_copy_data>:
60: 10 e0 ldi r17, 0x00 ; 0
62: a0 e6 ldi r26, 0x60 ; 96
64: b0 e0 ldi r27, 0x00 ; 0
66: e8 ec ldi r30, 0xC8 ; 200
68: f0 e0 ldi r31, 0x00 ; 0
6a: 02 c0 rjmp .+4 ; 0x70
0000006c <.do_copy_data_loop>:
6c: 05 90 lpm r0, Z+
6e: 0d 92 st X+, r0
00000070 <.do_copy_data_start>:
70: a0 36 cpi r26, 0x60 ; 96
72: b1 07 cpc r27, r17
74: d9 f7 brne .-10 ; 0x6c
00000076 <__do_clear_bss>:
76: 10 e0 ldi r17, 0x00 ; 0
78: a0 e6 ldi r26, 0x60 ; 96
7a: b0 e0 ldi r27, 0x00 ; 0
7c: 01 c0 rjmp .+2 ; 0x80
0000007e <.do_clear_bss_loop>:
7e: 1d 92 st X+, r1
00000080 <.do_clear_bss_start>:
80: a0 36 cpi r26, 0x60 ; 96
82: b1 07 cpc r27, r17
84: e1 f7 brne .-8 ; 0x7e
86: 0c 94 5d 00 jmp 0xba
0000008a <__bad_interrupt>:
8a: 0c 94 00 00 jmp 0x0
0000008e <__vector_1>:
#include <avr/interrupt.h>
#include <avr/signal.h>
SIGNAL (SIG_INTERRUPT0){
8e: 1f 92 push r1
90: 0f 92 push r0
92: 0f b6 in r0, 0x3f ; 63
94: 0f 92 push r0
96: 11 24 eor r1, r1
PORTB |= 0x20; //light LED
98: c5 9a sbi 0x18, 5 ; 24
9a: 0f 90 pop r0
9c: 0f be out 0x3f, r0 ; 63
9e: 0f 90 pop r0
a0: 1f 90 pop r1
a2: 18 95 reti
000000a4 <ioinit>:
}
void ioinit (void)
{
DDRD = 0x20; //PD2 INT0 input, PD5 LED output
a4: 80 e2 ldi r24, 0x20 ; 32
a6: 81 bb out 0x11, r24 ; 17
PORTD = 0x00; //turn LED off at boot.
a8: 12 ba out 0x12, r1 ; 18
MCUCR |= 0x03; //set INT0 int. req. on rising edge
aa: 85 b7 in r24, 0x35 ; 53
ac: 83 60 ori r24, 0x03 ; 3
ae: 85 bf out 0x35, r24 ; 53
GICR |= 0x40; //enable INT0 interrupt request
b0: 8b b7 in r24, 0x3b ; 59
b2: 80 64 ori r24, 0x40 ; 64
b4: 8b bf out 0x3b, r24 ; 59
sei(); //enable interrupts
b6: 78 94 sei
b8: 08 95 ret
000000ba <main>:
}
int main (void)
{
ba: cf e5 ldi r28, 0x5F ; 95
bc: d8 e0 ldi r29, 0x08 ; 8
be: de bf out 0x3e, r29 ; 62
c0: cd bf out 0x3d, r28 ; 61
ioinit ();
c2: 0e 94 52 00 call 0xa4
for(;;){ //wait for INTO interrupt to light LED
c6: ff cf rjmp .-2 ; 0xc6
- [avr-gcc-list] Can't capture INT0 external interrupt...,
Vincent Trouilliez <=