- 论坛徽章:
- 0
|
#include<stdio.h>
#include<reg52.h>
#include<absacc.h>
#define uchar unsigned char
#define uint unsigned int
uchar idata table[21]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f, 0x77,0x7c,0x39,0x5e,0x79,0x71,
0x08,0x48,0x49,0x54,0x40}; // d;d and g; d,g and a; n;-;//
uchar idata disbuf[4];
sbit CS=P3^0;
sbit HBEN=P3^1;
sbit INT=P3^2;
sbit P11=P1^1;
sbit P12=P1^2;
sbit P13=P1^3;
sbit P14=P1^4;
sbit P15=P1^5;
bit error;
sbit buzzer=P3^3;
void Dlms(uint t)
{
while(t--)
{
TR1=1;
while(TF1==0);
}
TR1=0;TL1=0;
}
uchar Keyscan(void)
{
uchar sccode,recode,keynum;
P2=0xf0;
if((P2&0xf0)!=0xf0)
{ Dlms(200);
if((P2&0xf0) !=0xf0)
{ sccode=0xfe;
while((sccode&0x10) !=0)
{P2=sccode;
if((P2&0xf0)!=0xf0)
{ recode=(P1&0xf0)|0x0f;
switch((~sccode)+(~recode))
{
case 0x11:keynum=1;break;
case 0x12:keynum=2;break;
case 0x14:keynum=3;break;
case 0x18:keynum=4;break;
case 0x21:keynum=5;break;
case 0x22:keynum=6;break;
case 0x24:keynum=7;break;
case 0x28:keynum=8;break;
case 0x41:keynum=9;break;
case 0x42:keynum=10;break;
default :keynum=0;
}
return(keynum);
}
else sccode=(sccode<<1)|0x01;
}
}
return(0);
}
void Display(uchar *P,uchar dig,uchar fv)
{
uchar sel=0x01,t,i;
if(*P==0&&*(P+1)==0&&*(P+2)==0&&*(P+3)==0)
{ P0=table[*P];
P2=0x01;
}
else
{ for(i=0;i<dig;i++)
{
if((i==1)&&(fv==0))P0=table[*P]+0x80;
else if((i==2)&&(fv==1))P0=table[*P]+0x80;
else P0=table[*P];
P2=sel;
P++;
sel=sel<<1;
for(t=0;t<100;t++);
}
}
}
/*
uint AD(uchar ch)
{
uchar m,n;
CS=0;
HBEN=0;
P0=0x40+ch;
while(INT);
n=P0;
HBEN=1;
m=P0&0x0f;
CS=1;
return(m*256+n);
}
//Frequency measurement,T0:Counter T2:Timer;T1 work in mode 2//
uint Frq(void)
{
TH2=-50530/256;TL2=-50530%256;
TH0=0;TL0=0;
TR0=1; TR2=1;
while(TF2==0);
TF0=0;TF2=0;
TR0=0;TR2=0;
return(TH0*256+TL0);
}
void Dataprocess(uint dataget,uint value,uint tlr)
{
error=0;
buzzer=0;
if((value==0)&&(dataget<=100))
{
error=1;
buzzer=1;
}
else (dataget<(value-tlr))&&dataget>(value+tlr) )
{
error=1;
buzzer=1;
}
if(dataget%10>=5)dataget=dataget/10+1;
for(i=0;i<4;i++)
{
disbuf[i]=dataget%10;
dataget=dataget/10;
}
}
main()
{
uchar knum,hitseq;
TMOD=0x25;
C_T2=0;
P0=0;
CS=1;
P1=0;
uint t;
//power on//
P11=1;
Display(disbuf,1,2);
Dlms(500);
While(1)
{
knum=Keyscan();
if(knum==0)
{
//Display TP100//
Dataprocess(AD(0),3300,200);
t=3000; disbuf[3]=16;
while(t--)
{
Display(disbuf,4,1);
if(error=1) buzzer=!buzzer;
knum=Keyscan();
if(knum !=0){t=0;buzzer=0;error=0;}
}
if(knum==0)
{
//Display TP91//
Dataprocess(AD(1),3300,200);
t=3000; disbuf[3]=17;
while(t--)
{
Display(disbuf,4,1);
if(error=1) buzzer=!buzzer;
knum=Keyscan();
if(knum !=0){t=0;buzzer=0;error=0;}
}
}
if(knum==0)
{
//Display TP89//
Dataprocess(AD(2),3800,500);
t=3000; disbuf[3]=18;
while(t--)
{
Display(disbuf,4,1);
if(error=1) buzzer=!buzzer;
knum=Keyscan();
if(knum !=0){t=0;buzzer=0;error=0;}
}
}
if(knum==0)
{
//Display PWM//
Dataprocess(Frq(),10000,100);
t=3000;
while(t--)
{
Display(disbuf,4,0);
if(error=1) buzzer=!buzzer;
knum=Keyscan();
if(knum !=0){t=0;buzzer=0;error=0;}
}
}
if(knum==2)
{
samepresstime++;
hitseq=samepresstime%3;
knum=0;
if(hitseq==1)
{
//Brightness 1//
Dataprocess(AD(3),900,200);
while(knum==0)
{
Display(disbuf,3,1);
if(error=1) buzzer=!buzzer;
knum=Keyscan();
if(knum !=0){t=0;buzzer=0;error=0;}
}
}
if(hitseq==2)
{
//Brightness 2//
Dataprocess(AD(3),1800,200);
while(knum==0)
{
Display(disbuf,3,1);
if(error=1) buzzer=!buzzer;
knum=Keyscan();
if(knum !=0){t=0;buzzer=0;error=0;}
}
}
if(hitseq==3)
{
//Brightness 3//
Dataprocess(AD(3),2700,200);
while(knum==0)
{
Display(disbuf,3,1);
if(error=1) buzzer=!buzzer;
knum=Keyscan();
if(knum !=0){t=0;buzzer=0;error=0;}
}
}
}
samepresstime=0; hitseq=0;
else if(knum==3)
{
samepresstime++;
hitseq=samepresstime%3;
knum=0;
if(hitseq==1)
{
//TEST3 MACS STEP0//
Dataprocess(AD(4),0,100);
while(knum==0)
{
Display(disbuf,3,1);
if(error=1) buzzer=!buzzer;
knum=Keyscan();
if(knum !=0){t=0;buzzer=0;error=0;}
}
}
if(hitseq==2)
{
//TEST3 MACS STEP1//
Dataprocess(AD(4),4750,250);
while(knum==0)
{
Display(disbuf,3,1);
if(error=1) buzzer=!buzzer;
knum=Keyscan();
if(knum !=0){t=0;buzzer=0;error=0;}
}
}
}
else if(knum==10)
{
disbuf[2]=14;
disbuf[1=19;
disbuf[0]=13;
while(1)Display(disbuf,3,2);
)
else
{
knum=0;
for(i=0;i<4;i++)disbuf[i]=20;
while(knum==0)
{
Display(disbuf,3,1);
knum=Keyscan();
}
}
}
*/
}
出错在这
Build target 'Target 1'
assembling STARTUP.A51...
compiling Text1.c...
TEXT1.C(70): error C141: syntax error near 'void'
Target not created
等你们答案 谢谢 |
|