标题:
52单片机用12864液晶制作时钟,请大家帮忙看看,感谢error C141: syntax error near ...
[打印本页]
作者:
xzxdbb
时间:
2022-1-9 16:08
标题:
52单片机用12864液晶制作时钟,请大家帮忙看看,感谢error C141: syntax error near ...
用keil uvision4编译错误
Build target '时钟'compiling main.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'
..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'
compiling pbdata.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'
compiling 24c02.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'
compiling key.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'
compiling xianshi.c.....\BSP\24C02.H(13): error C141: syntax error near 'date', expected ')'..\BSP\24C02.H(14): error C129: missing ';' before 'read_byte'Target not created
头文件
#ifndef __24C02_H_
#define __24C02_H_
bit write=0; //写24C02的标志
sbit sda =P2^0;
sbit scl =P2^1;
void delay0();
void start(); //开始信号
void stop(); //停止
void respons(); //应答
void init_24c02(); //I^2C初始化函数
void write_byte(uchar date); //写一个字节函数
uchar read_byte(); //读一个字节函数
void write_add(uchar address,uchar date); //指定地址写一个字节
void read_add(uchar address); //指定地址读一个字节
#endif
函数
#include "pbdata.h"
void delay0()
{;;}
void start() //开始信号
{
sda=1;
delay0();
scl=1;
delay0();
sda=0;
delay0();
}
void stop() //停止
{
sda=0;
delay0();
scl=1;
delay0();
sda=1;
delay0();
}
void respons() //应答
{
uchar i;
scl=1;
delay0();
while((sda==1)&&(i<250))
i++;
scl=0;
delay0();
}
void init_24c02() //I^2C初始化函数
{
sda=1;
delay0();
scl=1;
delay0();
}
void write_byte(uchar date) //写一个字节函数
{
uchar i,temp;
temp=date;
for(i=0;i<8;i++)
{
temp=temp<<1;
scl=0;
delay0();
sda=CY;
delay0();
scl=1;
delay0();
}
scl=0;
delay0();
sda=1;
delay0();
}
uchar read_byte() //读一个字节函数
{
uchar i,k;
scl=0;
delay0();
sda=1;
delay0();
for(i=0;i<8;i++)
{
scl=1;
delay0();
k=(k<<1)|sda;
scl=0;
delay0();
}
return k;
}
void write_add(uchar address,uchar date) //指定地址写一个字节
{
start();
write_byte(0xa0);
respons();
write_byte(address);
respons();
write_byte(date);
respons();
stop();
}
void read_add(uchar address) //指定地址读一个字节
{
uchar date;
start();
write_byte(0xa0);
respons();
write_byte(address);
respons();
start();
write_byte(0xa1);
respons();
date=read_byte();
stop();
return date;
}
作者:
wpppmlah
时间:
2022-1-10 14:10
头文件中的 uchar 没有定义,而报错.在前面定义一下:#define uchar unsigned char
作者:
xzxdbb
时间:
2022-1-10 15:02
好的,知道了,感谢
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1