/*频率计*/ //声明 #include<reg51.h> #define SEG P1 #define SCANP P3 char TAB[11]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xBF}; char disp[4]{0xc0,0xc0,0xc0,0xc0}; //声明定时器 #define yanshi 5000 #define H (65536-yashi)/256 #define L (65536-yanshi)%256 char times=0 //声明其他基本变量 bit status-F=1; char scan=1; unsigned int freq=0; sfr16 DPTR=0x82;
//测量函数 void measure (void) { SCANP=0Xff; IE=0x8a; TMOD=0X51; TH0=H;TL0=L TH1=0;TL1=0; TR0=1;TR1=1;//启动T0,T1 } //一中断程序 void T01S (void)interrupt 1() TH0=H;TL0=L; if (++times==20)//若达到1s { times=0;//qingling status-F=1;//zhuangtaibiaozhiwei TR1=0;TR0=0;//guanbit0t1 DPL=TL1; DPH=TH1; freq=DPTR; disp[1]=TAB[freq/100] disp[0]=TAB[freq/10] } //xianshihanshu void display(void) { char i; while (1) { scan=0x01; for (i=0;i<2;i++) { SEG=0Xff; SCANP=~scan; SEG=disp ; delay 1m(4); scan<<=1;//xiayigesaomiaoxinhao
} } } //yanshihanshu void delay1m(int x) { int i,j; for (i=0;i<x;i++) for(j=0;j<120;j++); //1ms
} //zhuchengxu main() { while(1) { status-F=0; measure(); while (status-F==0);
} desplay(); }
程序在上面,总是用KEIL编译时,困扰啊。总是显示 Build target 'Target 1' compiling Text1.c... TEXT1.C(7): error C129: missing ';' before '{' Target not created
|