找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3018|回复: 4
打印 上一主题 下一主题
收起左侧

keil4编程总是显示有错误,求大神解答

[复制链接]
跳转到指定楼层
#
ID:294964 发表于 2018-3-28 13:45 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
1黑币
本帖最后由 1903394084 于 2018-3-28 14:25 编辑

这是头文件
#ifndef _temp_H_
#define _temp_H_
#ifndef uchar
#define uchar unsigned char uchar
#endif
#ifndef uint
#define uint unsigned int
#endif
sbit DQ=P3^7;
uchar DSB20INIT();这一行总显示有错误
int READTIME();
void DSB20COM();
void DSB20CH();
void DSB20R();
void DSB20W();
void delayms(uint y);

#endif


这是c文件
#include"reg52.h"
#include"temp.h"
void delayms(uint y)
{
    uint x;
    for(;y>0;y--)
    {
        for(x=110;x>0;x--);
    }   
}
uchar DSB20INIT()
{
    uchar i;
    DQ=0;
    i=70;
    while(i--);
    DQ=1;
    i=0;
    while(DQ)
    {
        delayms(1);
        i++;
        if(i>5)
        {
            return 0;
        }
    }  
    return 1;
}
void DSB20W(uchar dat)
{
    uint i,j;
    for(j=0;j<8;j++)
    {
        DQ=0;
        i++;
        DQ=dat&0x01;
        i=6;
        while(i--);
        DQ=1;
        dat>>=1;
    }
}
void DSB20R(uchar byte)
{
    uint i,j;
    uchar bi;
    for(j=0;j<8;j++);
    {
        DQ=0;
        i++;
        DQ=1;
        i++;
        i++;
        bi=DQ;
        byte=(byte>>=1)|(bi<<=7)
        i=6;
        while(i--);
    }
    return byte;
}
void DSB20CH()
{
    DSB20INIT();
    delayms(1);
    DSB20W(0xcc);
    DSB20W(0x44);
}
void DSB20COM()
{
    DSB20INIT();
    delayms(1);
    DSB20W(0xcc);
    DSB20W(0xbe);   
}
int READTIME()
{
    int temp=0;
    uchar tml,tmh;
    DSB20CH();
    DSB20COM();
    tml=DSB20R();
    tmh=DSB20R();
    temp=tmh;
    temp<<=8;
    temp=temp|tml;
    return temp;
}

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

地板
ID:294964 发表于 2018-3-29 16:38 | 只看该作者
谢谢!
回复

使用道具 举报

板凳
ID:297224 发表于 2018-3-28 21:07 | 只看该作者
#define uchar unsigned char
#endif
回复

使用道具 举报

沙发
ID:298530 发表于 2018-3-28 20:10 | 只看该作者
定义uchar出错了,在上面的定义中#ifndef uchar
#define uchar unsigned char
#endif
改成这样就可以了
回复

使用道具 举报

楼主
ID:261288 发表于 2018-3-28 20:08 | 只看该作者
第四行最后多写一个uchar
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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