找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2855|回复: 2
收起左侧

KEIL程序编译提示未定义error C267: 'read': requires ANSI-style prototype

[复制链接]
ID:447439 发表于 2022-1-13 22:08 | 显示全部楼层 |阅读模式
10黑币
程序编译提示未定义,折腾一天了,实在头疼。麻烦帮忙看下。
标红的代码是提示出错的点!

void write(bit flag,uchar dat) //flag=0,write command;flag=1,write data
{
uchar i;
cd=flag; //flag=1,write command;flag=0,write data
cs = 0;
for(i = 0; i < 8; i++)
{
sda = dat & 0x80 ;
dat <<= 1 ;
sck = 1 ;
sck = 0 ;
        }

        cs = 1;

}

void init(void) //this subprogram is very important,please reference P50 of uc1698 datasheet
{
cs=0;

        /*************************reset*************************/
rst=0;
delay_ms(2); //reset
rst=1;
delay_ms(200);
write(0,0xe2); //24:reset by command
delay_ms(2);

        /**********************power control*********************/
write(0,0xe9); //27:Bias Ratio:1/10 bias
write(0,0x2b); //6:power control set as internal power
write(0,0x24); //5:set temperate compensation as 0%
write(0,0x81); //11:electronic potentionmeter
write(0,198);

        /**********************display control*******************/
write(0,0xa4); //16:all pixel off
write(0,0xa6); //17:inverse display off

/*************************lcd control********************/
write(0,0xc0); //19:partial display and MX disable,MY enable
write(0,0xa3); //15:line rate 15.2klps
write(0,0xd1); //21:rgb-rgb
write(0,0xd5); //18:4k color mode
write(0,0x84); //12:partial display control disable

/********************n-line inversion********************/
write(0,0xc8); //20,set n-line inversion
write(0,0x10); //enable NIV

/********************com scan fuction********************/
write(0,0xda); //23:enable FRC,PWM,LRM sequence

/***********************window****************************
*column and row set fix the display district,for example
*when AC[0]=1,AC[1]=0;(automatic wraparound,column first)
*column auto_icrement will restart after the end address
*********************************************************/

write(0,0xf4); //31:wpc0:column
write(0,0x25); //start from 130
write(0,0xf6); //33:wpc1
write(0,0x5A); //end of:272
write(0,0xf5); //32:wpp0:row
write(0,0x00); //start from 0
write(0,0xf7); //34:wpp1
write(0,0x9F); //end 160
write(0,0xf8); //35:inside mode
write(0,0x89); //13:RAM control
write(0,0xad); //18:display on,select on/off mode.Green Enhance mode disable


/************************scroll line*********************/

write(0,0x40); //8:low bit of scroll line
write(0,0x50); //8:high bit of scroll line
write(0,0xc4); //19,enable FLT and FLB
write(0,0x90); //14:FLT,FLB set
write(0,0x00);

/**********************partial display*******************/

write(0,0x84); //12,set partial display control:off
write(0,0xf1); //28:com end
write(0,0x9f); //160
write(0,0xf2); //29:display start
write(0,0); //0
write(0,0xf3); //30:display end
write(0,159); //160

}

void words(uchar x,uchar y,uchar type,uchar *p) //type=1,ascii;type=2,Chinese character
{                         //x,y fix the location where character display
uchar i,k,j,m,n,l,x0,dat0,dat1,dat2,dat3,dat4,dat5,dat6;//x should be the mutiples of 3
x=37+x;
x0=0x00|(x&0x0f);
x=0x10|((x&0xf0)>>4);
for(i=0;i<3;i++)
{
n=i*12*type;
for(j=0;j<8;j++)
{
m=i*8+j;
write(0,0x89);
write(0,x0);
write(0,x);
write(0,0x60|((y+m)&0x0f));
write(0,0x70|(((y+m)&0xf0)>>4));
for(k=0;k<2*type;k++) //a hexadecimal controlls 2 pixel
{                      //a display unit contains 3 pixel
l=k*6+n; //so column must be mutiples of 2 and 3
dat6=0x01<<j; //or else some colunm will be covered or lost
dat0=(*(p+l))&dat6;
dat0=dat0>>j;
dat0<<=7;

dat1=(*(p+l+1))&dat6;
dat1=dat1>>j;
dat1<<=3;

dat2=*(p+2+l)&dat6;
dat2=dat2>>j;
dat2<<=7;

dat3=(*(p+3+l))&dat6;
dat3=dat3>>j;
dat3<<=3;

dat4=(*(p+4+l))&dat6;
dat4=dat4>>j;
dat4<<=7;

dat5=(*(p+5+l))&dat6;
dat5=dat5>>j;
dat5<<=3;

write(1,dat0|dat1);
write(1,dat2|dat3);
write(1,dat4|dat5);

}

write(0,0x88);

}

}

write(0,0x89);

}

void picture(uchar *p)
{
uchar i,k;
write(0,0x60); //row address LSB
write(0,0x70); //row address MSB
write(0,0x05); //culomn address LSB
write(0,0x12); //culomn address MSB
        
for(i=0;i<160;i++)
{
for(k=0;k<81;k++) //1 hexadecimal controlls 2 pixel
{                 //a display unit contains 3 pixel
        write(1,*p++);
}
}
}

