大家帮我看看下面这个程序哪里出现问题了?为什么一直报错error c129 missing';' before'milsec'
单片机源程序如下:
#define uchar unsigned char #define uint unsigned int #include <reg52.h> #define FOSC 18432000L #define T1MS 1536 //1ms 定时器
sbit relay =P3^7; // 继电器输出 sbit touch =P1^0; // 触摸检测
ut milsec; uc sec,temp;
void delay(uc i) { while(i)i--; }
void InitUart (void); void InintTimer0 (void); void InitADC (void); uc GetADCResult (uc ch);
void main(0) { bitchanal; utsave_times,light,voice; AUXR= 0×00; InintTimer0(); InitADC(); sec= 0; relay= 0; while(1) //进入主程序循环状态,一直在这个while循环里检测 { if(chanal) { light+=GetADCResult(2); //光照强度检测 save_times++; } else { voice+=GetADCResult(6); //声音分贝检測 } chanal= -chanal; if(save_times== 256). //消抖 { save_times= -0; light/= 256: voice/= 256; } if((light>200) || (voice>50) || (touch==0)) relay = l; if(sec>=20) relay = 0; //延时输出20秒后灭灯 delay(200); delay(200); } }
void InirUart(void) { SCON = 0×5a; //8个数据位,无校验 TMOD = 0×20; //8位自动装载 THI = TL1 = -(FOSC/12/32/BAUD); //设置波特率 TR1 = 1; //使能定时1 }
void InintTimer0(void) { TMOD | = 0×01; TL0= T1MS; TH0= T1MS >> 8; TR0= 1; ET0= 1; EA= 1; }
Void InitADC(void) { P1 = P1M0 = 0×ff, P1M1 = 0×00; ADC _DATA = 0; ADC_CONTR = ADC_POWER | ADC_SPEEDLL; delay(2); }
uc GetADCResult(uc ch) { ADC_CONTR = ADC_POWER | ADC_SPEEDLL | ch |ADC_START: _nop_(): _nop_(); _nop_(); _nop_(); while(!(ADC_CONTR & ADC_FLAG); //Wait complete flag ADC_CONTR &= -ADC_FLAG; return ADC_DATA; }
void tm0_isr() interrupt 1 using 1 { TL0 = T1MS; TH0 = T1MS >> 8; milsec++; if (milsec == 1000) { if (sec<20) sec++; } }
|