#include#includevoid delay(void){unsigned int a,b;for(a=0;a<1000;a++)for(b=0;b<500;b++);}void init(void){DDRA=0XFF; //输出方式PORTA=0XFF;DDRD=0; //输入方式PORTD=0XFF;MCUCR |=0X02; //下降沿触发GICR |=BIT(6); //打开外边中断0DDRD &=~BIT(2); //设置为输入PORTD |=BIT(2); //带上拉电阻SREG |=BIT(7); //打开全局中断}void main(){init();while(1){PORTA |=BIT(0); //第一个LED亮delay();PORTA &=~BIT(0); delay();}}#pragam void interrupt_handle int0_isr:2void int0_isr(void) {PORTA=0;//LED全亮delay();delay();delay();PORTA=0xff; }
[ 本帖最后由 cc2513685 于 2012-11-1 14:50 编辑 ]
-
sss.c
(2012-11-1 14:50 上传)
678 Bytes, 下载次数: 4