欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3671|回復(fù): 4
收起左側(cè)

大神們幫個忙為什么我的程序會有這些錯誤》》

[復(fù)制鏈接]
ID:64215 發(fā)表于 2014-9-25 20:40 | 顯示全部樓層 |閱讀模式
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned uchar
#define uint unsigned uint

sbit trig=P1^2;
sbit echo=P1^0;

sbit LCD_RS=P1^0;
sbit LCD_RW=P1^1;
sbit LCD_EN=P1^2;
sbit LCD_PSB=P1^6;

bit flag;

void delay(uchar x )
{
  uchar i,j;
  for(j=0;j<x;j++)
          for(i=0;i<110;i++);
}
void write_cmd(uchar cmd)
{
        LCD_RS=0;
        LCD_RW=0;
        LCD_EN=0;
        P0=cmd;
        delay(5);
        LCD_EN=1;
        delay(5);
        LCD_EN=0;
}
void write_dat(uchar dat)
{
        LCD_RS=1;
        LCD_RW=0;
        LCD_EN=0;
        P0=dat;
        delay(5);
        LCD_EN=1;
        delay(5);
        LCD_EN=0;
}

void lcd_init()
{
        LCD_PSB=1;
        write_cmd(0x30);
        delay(5);
    write_cmd(0x0c);
        delay(5);
        write_cmd(0x01);
        delay(5);
}

void init()
{
        TMOD=0x01;
        TH0=0;
        TL0=0;
        TR0=0;
        IT0=1;
        EX0=1;
        EA=1;
        lcd_init();
}
uint test_distance(void)
{
        uint value;
        TH0=0;
        TL0=0;
        trig=0;
        _nop()_;
        trig=1;
        _nop_();_nop_();_nop_();_nop_();_nop_();
        _nop_();_nop_();_nop_();_nop_();_nop_();
        trig=0;
        while(!echo);
        TR0=1;
        while(echo);
        TR0=0;
        value=TH0*256+TL0;
        return value;       
}

void timer() interrupt 0;
{
        flag=1;
}

void lcd_pos(uchar x, uchar y)
{
        uchar pos;

        if(x == 0)           // 第一行的地址是80H
        {
                x = 0x80;
        }
               
        else if(x == 1)  //第二行的地址是90H
        {
                x = 0x90;       
        }
       
        else if(x == 2)  //第三行的地址是88H
        {
                x = 0x88;
        }
       
        else if(x == 3)
        {
                x = 0x98;
        }
       
        pos = x + y;
        write_cmd(pos);
}


void main()
{       
    uchar table[4];
        uint value;
        uint a,b,c,d,e,i;
        init();
        while(1)
        {
                if(flag)
                {
                        flag=0;
                        value=test_distance();
                           a=value/100;
                        b=a/2;
                        c=b*340;
                        e=c/10;
                        table[0]=e/1000;
                        table[1]=(e%1000)/100;
                        table[2]=((e%1000)%100)/10;
                    table[3]=e%10;
                        delay(5);
                        EA=1;
                }
        lcd_pos(0,0);
       
        for(i=0;i<4;i++)
        {
                write_dat(table[i]+0x30);
               
        }
       
        }
}



SS.C(16): error C141: syntax error near 'x', expected ')'
SS.C(18): error C231: 'uchar': redefinition
SS.C(18): error C141: syntax error near 'i'
SS.C(19): error C202: 'x': undefined identifier
SS.C(22): error C141: syntax error near 'cmd', expected ')'
SS.C(27): error C202: 'cmd': undefined identifier
SS.C(33): error C141: syntax error near 'dat', expected ')'
SS.C(38): error C202: 'dat': undefined identifier
SS.C(66): error C141: syntax error near ';'
SS.C(67): error C129: missing ';' before 'test_distance'
Target not created

回復(fù)

使用道具 舉報

ID:66661 發(fā)表于 2014-9-26 10:24 | 顯示全部樓層
回復(fù)

使用道具 舉報

無效樓層,該帖已經(jīng)被刪除
ID:66665 發(fā)表于 2014-9-26 12:17 | 顯示全部樓層
undefined identifier 未定義      其他很多都是未在英文狀態(tài)下寫的所以出錯了,重新寫一遍就好了
回復(fù)

使用道具 舉報

ID:2318 發(fā)表于 2014-9-26 12:40 來自觸屏版 | 顯示全部樓層
幻滅想 發(fā)表于 2014-9-26 12:17
undefined identifier 未定義      其他很多都是未在英文狀態(tài)下寫的所以出錯了,重新寫一遍就好了

這個答案是正解
回復(fù)

使用道具 舉報

ID:58502 發(fā)表于 2014-9-26 18:48 | 顯示全部樓層
#define uchar unsigned uchar
#define uint unsigned uint
這兩句定義錯了,后面的uchar改為char,后面的uint改為int,
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表