#include
#include
#define uchar unsigned char
#define uint unsigned int
#define uint unsigned int
__flash uchar seg[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
__flash uchar tab[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
__flash uchar tab[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
#define EEWE 1
#define EERE 0
#define EEMWE 2
#define EERE 0
#define EEMWE 2
#define k1 PIND_Bit4 //地址改变键
#define k2 PIND_Bit5 //数据改变键
#define k3 PIND_Bit6 //地址写入
#define k4 PIND_Bit7 //地址读出
#define k2 PIND_Bit5 //数据改变键
#define k3 PIND_Bit6 //地址写入
#define k4 PIND_Bit7 //地址读出
uint val; //显现的存储数值
uchar address,data; //存储地址和数值
void delay(uint k) //推迟函数
{
uint i,j;
for(i=0;i for(j=0;j<1140;j++);
}
{
uint i,j;
for(i=0;i
}
void key1()
{
static uchar i,j;
if(k1==0)
{
if(i==0)
{
j++;
if(j>3)
{
if(k1==0)
{
i=1;j=0;
address++;
}
}
}
}
else
{
i=0;j=0;
}
}
{
static uchar i,j;
if(k1==0)
{
if(i==0)
{
j++;
if(j>3)
{
if(k1==0)
{
i=1;j=0;
address++;
}
}
}
}
else
{
i=0;j=0;
}
}
void key2()
{
static uchar i,j;
if(k2==0)
{
if(i==0)
{
j++;
if(j>3)
{
if(k2==0)
{
i=1;j=0;
data++;
}
}
}
}
else
{
i=0;j=0;
}
}
{
static uchar i,j;
if(k2==0)
{
if(i==0)
{
j++;
if(j>3)
{
if(k2==0)
{
i=1;j=0;
data++;
}
}
}
}
else
{
i=0;j=0;
}
}
void show_val(uint k) //显现数值函数
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
void show_address(uint k) //显现数值函数
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j+3];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j+3];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
void show_data(uint k) //显现数值函数
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j+6];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
{
static uchar i=0,j;
uchar ss[6];
do
{
ss[i]=k%10;
i++;
}while(k/=10);
for(j=0;j{
PORTA=seg[ss[j]];
PORTC=tab[j+6];
delay(1);
PORTA=0xff;
PORTC=0xff;
}
i=0;
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/318350.html