用AVR实现简单按键的程序与proteus的结合
源代码在线查看: main.i
#line 1 "F:\电子设计\proteus\RUNNIN~1\main.c"
void port_init(void)
{
PORTA = 0x0F;
DDRA = 0x0F;
PORTB = 0x0F;
DDRB = 0x00;
PORTC = 0x00;
DDRC = 0x00;
PORTD = 0xFF;
DDRD = 0x05;
}
void init_devices(void)
{
CLI();
port_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00;
SEI();
}
void delay(void)
{
unsigned char i;
for(i=254;i!=0;i--)
{
asm("nop");
}
}
void main(void)
{
unsigned char temp;
init_devices();
while(1)
{
temp=PINB;
delay();
if(temp==PINB)
{
PORTA=PINB;
}
}
}