ATMega16单片机外部中断的使用

电子元件 4年前 (2022) aysz01
0

//Crystal:7.3728MHz,功能:学习外部中断0的程序
#include
#include

#defineLED_COMPORTA^=(1<voidport_init(void)
{
PORTA=0x40;
DDRA=0x40;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;//m103outputonly
DDRC=0x00;
PORTD=0x04;
DDRD=0x00;
}

#pragmainterrupt_handlerint0_isr:2
voidint0_isr(void)
{
LED_COM;
}

//callthisroutinetoinitializeallperipherals
voidinit_devICes(void)
{
//stoperrantinterruptsuntilsetup
CLI();//dISAbleallinterrupts
port_init();

MCUCR=0x00;
GICR=0x40;
TIMSK=0x00;//timerinterruptsources
SEI();//re-enableinterrupts
//allperipheralsarenowinitialized
}

voidmain()
{
init_devices();
while(1)
{
;
}

}

版权声明:aysz01 发表于 2022-08-06 11:05:33。
转载请注明:ATMega16单片机外部中断的使用 | 鳌游电工

暂无评论

暂无评论...