欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
我做一個(gè)單片機(jī)定時(shí)器1的中斷矩陣按鍵的實(shí)驗(yàn),但是沒(méi)有結(jié)果顯示,求大佬幫忙。
[打印本頁(yè)]
作者:
RealyWjw
時(shí)間:
2018-11-9 09:29
標(biāo)題:
我做一個(gè)單片機(jī)定時(shí)器1的中斷矩陣按鍵的實(shí)驗(yàn),但是沒(méi)有結(jié)果顯示,求大佬幫忙。
#include "reg51.h"
#define GPIO_KEY P1
typedef unsigned int u16;
typedef unsigned char u8;
u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
u8 KeyDown(void)
{
u8 KeyValue = 0;
if(GPIO_KEY!=0x0f)
{
GPIO_KEY=0X0F;
switch(GPIO_KEY)
{
case(0X07): KeyValue=0;break;
case(0X0b): KeyValue=1;break;
case(0X0d): KeyValue=2;break;
case(0X0e): KeyValue=3;break;
}
GPIO_KEY = 0xf0;
switch(GPIO_KEY)
{
case(0X70): KeyValue=KeyValue;break;
case(0Xb0): KeyValue=KeyValue+4;break;
case(0Xd0): KeyValue=KeyValue+8;break;
case(0Xe0): KeyValue=KeyValue+12;break;
}
while(GPIO_KEY!=0xf0)
{
}
}
return KeyValue;
}
void timer1Init(void)
{
TMOD |= 0x10;
TH1 = 0xff;
TL1 = 0xff;
TR1 = 1;
ET1 = 1;
EA = 1;
}
void timer1() interrupt 3 using 3
{
static u16 i = 0;
static u8 key = 0;
TH1 = 0xff;
TL1 = 0xff;
GPIO_KEY = 0x0f;
if (GPIO_KEY != 0x0f)
{
i++;
if (i >= 10000)
{
key = KeyDown();
i = 0;
}
}
P0 = ~smgduan[key];
}
int mian(void)
{
timer1Init();
while (1) ;
}
作者:
mengzhixinheng
時(shí)間:
2018-11-9 12:31
#include "reg51.h"
#define GPIO_KEY P1
typedef unsigned int u16;
typedef unsigned char u8;
u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
u8 KeyDown(void)//注意:只是提供思路
{
u8 KeyValueH = 0;
u8 KeyValueL = 0;
static u8 state_k;
GPIO_KEY=0x0f;
if(GPIO_KEY!=0x0f&&!state_k){state_k=1;return;}//消抖
if(GPIO_KEY!=0x0f)
{
KeyValueH=GPIO_KEY;
GPIO_KEY = 0xf0;
KeyValueL=GPIO_KEY;
}
GPIO_KEY=0xff;
while(GPIO_KEY!=0xff) ;//可以照著按下消抖的方法自己改
return (KeyValueH |KeyValueL);
}
u8 keyscan()
{
switch(KeyDown())
{
鍵值處理……
}
return 鍵值;
}
void timer1Init(void)
{
TMOD |= 0x10;
TH1 =( 65536-20000)/256;
TL1 =( 65536-20000)%256;
TR1 = 1;
ET1 = 1;
EA = 1;
}
void timer1() interrupt 3 using 3
{
static u16 i = 0;
static u8 key = 0;
TH1 =( 65536-20000)/256;
TL1 =( 65536-20000)%256;
GPIO_KEY = 0x0f;
if (GPIO_KEY != 0x0f)
{
key = keyscan();
}
P0 = ~smgduan[key];
}
int mian(void)
{
timer1Init();
while (1) ;
}
作者:
wulin
時(shí)間:
2018-11-9 20:34
按鍵掃描程序里有這條語(yǔ)句while(GPIO_KEY!=0xff) 待松手,不適合放在中斷中使用。而且65ms中斷時(shí)間太長(zhǎng),數(shù)碼管動(dòng)態(tài)掃描玩不轉(zhuǎn)。
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1