访问手机版页面
你的位置:老古开发网 > AVR单片机 > ATmega16单片机 > 正文  
ATMega16单片机外部中断程序分享
内容导读:

//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)

{

;

}

}

标签:ATmega16单片机,外部中断,
来源:工程师周亮 作者:lhl545545 时间:2019/1/10 15:20:00
相关阅读
推荐阅读
阅读排行
最近更新
商品推荐