找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

各位大佬,已經(jīng)定義變量C語言程序還是顯示C202錯誤

[復(fù)制鏈接]
ID:1008285 發(fā)表于 2022-4-10 15:39 | 顯示全部樓層 |閱讀模式

        
               
               
                17_[RNQ0K8F_LADL4FHIU19.png

回復(fù)

使用道具 舉報

ID:94031 發(fā)表于 2022-4-10 16:10 | 顯示全部樓層
你的截圖并沒有Data聲明。
回復(fù)

使用道具 舉報

ID:956669 發(fā)表于 2022-4-10 16:13 來自觸屏版 | 顯示全部樓層
你只定義了無符號字符a,沒有定義Data,而且在你發(fā)的圖上我也沒看到,建議把所有代碼都發(fā)出來
回復(fù)

使用道具 舉報

ID:1008285 發(fā)表于 2022-4-10 16:23 | 顯示全部樓層
               
#include <reg52.h>
#include <intrins.h>
#include <absacc.h>
sbit IN0=P3^2;
#define uchar unsigned char
#define uint unsigned int
sbit TuiBi=P3^1;
uchar m=0;
uchar a;
sbit Row1=P1^0;
sbit Row2=P1^1;
sbit Row3=P1^2;
sbit Line1=P1^3;
sbit Line2=P1^4;
sbit Line3=P1^5;
uchar code chuhuo[]={0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};sbit LCD_EP=P3^6;
sbit LCD_RW=P3^5;
sbit LCD_RS=P3^4;
#define LCD_Out P0
#define LCD_In P0
code uchar LCD_addr[18]={
0x85,0xc5,0x86,0xc1,
0x81,0xc3,0x83,0xc3,
0x83,0xc0,0x81,0xc0,
        0x81,0xc6,0x84,0xc6,0x81,0xc3
};
code uchar LCD_InitialCode[]={0x30,0x30,0x30,0x38,0x01,0x06,0x0c};
uchar*string_s1,*string_s2;
uchar i,j;
void delay(uint count)
{
uint i;
        while(--count!=0)
                for(i=0;i<125;i++);
}
void main()
        {
                LCD();
                a=Data;
                EA=1;
                EX0=1;
                IT0=1;
                while(1)
                {
                Row1=0;Row2=0;Row3=0;Line1=1;Line2=1;Line3=1;TuiBi=1;
                P2=chuhuo[m];
                        delay (500) ;
                }
        }
        void into_ISR(void) interrupt 0
        {
        if (IN0==0)
        {
                delay(10);
                if(IN0==0)
                {
                        Row1=0;Row2=1;Row3=1;
                        if(Line1==0)
                        {
                                if(a>=1)
                                {
                                        m=1;a=a-1;Data=a;
                                        LCD();
                                }
                                else Tishi();
                                return;
                        }
                        else if (Line2==0)
                        {
                                m=5;a=a-2;Data=a;
                                LCD();
                        }
                        else Tishi();
                        return;
                }
                else if (Line3==0)
                {
                        if(a>=2)
                        {
                                m=6;a=a-2;Data=a;
                                LCD();
                        }
                        else Tishi();
                        return;
        }
               
        Row1=1;Row2=1;Row3=0;
        if (Line1==0)
        {
        if (a>=3)
        {
                m=8;a=a-3;Data=a;
                LCD();
        }
        else Tishi();
        return;
}
        else if(Line3==0)
        {
                TuiBi=0;
                String_s1="We appreciate yours";
                String_s2="Business,bye!";
                LCD();
                return
        }
}
        }
}

void LCD_DataWrite(unsigned char Data)
{
        unsigned int Read_Dat=0;
        LCD_EP=0;
        LCD_RS=0;
        LCD_RW=1;
        do{
        LCD_In=0xff;
                LCD_EP=1;
                Read_Dat=LCD_In&0x80;
                LCD_EP=0;
        }
        whlie(Read_Dat!=0);
        LCD_RW=0;
        LCD_RS=1;
        LCD_Out=Data;
        LCD_EP=1;
        LCD_EP=0;
}
        void LCD_RegWrite(uchar Command)
        {
        uint Read_Dat=0;
                LCD_EP=0;
                LCD_RS=0;
                LCD_RW=1;
                do {
                LCD_In=0xff;
                        LCD_EP=1;
                        Rrad_Dat=LCD_In&0x80;
                        LCD_EP=0;
                }
                whlie(Read_Dat!=0);
                LCD_RW=0;
                LCD_Out=Command;
                LCD_EP=1;
                LCD_EP=0;
        }
        unsigned char LCD_StatusRead(void)
        {
        unsigned char Read_Dat=0;
                LCD_EP=0;
                LCD_RS=0;
                LCD_RW=1;
                LCD_In=0xff;
                LCD_EP=1;
                Read_Dat=LCD_In;
                LCD_EP=0;
                return Read_Dat;
        }
