Hallo,
ich möchte das folgende Programm im Atmel Studio 6.2 Simulator testen.
Wie kann ich hier im Simulator einen ext. Interrupt auslösen?
1 | #include <avr/io.h>
|
2 | #include <util/delay.h>
|
3 | #include <avr/interrupt.h>
|
4 |
|
5 | volatile uint8_t flag=0; // global variable
|
6 |
|
7 | int main(void)
|
8 | {
|
9 | DDRD &= ~(1<<PD2); // PD2 = Input (INT0)
|
10 | DDRB |= (1<<PB1); // PB1 = Output
|
11 | PORTB = 0x00; // PORTB = low
|
12 |
|
13 | EICRA |= (1<<ISC01)|(1<<ISC00); //The rising edge of INT0 generates an interrupt request
|
14 | EIMSK |= (1<<INT0); //External interrupt request 0 enable
|
15 |
|
16 | sei(); // Interrupt enable
|
17 |
|
18 | while(1)
|
19 | {
|
20 | if(flag == 1)
|
21 | {
|
22 | _delay_ms(500);
|
23 | PORTB &= ~(1 << PB1); // PB1 = LOW
|
24 | }
|
25 | }
|
26 |
|
27 | return 0;
|
28 | }
|
29 |
|
30 | ISR (INT0_vect) // Begin of ISR
|
31 | {
|
32 | flag = 1;
|
33 | PORTB |= (1 << PB1); // PB1 = HIGH
|
34 | }
|