assembly - Atmega8535 INT0 INT1 INT2 INT3 -
i using atmega8535 microcontoller , stk200 development board, trying use more 1 external interrupt, reason int0 works , others nothing, here related code:
;interrupt vector addresses .equ int0addr=$001 ;external interrupt0 vector address .equ int1addr=$002 .equ int2addr=$003 .equ int3addr=$004 .equ int4addr=$005 //interrupts .org int0addr rjmp int0 ;external interrupt0 vector .org $0015 ;program address .org int1addr rjmp int1 ;external interrupt1 vector .org $0015 ;program address .org int2addr rjmp int2 ;external interrupt0 vector .org $0017 .org int3addr rjmp int3 ;external interrupt0 vector .org $0018 .org int4addr rjmp int4 ;external interrupt0 vector .org $0019 ;external interrupt0 service routine int0: cli ;prevent more interrupts while isr running rjmp reset reti ;return , enable interrupts again ;external interrupt1 service routine int1: cli ;prevent more interrupts while isr running rjmp reset reti ;return , enable interrupts again ;external interrupt1 service routine int2: cli ;prevent more interrupts while isr running rjmp reset reti ;return , enable interrupts again ;external interrupt1 service routine int3: cli ;prevent more interrupts while isr running rjmp reset reti ;return , enable interrupts again ;external interrupt1 service routine int4: cli ;prevent more interrupts while isr running rjmp reset reti ;return , enable interrupts again
you might asking bit processor. according processor reference (pg. 65) processor has 3 external interrupts int0, int1 , int2 (on portd.2, portd.3 , portb.2 respectively) ... worth reading pg 68ff!
i don't see set global interrupt enable bit (bit 7 of sreg) after reset 0 , preventing interrupts being processed, , individual interrupts must enabled (register gicr)
you have lot of superfluous .org
in code (e.g. lines 11, 13).
i recommend include device specific inc file, , - sake of clarity - specify full interrupt vector table e.g.
.nolist .include <m8535def.inc> .list .org 0x0000 ; .... highest priority jmp v_reset ; reset jmp v_extint0 ; external interrupt 0 jmp v_extint1 ; external interrupt 1 jmp v_noint ; timer/counter2 compare match jmp v_noint ; timer/counter2 overflow jmp v_noint ; timer/counter1 capture event jmp v_noint ; timer/counter1 compare match jmp v_noint ; timer/counter1 compare match b jmp v_noint ; timer/counter1 overflow jmp v_noint ; timer/counter0 overflow jmp v_noint ; spi serial transfer complete jmp v_noint ; usart, rx complete jmp v_noint ; usart data register empty jmp v_noint ; usart, tx complete jmp v_noint ; adc conversion complete jmp v_noint ; eeprom ready jmp v_noint ; analog comparator jmp v_noint ; two-wire serial interface jmp v_extint2 ; external interrupt request 2 jmp v_noint ; timercounter0 compare match jmp v_noint ; store program memory read ; .... lowest priority v_reset: ; define stack pointer ; set individual interrupt bits ; initialize ports, etc. sei ; enable general interrupts main: rjmp main v_extint0: ; int0 handler reti v_extint1: ; int1 handler reti v_extint2: ; int2 handler reti v_noint: ; e.g. flash led otherwise unused show abnormal condition reti
Comments
Post a Comment