爱问知识人 爱问教育 医院库

C51单片机编程中C语言如何嵌套汇编语言

首页

C51单片机编程中C语言如何嵌套汇编语言

C51单片机编程中C语言如何嵌套汇编语言  要详细一点的  最好有DS18B20的编程实例

提交回答

全部答案

    2018-05-06 19:43:19
  •   #include 
    #include
    #define uchar unsigned char
    #define uint unsigned int
    sbit DS=P3^3; //定义DS18B20接口
    int temp;
    uchar flag1;
    void display(unsigned char *lp,unsigned char lc);//数字的显示函数;lp为指向数组的地址,lc为显示的个数
    void delay();//延时子函数,5个空指令
    code unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef,0x40,0x39,0x00};//共阴数码管显示数的组成是 "0-9""0-9有小数点的" "-" "C" "空 表"
    unsigned char l_tmpdate[8]={0,0,10,0,0,0,0,0};//定义数组变量,并赋值1,2,3,4,5,6,7,8,就是本程序显示的八个数
    int tmp(void);
    void tmpchange(void);
    void tmpwritebyte(uchar dat);
    uchar tmpread(void);
    bit tmpreadbit(void);
    void dsreset(void);
    void delayb(uint count);
    void main() //主函数
    {
    uchar i;
    int l_tmp;
    while(1)
    {
    tmpchange(); //温度转换
    l_tmp=tmp(); //读取温度值
    if(l_tmp0)
    i--;
    count--;
    }


    答案补充
    }
    void dsreset(void)//DS18B20初始化
    {
    uint i;
    DS=0;
    i=103;
    while(i>0)i--;
    DS=1;
    i=4;
    while(i>0)i--;
    }
    bit tmpreadbit(void) // 读一位
    {
    uint i;
    bit dat;
    DS=0;i ; //小延时一下
    DS=1;i ;i ;
    dat=DS;
    i=8;while(i>0)i--;
    return (dat);
    }
    uchar tmpread(void) //读一个字节
    {
    uchar i,j,dat;
    dat=0;
    for(i=1;i>1); }
    return(dat); }


    答案补充
    void tmpwritebyte(uchar dat)
    {
    uint i;
    uchar j;
    bit testb;
    for(j=1;j>1;
    if(testb)
    {
    DS=0;
    i ;i ;
    DS=1;
    i=8;while(i>0)i--;
    }
    else
    {
    DS=0;
    i=8;while(i>0)i--;
    DS=1;
    i ;i ;
    }
    }
    }
    void tmpchange(void)
    {
    dsreset();
    delayb(1);
    tmpwritebyte(0xcc);
    tmpwritebyte(0x44);
    }

    答案补充
    int tmp() //获得温度
    {
    float tt;
    uchar a,b;
    dsreset();
    delayb(1);
    tmpwritebyte(0xcc);
    tmpwritebyte(0xbe); //发送读取数据命令
    a=tmpread(); //连续读两个字节数据
    b=tmpread();
    temp=b;
    temp0;a--)
    for(b=60;b>0;b--);
    }
    哇!好累啊。
      。。这个可以用。。。用那个口自己看看就懂了,如果要汇编语言的去看:
    http://hi。baidu。com/�๦�ܳ�����/blog/item/1f4f0ede8776141462279862。html。

    爱***

    2018-05-06 19:43:19

类似问题

换一换
  • 其他编程语言 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 170-189
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):