欢迎来到课桌文档! | 帮助中心 课桌文档-建筑工程资料库
课桌文档
全部分类
  • 党建之窗>
  • 感悟体会>
  • 百家争鸣>
  • 教育整顿>
  • 文笔提升>
  • 热门分类>
  • 计划总结>
  • 致辞演讲>
  • 在线阅读>
  • ImageVerifierCode 换一换
    首页 课桌文档 > 资源分类 > DOCX文档下载  

    DHT2151AM2301汇编程序.docx

    • 资源ID:1502334       资源大小:27.44KB        全文页数:56页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    DHT2151AM2301汇编程序.docx

    ;DHT21运用范例;单片机:AT89S52或STC89C52RC;功能;串口发送温湖度数据波特率9600;硬件连接:P2.0口为通讯口连接DHTl1.DHTu的电源和地连接单片机的电源和地,单片机串口加MAX232连接电脑;一一变量定义区F1.AGEQU30HU8comdataEQU31HU8T_data_HEQU32HU8T_data_1.EQU33HU8RH_dala_HEQU34HU8RH_data_1.EQU35HU8checkdataEQU36HU8tempEQU37HtempEQU38Horg0000hAJMPSTARTorg0023hAJMPSET_INTSTART:MOVPO,#OFFHMOVTMOD,#20H;T1工作方式2;串口波特率为9600;串口工作于方式1并允许接受;启动Tl;允许串口中断;允许全部外设中断MOVTH1.tfOFDHMOVSCON,#50HSETBTRiSETBESSETBEAMAIN:;调用湿度读取子程序1.C1.1.RH;串口发送程序一一TT:MOVA,U8RH_data_H1.C1.1.TX_DATAMOVA,U8RH_data_1.1.C1.1.TX-DTMOVA,U8T_data_H1.C1.1.TX-DTMOVA,U8T_data_1.1.C1.1.TX-DTMOVA,U8checkdata1.C1.1.TX-DT延时两秒1.C1.1.Delay_2SIJMPMAIN;湿度读取子程序;一一以下变量均为全局变量;温度高8位=U8T_data_H;一一温度低8位=U8T_data_1.;湿度高8位=U8RH_data_H;一一湿度低8位=U8RH_data_1.:校验8位=UScheckdata;一一调用相关子程序如下:Read,DelayOUS,DelayRH:;主机拉低总线,延时50OUSC1.RP2.0MOV,8361.CA1.1.DelaySETBP2.0;延时40us1.C1.1.DelayJOus1.CA1.1.)elay_10us1.C1.1.Delay_10us1.CA1.1.DelayOUS;检测从机是否响应,无响应则跳出JBP2.O,Rl1.EM)MOVF1.AG,tt1.OOPl:INCF1.AGMOVA,F1.AGJBP2.O,1.OOP1_END;为高电平则跳出CJNEA,#0,1.ooPl1.JMPRH_END1.OOP1.END:MOVF1.AG,#01.00P2:INCF1.AGMOVA,F1.AGJNBP2.O,1.00P2_END;为低电平则跳出CJNE,#0,1.00P21.JMPRl1.EYD1.00P2,EN):进入数据接收阶段1.CA1.1.ReadMOVU8RH_data_H,U8comdata;1.CA1.1.ReadMOVU8RH_data_1.,U8comdata;1.CA1.1.ReadMOVU8T_data_H,U8comdata;1.C1.1.ReadMOVU8T_data_1.,U8comdata;1.CA1.1.ReadMOVU8checkdata,U8comdata;SETBP2.0;一一留意:本程序没有加校验程序假如用户须要校验请安以下说明编写校验程序;数据传送正确时校验和UScheckdata的值等于;"8bil海度整数数据+8bit湿度小数数据+8bi温度整数数据+8bit温度小数数据”所得结果的末8位RH_END:RET;读数子程序Read:MOVtemp,#8MOVU8comdata,#01.oOP/0M:;推断低电平是否结束MOVF1.AG,#01.00P3:INCF1.AGMOV,F1.AGJBP2.0,1.OOP3_END;为高电平则跳出CJNE,#0,1.ooP31.JMPCOM_END1.00P3_END:;C1.RP2.1:SETBP2.11.CA1.1.Delay_10us1.C1.1.Delay_10us1.CA1.1.Delay_10us:C1.RP2.1;SETBP2.1MOVU8temp,#0JNBP2.O,HIGl1.ENDMOVU8temp,SlHIGH_END:MOVF1.AG,#01.00P4:INCF1.AGMOVA,F1.AGJNBP2.O,1.ooP4_END;为低电平则跳出CJNE,tt,I.OOP41.JMPCOM_END1.OOP4_END:MOVA,F1.AGCJNEA,no,NO_FI.AG1.JMPCOM_ENDNO_F1.AG:MOVA,U8comdataR1.AOR1.,U8tempMOVU8comdata,A:推断高电平是否结束DJNZtemp,1>OOP_COMCOM_END:RET;延时函数Delay:MOVR4,A;2.5msDl:MOVR5,#0FFHDJNZR5,$DJNZR4,DlRET;延时IOus函数DclayJOus:;IOusNOPNOPNOPNOPNOPNOPRET;延时2S函数Delay_2S:MOVA,#2501.CA1.1.DelayMOVA,#2501.CA1.1.DelayMOVA,#2501.CA1.1.DelayMOVA,#2501.CA1.1.DelayMOVA,#2501.C1.1.DelayMOVA,#2501.CA1.1.DelayMOVA,#2501.CA1.1.DelayMOVA,#2501.C1.1.DelayRET;串口数据发送函数TX_)ATA:C1.RESMOVSBUF,AJNBTI,$C1.RTISETBESRET:串口中断函数SET_INT:C1.RESJNBR,$C1.RRIMOVA,SBUFMOVPO,MOVSBUF,A;禁止串口中断;将同一数据发送到串口;允许串口中断:禁止串口中断;接受串口数据;将串口数据送往POJNBTI,$C1.RTI;将同一数据发送到串口SETBES;允许串口中断RETIEND结束RSBITP3.4RWBITP3.5EBITP3.6DlBITP2.OD2BITP2.1D3BITP2.2IDSBITP2.4IRWBITP2.5IASBITP2.6ICSBITP2.7TTEQU39HFI.AGEQU30HU8comdataEQU31HU8T_data_HEQU32HU8T_data_1.EQU33HU8RH_data_HEQU34HU8RH_data_1.EQU35HU8checkdataEQU3611U8tempEQU37HtempEQU38HORGOOOOH1.JMPMAINORG0040HMAIN:MOVR3,ttMOVTT,#0MOVSP,#5FHCA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1.1.DE1.AYSETBECA1.1.DE1.AYC1.RERETWRD:SETBRSCA1.1.DE1.AYSETBECA1.1.DE1.AYC1.RERETDE1.AY:MOVR7,#5DE1.A:MOVR6,#0F9HDJNZR6,$DJNZR7,DE1.RETDE1.AY1:MOVR7,#120DE1.1:MOVR6,#0F9HDJNZR6,$DJNZR7,DE1.AlRETRH:MOVA,#361.C1.1.DE1.AY2SETBP2.31.C1.1.Delay_10usI-CA1.I.Delay_IOus1.C1.1.Delay_10us1.CA1.1.Delay_10usRHl:INCF1.AGMOV,F1.AGJBP2.3,RH1.ENDCJNE,#0,RHl1.JMPRH_ENDRH1_END:MOVF1.AG,#0RH2:INCF1.AGMOV,F1.AGJNBP2.3,RH2一ENDCJNE,#0,RH21.JMPRH_ENDRH2END:1.CIJ.ReadMOVU8RH_data_H,U8comdata;1.C1.1.ReadMOVU8RH_data_1.,U8comdata;1.CA1.1.ReadMOVU8T_data_H,U8comdata;1.CA1.1.ReadMOVU8T_data_1.,U8comdata;1.CA1.1.ReadMOVU8checkdata,U8comdata;SETBP2.3RH_END:RETRead:MOVtemp,#8MOVU8comdata,#01.OOP_COM:MOVF1.AG,#01.00P3:INCF1.AGMOVA,F1.AGCJNE,tt,I.OOP31.JMPCOM_END1.OOP3_END:1.C1.1.Delay_10us1.CA1.1.DelayOUS1.C1.1.Delay_10usMOVU8temp,#0JNBP2.3,HIGH_ENDMOVU8temp,#1HIGH_END:MOVF1.AG,n1.00P4:INCF1.AGMOV,F1.AGJNBP2.3,1.00P4_ENDCJNE,#0,1.oOP41.JMPCOM_EM)1.00P4_END:MOV,F1.AGCJNE,#0,NO_F1.AG1.JMPCOM_ENDNOF1.AG:MOV,>,U8comdataR1.OR1.A,U8tempMOVU8comdata,DJNZtemp,.OOP_COMCOM_END:RBTDE1.Y2:MOVR4,ADE1.2:MOVR5,#OFEHDJNZR5,$DJNZR4,DE1.A2RETDelayJOus:NOPNOPNOPNOPNOPNOPRETEND

    注意事项

    本文(DHT2151AM2301汇编程序.docx)为本站会员(夺命阿水)主动上传,课桌文档仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知课桌文档(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-1

    经营许可证:宁B2-20210002

    宁公网安备 64010402000986号

    课桌文档
    收起
    展开