void lcdscan(uchar dat1,uchar dat2)
{
uchar i,j;
write(0,0x60); //row address LSB
write(0,0x70); //row address MSB
write(0,0x05); //culomn address LSB
write(0,0x12); //culomn address MSB
for(j=0;j<160;j++)
{
for(i=0;i<27;i++)
{
if(j%2==0)
{
write(1,dat1);
write(1,dat1);
write(1,dat1);
}
else
{
write(1,dat2);
write(1,dat2);
write(1,dat2);
}
}
}
}
        
void character(void)
{
uchar *q;
uchar i,j,temp[3],table[6];
lcdscan(0x00,0x00);
for(i=0;i<5;i++)
{
   q=hanzi+i*72;
   j=9*i+4;
   words(j,10,2,q);
}
for(i=0;i<11;i++)
{
   q=zimu+i*36;
   j=4*i+4;
   words(j,40,1,q);
}

for(i=11;i<18;i++)
{
   q=zimu+i*36;
   j=4*(i-11)+4;        
        
        words(j,70,1,q);
}
for(i=18;i<25;i++)
{
   q=zimu+i*36;
   j=4*(i-18)+1;
   words(j,100,1,q);
}

temp[0]=read(0);
temp[1]=read(0);
temp[2]=read(0);
table[0]=(temp[0]&0xf0)>>4;
table[1]=temp[0]&0x0f;
q=ascii+table[0]*36;
words(29,100,1,q);
q=ascii+table[1]*36;
words(33,100,1,q);


table[2]=(temp[1]&0xf0)>>4;
table[3]=temp[1]&0x0f;
q=ascii+table[2]*36;
words(37,100,1,q);
q=ascii+table[1]*36;
words(41,100,1,q);


table[4]=(temp[2]&0xf0)>>4;
table[5]=temp[2]&0x0f;
q=ascii+table[4]*36;
words(45,100,1,q);
q=ascii+table[5]*36;
words(49,100,1,q);

}

void readdata(void)
{
uchar l,m,n,*q;
write(0,0x88);
write(0,0x60); //row address LSB
write(0,0x70); //row address MSB
write(0,0x05); //culomn address LSB
write(0,0x12); //culomn address MSB
l=read(1);
m=(l&0xf0)>>4;
n=l&0x0f;
q=ascii+36*m;
words(0,130,1,q);
q=ascii+36*n;
words(5,130,1,q);
}

void main(void)
        
{
uchar *p;
uchar i,j,k;
bl=1;
IE=0X81;
IP=0X01;
TCON=0X00;
init();
while(1)
{

write(0,0x84); //12,set partial display off

lcdscan(0xf0,0x0f); //雪花
delay_ms(1000);

p=cha; //交叉图案
picture(p);
delay_ms(500);

// p=hui; //’回‘字图案
//picture(p);
//delay_ms(500);

write(0xff,0xff); //all pixel on
delay_ms(1500);

lcdscan(0xff,0x00); //横线
delay_ms(1000);
write(0,0x41); //scroll 1 line
delay_ms(1300);
write(0,0x40); //no scroll


lcdscan(0x0f,0x0f); //竖线
delay_ms(1000);
write(0,0xa7); //inverse display
delay_ms(1500);
write(0,0xa6);

// p=zi; //字符图案
// picture(p);
// delay_ms(800);

write(0,0x85); //12,set partial display on
for(i=40;i<=160;i+=40) //scroll the screen 8 times
{
j=i&0x0f;
k=(i&0xf0)>>4;

write(0,0x40|j); //low bit of scroll line
write(0,0x50|k); //high bit of scroll line
delay_ms(800);
}


write(0,0x40); //low bit of scroll line
write(0,0x50); //high bit of scroll line

// readdata();
// delay_ms(1500);


lcdscan(0x00,0x00);
character();
delay_ms(1300);

/* for(i=0;i<=32;i+=8) //ajust contrast
{
write(0,0x81); //electronic potentionmeter
write(0,180+i); //
delay_ms(1000);
}
write(0,0x81); //electronic potentionmeter
write(0,206); //
*/

lcdscan(0x00,0x00);
}
}
void innt0 () interrupt 0
{
do
{
key=1;
delay_us(500);
}
while(key==1);
}


main1.c(598): warning C206: 'read': missing function-prototype
main1.c(598): error C267: 'read': requires ANSI-style prototype
main1.c(648): error C202: 'bl': undefined identifier
Target not created.



最佳答案

查看完整内容

提示信息说的很清楚了,read()这个函数没找着,‘BI’这个变一没有定义。 要学会看提示信息的说。。。这个算是基本功了。
回复

使用道具 举报

ID:824490 发表于 2022-1-13 22:08 | 显示全部楼层
提示信息说的很清楚了,read()这个函数没找着,‘BI’这个变一没有定义。
要学会看提示信息的说。。。这个算是基本功了。
回复

使用道具 举报

ID:514901 发表于 2022-1-14 09:23 | 显示全部楼层
都是未定义,read函数和bl变量没有定义
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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