void LCD_Init(void)
{
        uchar uiTemp=0,i;
        uchar *Point;
        Point=(uchar*)LCD_InitialCode;
        LCD_EP= 0;
        LCD_RS= 0;
        LCD_RW= 0;
        for(i=0;i<4;i++)
        {
        uiTemp=*Point++;
                LCD_Out = uiTemp;
                LCD_EP=1;
                LCD_EP=0;
                delay(5)
        }
        LCD_RegWrite(*Point++);
        LCD_RegWrite(*Point++);
        LCD_RegWrite(*Point++);
}
void LCD()
{
uchar uiTemp=O;
        LCD_Init();
        uiTemp= LCD_StatusRead();
        LCD_RegWrite(LCD_addr[i]);
        while((*String_s1)!=0)
                {
                        LCD_DataWrite(*String_s1);
}
                LCD_RegWrite(LCD_addr[j]);
while((*String_s2)!=0)
{
LCD_DaraWrite(*String_s2);
        String_s2++;
}

        void Tishi()
        {
        sbit d=P3^3;
        sbit c=P3^7;
        sbit f;
                void baojing()
                {
                EA=1;
                EX0=1;
                        IT0=1;
                        c=1;
                }
                if(
        }
void extero() interrupt 0
{
        f=1;
}
}
       
               
回復(fù)

使用道具 舉報

ID:1008285 發(fā)表于 2022-4-10 16:25 | 顯示全部樓層
文件在這

新建 Microsoft Word 文檔 (2).docx

15.06 KB, 下載次數(shù): 5

回復(fù)

使用道具 舉報

ID:1008285 發(fā)表于 2022-4-10 16:26 | 顯示全部樓層
余英杰 發(fā)表于 2022-4-10 16:13
你只定義了無符號字符a,沒有定義Data,而且在你發(fā)的圖上我也沒看到,建議把所有代碼都發(fā)出來

發(fā)在樓下了,麻煩大佬看看
回復(fù)

使用道具 舉報

ID:824490 發(fā)表于 2022-4-10 16:53 | 顯示全部樓層
LCD.C(38): warning C206: 'LCD': missing function-prototype
LCD.C(39): error C202: 'Data': undefined identifier
LCD.C(62): error C202: 'Data': undefined identifier
回復(fù)

使用道具 舉報

ID:625730 發(fā)表于 2022-4-10 17:25 | 顯示全部樓層
jxual 發(fā)表于 2022-4-10 16:26
發(fā)在樓下了,麻煩大佬看看

最好不要用Data做變量,C語言有些單詞是保留的,不能用做定義變量。

評分

參與人數(shù) 1黑幣 +5 收起 理由
13872888583 + 5

查看全部評分

回復(fù)

使用道具 舉報

ID:310441 發(fā)表于 2022-4-10 17:44 來自觸屏版 | 顯示全部樓層
TEC 發(fā)表于 2022-4-10 17:25
最好不要用Data做變量,C語言有些單詞是保留的,不能用做定義變量。

贊同,變量名稱還是設(shè)置的有明確的意義一點,既可以避免和關(guān)鍵字之類的沖突,也可以讓程序可讀性好一些
回復(fù)

使用道具 舉報

ID:970221 發(fā)表于 2022-4-10 18:35 來自觸屏版 | 顯示全部樓層
沒有看到程序?qū)ata的定義。
回復(fù)

使用道具 舉報

ID:970221 發(fā)表于 2022-4-10 18:39 來自觸屏版 | 顯示全部樓層
沒有看到程序中對Data的定義。void LCD_DataWrite(unsigned char Data)函數(shù)參數(shù)區(qū)定義的Data作用域限于該函數(shù)內(nèi)部,不能延伸到main中,而在全局區(qū)只定義了uchar a。避免報錯可在其后加上uchar Data;但這樣也需要恰當(dāng)?shù)某踔怠?/td>

評分

參與人數(shù) 1黑幣 +20 收起 理由
admin + 20 回帖助人的獎勵!

查看全部評分

回復(fù)

使用道具 舉報

ID:1017378 發(fā)表于 2022-4-11 00:48 | 顯示全部樓層
沒有看到程序中對Data的定義。void LCD_DataWrite(unsigned char Data)函數(shù)參數(shù)區(qū)定義的Data作用域限于該函數(shù)內(nèi)部,不能延伸到main中,而在全局區(qū)只定義了uchar a。
回復(fù)

使用道具 舉報

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

本版積分規(guī)則

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

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

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