找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1671|回复: 11
收起左侧

各位大佬,已经定义变量C语言程序还是显示C202错误

[复制链接]
ID:1008285 发表于 2022-4-10 15:39 | 显示全部楼层 |阅读模式

        
               
               
                17_[RNQ0K8F_LADL4FHIU19.png

回复

使用道具 举报

ID:94031 发表于 2022-4-10 16:10 | 显示全部楼层
你的截图并没有Data声明。
回复

使用道具 举报

ID:956669 发表于 2022-4-10 16:13 来自手机 | 显示全部楼层
你只定义了无符号字符a,没有定义Data,而且在你发的图上我也没看到,建议把所有代码都发出来
回复

使用道具 举报

ID:1008285 发表于 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;
}
}
       
               
回复

使用道具 举报

ID:1008285 发表于 2022-4-10 16:25 | 显示全部楼层
文件在这

新建 Microsoft Word 文档 (2).docx

15.06 KB, 下载次数: 5

回复

使用道具 举报

ID:1008285 发表于 2022-4-10 16:26 | 显示全部楼层
余英杰 发表于 2022-4-10 16:13
你只定义了无符号字符a,没有定义Data,而且在你发的图上我也没看到,建议把所有代码都发出来

发在楼下了,麻烦大佬看看
回复

使用道具 举报

ID:824490 发表于 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
回复

使用道具 举报

ID:625730 发表于 2022-4-10 17:25 | 显示全部楼层
jxual 发表于 2022-4-10 16:26
发在楼下了,麻烦大佬看看

最好不要用Data做变量,C语言有些单词是保留的,不能用做定义变量。

评分

参与人数 1黑币 +5 收起 理由
13872888583 + 5

查看全部评分

回复

使用道具 举报

ID:310441 发表于 2022-4-10 17:44 来自手机 | 显示全部楼层
TEC 发表于 2022-4-10 17:25
最好不要用Data做变量,C语言有些单词是保留的,不能用做定义变量。

赞同,变量名称还是设置的有明确的意义一点,既可以避免和关键字之类的冲突,也可以让程序可读性好一些
回复

使用道具 举报

ID:970221 发表于 2022-4-10 18:35 来自手机 | 显示全部楼层
没有看到程序对Data的定义。
回复

使用道具 举报

ID:970221 发表于 2022-4-10 18:39 来自手机 | 显示全部楼层
没有看到程序中对Data的定义。void LCD_DataWrite(unsigned char Data)函数参数区定义的Data作用域限于该函数内部,不能延伸到main中,而在全局区只定义了uchar a。避免报错可在其后加上uchar Data;但这样也需要恰当的初值。

评分

参与人数 1黑币 +20 收起 理由
admin + 20 回帖助人的奖励!

查看全部评分

回复

使用道具 举报

ID:1017378 发表于 2022-4-11 00:48 | 显示全部楼层
没有看到程序中对Data的定义。void LCD_DataWrite(unsigned char Data)函数参数区定义的Data作用域限于该函数内部,不能延伸到main中,而在全局区只定义了uchar a。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表