首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > 单片机 >

求指教程序有个异常实在找不出啊来

2013-11-29 
求指教程序有个错误实在找不出啊来#includereg51.h#includeABSACC.h#includestdio.h#includeintrin

求指教程序有个错误实在找不出啊来
#include<reg51.h>
#include<ABSACC.h>
#include<stdio.h>
#include<intrins.h>
#define uchar unsigned char
#define unit unsigned int
sbit P3_6=P2^1;
sbit LcdRs=P3^2;
sbit LcdRw=P3^1;
sbit LcdEn=P3^0;
sbit P2_0=P2^0;
unit key_val=16;
unit m=0,count=0,count2=0;
unit pass=0,pass0=0,pass1=0,pass2=0,o=0,n=0;
unit co[6]={0,0,0,0,0,0};
unit cp[1]={0};
unit cq[7]={ 0,0,0,0,0,0 ,0};
uchar sk[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uchar password[16];
void DelayMs(unsigned int n){
unsigned int i,j;
for(i=0;i<n;i++)
for(j=0;j<120;j++);}
void Check_key(void){
unsigned int row,col,tmp1,tmp2;
tmp1=0x10;
for(row=0;row<4;row++){
P1=0x0f;
P1=~tmp1;
tmp1*=2;
if((P1&0x0f)<0x0f)
{DelayMs(30);
 if((P1&0x0f)<0x0f)
{ tmp2=0x01; 
 for (col=0;col<4;col++){
 if((P1&tmp2)==0x00){
 key_val=row*4+col;
 while ((P1&tmp2)==0x00);
return ;}
tmp2*=2;}
while((P1&tmp2)==0x00);}}} }
void rec_key(void)
{
if(key_val!=16){
if(m>6)
m=0;
if(count2==1)
{if (key_val==0){
sk[0]=1;
count++;
pass=0;
password[m]=0;
m++;
DelayMs(10);
P3_6=0;
DelayMs(100);
 
P3_6=1;
key_val=16;}
if(key_val==1){
sk[1]=1;
count++;
pass=1;
password[m]=1;
m++;
DelayMs(10);P3_6=0;
DelayMs(100);P3_6=1;
key_val=16;}
if(key_val==2 ){
sk[2]=1;
count++;
pass=2;
password[m]=2;
m++;
DelayMs(10);P3_6=0;
DelayMs(100);P3_6=1;
key_val=16;}
 if(key_val==3){
 sk[3]=1;
 count++;pass=3;password[m]=3;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;
 }
 if(key_val==4){
 sk[4]=1;
 count++;
 pass=4;
 password[m]=4;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==5){
 sk[5]=1;
 count++;
 pass=5;
 password[m]=5;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==6){
 sk[6]=1;
 count++;
 pass=6;
 password[m]=6;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==7){
 sk[7]=1;
 count++;
 pass=7;
 password[m]=7;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==8){
 sk[8]=1;
 count++;
 pass=8;
 password[m]=4;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==9){
 sk[9]=1;
 count++;
 pass=9;
 password[m]=9;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==10){
 sk[10]=1;
 count++;
 pass=10;
 password[m]=10;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==11){
 sk[11]=1;
 count++;
 pass=11;
 password[m]=11;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==12){
 sk[12]=1;
 count++;
 pass=12;
 password[m]=12;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==13){
 sk[13]=1;
 count++;
 pass=13;
 password[m]=16;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==14){
 sk[14]=1;
 count++;
 pass=14;
 password[m]=14;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(key_val==15){
 sk[15]=1;
 count++;
 pass=15;
 password[m]=15;
 m++;
 DelayMs(10);P3_6=0;
 DelayMs(100);P3_6=1;
 key_val=16;}
 if(m>10)
 m=0; }
 unsigned char LCD_Wait(void){//这行附近有个语法错误

 LcdEn=0;LcdRs=0;
 LcdRw=1;_nop_();
 LcdEn=1;_nop_();
 LcdEn=0;_nop_();
 while(DBPort&0x80)
 if(DBPort&0x80==0x80)
 return DBPort;}
#define LCD_COMMAND 0
#define LCD_DATA  1
#define LCD_CLEAR_SCREEN 0x01
#define LCD_HOMING  0x02
void LCD_Write(bit style,unsigned char input){
LCD_Wait();
LcdEn=0;
LcdRs=style;
LcdRw=0;_nop();
DBPort=input; _nop();
LcdEn=1;_nop();
LcdEn=0; _nop();
}
#define LCD_SHOW 0x04
#define LCD_HIDE 0x00
#define LCD_CURSOR 0x02
#define LCD_NO_CURSOR 0x00
#define LCD_FLASH 0x01
#define LCD_NO_FLASH 0x00
 void LCD_SetDisplay(unsigned char DisplayMode){
  LCD_Write(LCD_COMMAND,0x08|DisplayMode);}
  #define LCD_AC_Up 0x02
  #define LCD_AC_DOWN  0x00


  #define LCD_MOVE 0x01
  #define LCD_NO_MOVE 0x00
  void LCD_Setinput(unsigned char InputMode){
  LCD_Write(LCD_COMMAND,0x04|InputMode);}
  /*#define LCD_CURSOR 0x02
  void LCD_Move(unsigned char object ,unsigned char direction){
  if (object==LCD_CURSOR)
  LCD_Write(LCD_COMMAND,0x01|direction);
  if (object==LCD_SCREEN)
  LCD_Write(LCD_COMMAND,0x18| direction);}*/
  void LCD_Initial(){
  LcdEn=0;
  LCD_Write(LCD_COMMAND,0x38);
  LCD_Write(LCD_COMMAND,0x38);
  LCD_SetDisplay(LCD_SHOW|LCD_NO_CURSOR);
  LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN);
  LCD_SetInput(LCD_AC_UP|LCD_NO_MOVE);
  }
  void GotoXY(unsigned char x,unsigned char y)
  {
  if(y==0)
  LCD_Write(LCD_COMMAND,0x80|x);
  if(y==1)
  LCD_Write(LCD_COMMAND,0x80|(x-0x40));}
 void Print(unsigned char *str){
 while(*str!='\0'){
 LCD_Write(LCD_DATA,*str);}
 str++;}
 void LCD_LoadChar(unsigned char user[8],unsigned char place){
 unsigned char i;
 LCD_Write(LCD_COMMAND,0x40|(place*8));
 for(i=0;i<8;i++)
 LCD_Write(LCD_DATA,user[i]); }
 void main(void)
 int count1=0,count4=0,count6=0,count7=0,count8=0,P2_0=1;
 LCD_Intial();
 while(1){
 Check_Key();
 rec_key();
  if((count6==0)&(count7==0)){
  GotoXY(0,0);
  printf("locking"); }
  if(count4==1){
  GotoXY(0,0);
  printf("opening");}
  if(sk[15]==1){
  GotoXY(0,0);
   count=0;
   printf("clde:");
   count1=1;
   count2=1;
   count6=1;
   sk[15]=0;
   sk[14]=0;
   m=0;
   cp[0]=1;
   }
   if((count!=0)&&(count1==1)){
   if(cout1==1){
   GotoXY(0,0);print("old code:*");}
   if(count==2){
   GotoXY(0,0);print("old code:**");}
   if(count==3){
   GotoXY(0,0);print("old code:***");}
   if(count==4){
   GotoXY(0,0);print("old code:****");}
   if(count==5){
   GotoXY(0,0);print("old code:*****");}
if(count==6){
   GotoXY(0,0);print("old code:******");}
   count1=0;}  }
   if((sk[14]==1)&(count6==1)){
   if((password[0]==cq[0])&(password[1]==cq[1])&(password[2]==cq[2])&(password[3]==cq[3])&(password[4]==cq[4])&(password[5]==cq[5])&(count=6))  {
   GotoXY(0,0);print("door open!");
   sk[14]=0;
   count=0;
   count2=0;
   m=0;
   count4=1;count6=1;
   DealyMs(1000);
   P2_0=0;
   DElay_Ms(500);
   P2_0=1;
   LCD_Initial();
   cp[0]=0;
   }
   else{
   GotoXY(0,0);print("code wrong");
   DelayMS(1000);
sk[14]=0;
count=0;count2=0;
count6=0;m=0;P3_6=0;
 count4=1;count6=1;
 DelayMs(1000);
 DelayMs(100);
 DelayMs(3000);P3_6=1;LCD_Initial();cp[0]=0;}}
  if((sk[11]==1)&(cp[0]==0)){
  GotoXY(0,0);print("old code:");
  psss=1;
  count1=0;
  count=0;
  count7=1;
  count2=1;
   count6=0;
   sk[11]=0;
   }
   if((count!=0)&(pass==1)&(cp[0]==0)){
   pss0=0;
   if(count==1){
   GotoXY(0,0);print("old code:*");}
if(count==2){
   GotoXY(0,0);print("old code:**");}
   if(count==3){
   GotoXY(0,0);print("old code:***");}
   if(count==4){
   GotoXY(0,0);print("old code:****");}
   if(count==5){
   GotoXY(0,0);print("old code:*****");}
   if(count==6){
   GotoXY(0,0);print("old code:******");}
   m=0;}
   if((count!=0)&(pass0==1)&(cp[0]==0){
   pass=0;
   if(count==1){
   GotoXY(0,0);print("new code:*");}
   if(count==2){
   GotoXY(0,0);print("new code:**");}
   if(count==3){
   GotoXY(0,0);print("new code:***");}
   if(count==4){
   GotoXY(0,0);print("new code:****");}
   if(count==5){
   GotoXY(0,0);print("new code:*****");}
   if(count==6){
   GotoXY(0,0);print("new code:******");}
 m=0;}
   if(sk[14]==1)&(count7==1)){


   if((password[0]==cq[0])&(password[1]==cq[1])&(password[2]==cq[2])&
   (password[3]==cq[3])&(password[4]==cq[4])&(password[5]==cq[5])&(pass==1)&(count>6))
   {
   GotoXY(0,0);print("new code:");
   pass0=1;
   pass=0;
   sk[14]=0;
   count=0;
   count7=0;
   n=0;m=0;}
   else{GotoXY(0,0);ptint("old codewrong");
   sk[14]=0;
   count2=0;
   count7=0;
   pass=0;
   m=0;}}
   if(pa!=10)(pass0==1){
   if(n<7){
   co[n]=pa;
   n++;pa=10;
   }}
   if(sk[14]==1){
   if((n>7)&(count==6)){ GotoXY(0,0);print("set over!");
   cq[0]=co[1];cq[1]=co[2];cq[2]=co[3];cq[3]=co[4];
   cq[4]=co[5];cq[5]=co[6];
   n=0;pass0=0;
   pass1=1;
   sk[14]=0;
   count=0;
   count2=0;
   m=0;count7=0;
   }
   else{
    
   GotoXY(0,0);print("set wrong!");
   sk[14]=0;
   count2=0;count=0;
   count7=0;
   m=0;
   }}}}














  
  







[解决办法]
求指教程序有个异常实在找不出啊来
[解决办法]
靠,这么长又不指出错误行
[解决办法]
楼主要读下顶置的 提问的艺术
[解决办法]
楼主好强大,佩服佩服!!!

热点排行