實驗四指示燈/數碼管中斷控制
【實驗目的】
掌握行列式鍵盤的工作原理,熟悉 C51 語言的編程與調試
【實驗內容】
(1) 學習使用 Proteus 軟件,掌握原理圖繪圖方法
(2) 學習 Keil C 軟件,掌握 C51 程序編寫與調試方法
(3) 理解行列式鍵盤的掃描工作原理,完成掃描程序的編寫與調試
(4) 實現行列式鍵盤掃描中斷控制功能
【實驗步驟】
(5) 在 Proteus 中繪制電路原理圖,將相應的元件添加到編輯環境中
(6) 在 Keil 中編寫 C51 程序,并使之編譯通過
(7) 在 Proteus 中加載程序,觀察仿真結果
【實驗原理圖】
【實驗源程序】
#include<reg51.h>
unsigned char led_mod[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x58,0x5e,0x79,0x71};
unsigned char count=0;
sbit P0_4=P0^4;
void INT_0SRV() interrupt 0 {
P0_4 = ~P0_4;
}
void INT_1SRV() interrupt 2 {
count++;
if(count==16)
count = 1;
P2 = led_mod[count];
}
void main(){
P2=0x00;
P0_4=0x01;
EA=1;
EX0=1;
EX1=1;
IT1=1;
IT0=1;
while(1);
}
|