13.07.2013 Views

Interrupts

Interrupts

Interrupts

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

An Example:<br />

We must start our program<br />

with these instructions.<br />

We need to write the<br />

initialization part of the<br />

program and setup the stack<br />

(use of the stack is required<br />

when using interrupts)<br />

Start the initialize the<br />

interrupt: set it up for the<br />

high-to-low transition<br />

Enable the interrupt<br />

1/4/2010<br />

$0000 jmp RESET ; Reset Handler<br />

$0002 jmp EXT_INT0 ; IRQ0 Handler<br />

$0004 jmp EXT_INT1 ; IRQ1 Handler<br />

$0006 jmp EXT_INT2 ; IRQ2 Handler<br />

$0008 jmp EXT_INT3 ; IRQ3 Handler<br />

$000A jmp EXT_INT4 ; IRQ4 Handler<br />

$000C jmp EXT_INT5 ; IRQ5 Handler<br />

$000E jmp EXT_INT6 ; IRQ6 Handler<br />

$0010 jmp EXT_INT7 ; IRQ7 Handler<br />

RESET: initialization instructions<br />

ldi r21,low(RAMEND) ;setup the stack<br />

out SPL,r21<br />

ldi r21,high(RAMEND)<br />

out SPH,r21<br />

ldi r21,obxxxxxx10<br />

out EICRA,r21 ;H-to-L on INT0<br />

ldi r21,0bxxxxxxx1<br />

out EIMSK,r21 ;set INT0 Mask<br />

sei ;set Global Int Mask<br />

the rest of the main program<br />

28

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!