久久ER99热精品一区二区-久久精品99国产精品日本-久久精品免费一区二区三区-久久综合九色综合欧美狠狠

新聞中心

EEPW首頁 > 嵌入式系統 > 設計應用 > AVR Int0中斷的c語言編程

AVR Int0中斷的c語言編程

作者: 時間:2016-11-11 來源:網絡 收藏
#include

#define uchar unsigned char
#define uint unsigned int

本文引用地址:http://cqxgywz.com/article/201611/316777.htm


uchar Table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar Data[4]={0,7,2,8};
uchar Data1[4]={1,1,1,1};
void DelayMs(uint i) //0.25ms
{uchar j;
for(;i!=0;i--)
{for(j=250;j!=0;j--) {;}}
}

void Display(uchar *p) //間隔5ms顯示
{uchar i,sel=0x01;
for(i=0;i<4;i++)
{PORTA=sel;
PORTC=0xff-Table[p[i]];
DelayMs(20);
sel=sel<<1;
}
}

void main(void)
{uint i;
DDRA=0xff; //設置A口為不帶上拉輸入;
PORTA=0xff;
DDRC=0xff; //設置C口為推挽1輸出;
PORTC=0xff;
DDRD=0xff; //設置D口為上拉輸入
PORTD=0xff;
PORTA=0xff;
PORTC=0x00;
DelayMs(10000);
MCUCR=0x00;//下降沿
GIMSK=0x40;//int0
GIFR=0xff;
SREG=SREG|0x80;
while(1){Display(Data1);}
/*{if((GIFR&0x40)==0x40) {GIFR=0xff;Display(Data);}
else
}*/
}
#pragma interrupt_handler int0:2
void int0(void)
{Display(Data);}



關鍵詞: AVRInt0中斷c語

評論


技術專區

關閉