本帖最后由 慧剑温情 于 2015-9-10 17:57 编辑
以下是函数全部,函数void Thekeyadd()在主函数里调用不起,但是把void Thekeyadd()函数内容直接写到主函数里就能正常运行,怎么回事啊??附带能正常运行图片
#include<reg52.h>
sbit keyout4=P2^0;
sbit key=P2^6;
unsigned char code ledchar[]={
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,
0x80, 0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E
};
unsigned char ge=0;
unsigned char shi=0;
void delay();
void Thekeyadd();
void main()
{
keyout4=0;
P1=0x08;
P0=0xff;
EA=1;
TMOD=0X01;
TH0=0XFC;
TL0=0X67;
ET0=1;
TR0=1;
while(1)
{
Thekeyadd();
}
}
void delay()
{
unsigned int shu=1000;
while(shu)
{
shu--;
}
}
void Thekeyadd()
{
unsigned char sec=0;
unsigned kbuff;
bit backup=1;
ge=sec%10;
shi=sec/10%10;
kbuff=key;
if(kbuff!=backup)
{
delay();
if(kbuff==key)
{
if(backup==0)
{
sec++;
if(sec>=100)
{
sec=0;
}
}
backup=kbuff;
}
}
}
void interrupttimer0() interrupt 1
{
static unsigned char i=0;
TH0=0XFC;
TL0=0X67;
P0=0XFF;
switch(i)
{
case 0:P1=0X08;i++;P0=ledchar[ge];break;
case 1:P1=0X09;i=0;P0=ledchar[shi];break;
default :break;
}
}
|