This program was produced by the CodeWizardAVR V2 05 Professional Auto

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.0 Professional
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 21.04.2015
Author :
Company :
Comments:
Chip type : ATmega32L
Program type : Application
AVR Core Clock frequency: 16,000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 512
*****************************************************/
#include <mega32.h>
#include <delay.h>
volatile unsigned char i;
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
// Place your code here
i=1;
/*PORTA=0b00001001;
delay_ms(1);
PORTA=0b00001000;
delay_ms(1);
PORTA=0b00001100;
delay_ms(1);
PORTA=0b00000100;
delay_ms(1);
PORTA=0b00000110;
delay_ms(1);
PORTA=0b00000010;
delay_ms(1);
PORTA=0b00000011;
delay_ms(1);
PORTA=0b00000001;
delay_ms(1); */
}
// External Interrupt 1 service routine
interrupt [EXT_INT1] void ext_int1_isr(void)
{
i=2;
/*PORTA=0b00000001;
delay_ms(1);
PORTA=0b00000011;
delay_ms(1);
PORTA=0b00000010;
delay_ms(1);
PORTA=0b00000110;
delay_ms(1);
PORTA=0b00000100;
delay_ms(1);
PORTA=0b00001100;
delay_ms(1);
PORTA=0b00001000;
delay_ms(1);
PORTA=0b00001001;
delay_ms(1); */
}
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=Out Func2=Out Func1=Out Func0=Out
// State7=T State6=T State5=T State4=T State3=0 State2=0 State1=0 State0=0
PORTA=0x00;
DDRA=0x0F;
PORTD=0x0C;
DDRD=0x00;
// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Low level
// INT1: On
// INT1 Mode: Low level
// INT2: Off
GICR|=0xC0;
MCUCR=0x00;
MCUCSR=0x00;
GIFR=0xC0;
// Global enable interrupts
#asm("sei")
while (1)
{
switch (i) {
case 1:
PORTA=0b00001001;
delay_ms(1);
PORTA=0b00001000;
delay_ms(1);
PORTA=0b00001100;
delay_ms(1);
PORTA=0b00000100;
delay_ms(1);
PORTA=0b00000110;
delay_ms(1);
PORTA=0b00000010;
delay_ms(1);
PORTA=0b00000011;
delay_ms(1);
PORTA=0b00000001;
delay_ms(1);
i=0;
break;
case 2:
PORTA=0b00000001;
delay_ms(1);
PORTA=0b00000011;
delay_ms(1);
PORTA=0b00000010;
delay_ms(1);
PORTA=0b00000110;
delay_ms(1);
PORTA=0b00000100;
delay_ms(1);
PORTA=0b00001100;
delay_ms(1);
PORTA=0b00001000;
delay_ms(1);
PORTA=0b00001001;
delay_ms(1);
i=0;
break;
}
}
}