標(biāo)題:
求助本單片機(jī)程序錯(cuò)誤,實(shí)在找不到哪里錯(cuò)了
[打印本頁]
作者:
GRE
時(shí)間:
2018-5-2 21:35
標(biāo)題:
求助本單片機(jī)程序錯(cuò)誤,實(shí)在找不到哪里錯(cuò)了
#include <reg52.h>
void delay1ms(int n) //延時(shí)子程序
{
int k,j;
for(k=0;k<=n;k++)
for(j=0;j<=10;j++);
}
void delay1s(int n) //延時(shí)子程序
{
int k,j;
for(k=0;k<=n;k++)
for(j=0;j<=120;j++);
}
void SPEAKER(uint n) //蜂鳴器程序,按周期n發(fā)聲
{
for(i=0;i<=200;i++)
{
delay(10);
BEEP=~BEEP;
}
BEEP=1; }// ***********************************LCD程序**********
void delay1ms(unsigned int ms)//延時(shí)的時(shí)間不夠精確的
{
uint k,j;
for(k=0;k<ms;k++)
for(j=0;j<100;j++);
}
void LCD_w_com(unsigned com) //寫入指令
{
RW=0;
RS=0;
E=1;
P0=com;
delay1ms(40);
E=0;
RW=1;
}
void LCD_w_dat(uchar dat) // 寫入數(shù)據(jù)
{
RW=0;
RS=1;
E=1;
P0=dat;
delay1ms(40);
E=0;
RW=1;
}
void gotoxy(unsigned x,unsigned y) // x,y分別代表行列
{
if(x==1)
LCD_w_com(0x80+y);
else
LCD_w_com(0xC0+y);
}
void clear_LCD(void)
{
LCD_w_com(0x01); // 清屏指令
LCD_w_com(0x02); // 光標(biāo)歸位 即光標(biāo)置于左上位置
}
void init_LCD(void) // 初始化LCD
{
LCD_w_com(0x38); // LCD為兩行顯示8位數(shù)據(jù)線有效
LCD_w_com(0x0c); // 顯示字符 關(guān)閉光標(biāo)
LCD_w_com(0x06); // 輸入方式設(shè)置 光標(biāo)向右移動(dòng)一位 ac-1
gotoxy(1,0);
for(i=0;i<=5;i++)
{
LCD_w_dat(test[i]);
}
}
//*********叫號(hào)機(jī) 按一次一號(hào)鍵變量+1最大為10*************
void QueueNumProcess()
{
rank[Length Flag]=num_count; // num_count為實(shí)時(shí)取得的號(hào)碼
Length Flag++;
}
if(Length Flag>10) (void)
{
EA=1;
EX0=1;
EX1=1;
IT0=1;
IT1=1;
clear_LCD();
init_LCD();
while(1)
{
delay1s(10000);
clear_LCD();
gotoxy(1,0);
for(i=0;i<=5;i++)
{
LCD_w_dat(test[i]);
}
delay1s(10000);
clear_LCD();
prompt8[0]=Length Flag10+'0';
prompt8[1]=Length Flag%10+'0';
gotoxy(1,0);
for(m=0;m<=9;m++)
{
LCD_w_dat(prompt8[m]);
}
delay1s(10000);
clear_LCD();
ClearNumProcess();
prompt2[3]=(num)10+'0';
prompt2[4]=(num)%10+'0';
prompt3[1]=jz+'0';
gotoxy(1,0);
for(m=0;m<=15;m++)
{
LCD_w_dat(prompt2[m]);
}
gotoxy(2,0);
for(m=0;m<=15;m++)
{
LCD_w_dat(prompt3[m]);
}
}
} //**************按鍵中斷方式**********************
void int_x0() interrupt 0
{
if(!key1) {jz=1;sev1++;}
if(!key2) {jz=2;sev2++;}
if(!key3) {jz=3;sev3++;}
if(!key4) {jz=4;sev4++;}
if(!key0) /// ******叫號(hào)機(jī)程序*******
{
while(!key0);
if(Length Flag<=10)
{
clear_LCD();
QueueNumProcess();
prompt1[11]=(num_count)10+'0'; prompt1[12]=(num_count)%10+'0';
num_count++;
}
else
{
clear_LCD();
gotoxy(1,2);
for(m=0;m<=10;m++)
{
LCD_w_dat(prompt4[m]);
}
gotoxy(2,0);
for(m=0;m<=15;m++)
{
LCD_w_dat(prompt5[m]); // 提示隊(duì)列已滿
}
}
key5=0;
}
if((!key1||!key2||!key3||!key4)&&key0) // *******消號(hào)處理******
{
while((!key1||!key2||!key3||!key4)&&key0);
{
SPEAKER(11);
delay(200);
SPEAKER(15);
if(Length Flag<1)
{
clear_LCD();
gotoxy(1,0);
for(m=0;m<=15;m++)
{
LCD_w_dat(prompt6[m]);
}
gotoxy(2,0);
for(m=0;m<=8;m++)
{
LCD_w_dat(prompt7[m]);
}// 顯示隊(duì)列為空
}
else
{
clear_LCD();
ClearNumProcess();
prompt2[3]=(num)10+'0';
prompt2[4]=(num)%10+'0';
prompt3[1]=jz+'0';
gotoxy(1,0);
for(m=0;m<=15;m++)
{
LCD_w_dat(prompt2[m]);
}
gotoxy(2,0);
for(m=0;m<=15;m++)
{
LCD_w_dat(prompt3[m]);
}
}
}
}
}
void int_x1() interrupt 2
{
if(!key5) // 統(tǒng)計(jì)等待人數(shù)
{
key5=1;
clear_LCD();
prompt8[0]=Length Flag10+'0';
prompt8[1]=Length Flag%10+'0';
gotoxy(1,0);
for(m=0;m<=9;m++)
{
LCD_w_dat(prompt8[m]);
}
}
if(!key6) // 統(tǒng)計(jì)客流量
{
clear_LCD();
prompt9[7]=(sev)10+'0';
prompt9[8]=(sev)%10+'0';
gotoxy(1,0);
for(m=0;m<=9;m++)
{
LCD_w_dat(prompt9[m]);
}
}
if(!key7) // 統(tǒng)計(jì)各窗口客流量
{
clear_LCD();
prompt10[5]=sev110+'0';
prompt10[6]=sev1%10+'0';
prompt11[5]=sev210+'0';
prompt11[6]=sev2%10+'0';
prompt12[5]=sev310+'0';
prompt12[6]=sev3%10+'0';
prompt13[5]=sev410+'0';
prompt13[6]=sev4%10+'0';
gotoxy(1,0);
for(m=0;m<=7;m++)
{
LCD_w_dat(prompt10[m]);
}
gotoxy(1,8);
for(m=0;m<=7;m++)
{
LCD_w_dat(prompt11[m]);
}
gotoxy(2,0);
for(m=0;m<=7;m++)
{
LCD_w_dat(prompt12[m]);
}
gotoxy(2,8);
for(m=0;m<=7;m++)
{
LCD_w_dat(prompt13[m]);
}
}
if(!cd) // 插隊(duì)處理
{
clear_LCD();
gotoxy(1,0);
for(m=0;m<=6;m++)
{
LCD_w_dat(prompt14[m]);
}
Length Flag++;
for(i=1;i<Length Flag;i++)
rank[Length Flag-i]=rank[Length Flag-i-1];
rank[0]=10;
}
IT1=0;
}
復(fù)制代碼
作者:
GRE
時(shí)間:
2018-5-2 21:35
哭暈在廁所啦
作者:
陳林19861106
時(shí)間:
2018-5-2 23:37
02.void delay1ms(int n) void delay1ms(unsigned int ms)貌似重名
作者:
GRE
時(shí)間:
2018-5-3 00:43
1.C(1): warning C500: LICENSE ERROR (R208: RENEW LICENSE ID CODE (LIC))
1.C(14): error C141: syntax error near 'n', expected ')'
1.C(16): error C202: 'i': undefined identifier
這是報(bào)錯(cuò),不知道怎么改了,有沒有大神了該啊
作者:
GRE
時(shí)間:
2018-5-3 00:43
陳林19861106 發(fā)表于 2018-5-2 23:37
02.void delay1ms(int n) void delay1ms(unsigned int ms)貌似重名
1,14,16行報(bào)錯(cuò),也不知道到底哪里錯(cuò)了,哎
作者:
lilao3
時(shí)間:
2018-5-3 02:04
第一行,授權(quán)錯(cuò)誤,如果你用keil 則需要在網(wǎng)上下載keil的注冊(cè)機(jī),注冊(cè)后在編譯即可去掉警告,百度一下,會(huì)有很多。
第14行,語法錯(cuò)誤,uint沒有定義,改成unsigned int 即可,或在#include <reg52.h> 下一行加上一句 #define uint unsigned int 定義也行。
第16行,i沒有定義,在本函數(shù)里加 unsigned char i; 定義。
看了你的程序,可能還有錯(cuò)誤,多半是用到的變量沒定義。
作者:
774559006
時(shí)間:
2018-5-3 08:11
在14行那個(gè)函數(shù)定義一個(gè) int i;
作者:
xdata911
時(shí)間:
2018-5-4 21:35
報(bào)錯(cuò)不都說了,
LICENSE ERROR 許可證錯(cuò)誤
syntax error near 'n', expected ')' 語法錯(cuò)誤,在n和)附近
undefined identifier 未定義標(biāo)識(shí)符
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1