?? ps2.c
字號(hào):
/*==================================================
由于每次鍵盤(pán)上電或復(fù)位后都會(huì)自檢,然后發(fā)出0xAA到PC
若每次采集33次中斷數(shù)據(jù)則會(huì)出現(xiàn)一點(diǎn)小問(wèn)題,我的解決
辦法是只利用收集到的中間11位數(shù)據(jù)
=================================================*/
#include<reg51.h>
#define uchar unsigned char
sbit Clk=P3^2; //時(shí)鐘線接在P32
sbit Dat=P1^0; //數(shù)據(jù)線接在P10
uchar Degree=0;
uchar Data=0;
void Get_data(void) interrupt 0 using 1
{
if((Degree>11)&&(Degree<20))
{
Data=Data>>1;
if(Dat){Data|=0x80;};
} //只用采集到的中間11位的八位數(shù)據(jù)
Degree++;
if(Degree>=33)
{Degree=0;
P2=Data;
} //32次后重新計(jì)數(shù)
}
void main(void)
{
IT0=1;
EA=1;
EX0=1;
while(1);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -