找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1676|回復: 2
打印 上一主題 下一主題
收起左側

52單片機用12864液晶制作時鐘,請大家?guī)兔纯?感謝error C141: syntax error near ...

[復制鏈接]
跳轉到指定樓層
樓主
ID:986164 發(fā)表于 2022-1-9 16:08 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
用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初始化函數(shù)
void write_byte(uchar date);        //寫一個字節(jié)函數(shù)
uchar read_byte();                        //讀一個字節(jié)函數(shù)
void write_add(uchar address,uchar date);        //指定地址寫一個字節(jié)
void read_add(uchar address);                                //指定地址讀一個字節(jié)


#endif
函數(shù)
#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初始化函數(shù)
{
        sda=1;
        delay0();
        scl=1;
        delay0();        
}
void write_byte(uchar date)                //寫一個字節(jié)函數(shù)
{
        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()                //讀一個字節(jié)函數(shù)
{
        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)        //指定地址寫一個字節(jié)
{
        start();
        write_byte(0xa0);
        respons();
        write_byte(address);
        respons();
        write_byte(date);
        respons();
        stop();
}
void read_add(uchar address)        //指定地址讀一個字節(jié)
{
        uchar date;
        start();
        write_byte(0xa0);
        respons();
        write_byte(address);
        respons();
        start();
        write_byte(0xa1);
        respons();
        date=read_byte();
        stop();
        return date;               
}

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發(fā)
ID:68189 發(fā)表于 2022-1-10 14:10 | 只看該作者
頭文件中的 uchar 沒有定義,而報錯.在前面定義一下:#define uchar unsigned char
回復

使用道具 舉報

板凳
ID:986164 發(fā)表于 2022-1-10 15:02 | 只看該作者
好的,知道了,感謝
回復

使用道具 舉報

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

本版積分規(guī)則

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

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

快速回復 返回頂部 返回列表