C51单片机编程中C语言如何嵌套汇编语言
#include #include #define uchar unsigned char#define uint unsigned intsbit 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,0x5...全部
#include #include #define uchar unsigned char#define uint unsigned intsbit 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。收起