LCD显示的温度表的设计.docx

上传人:p** 文档编号:705438 上传时间:2024-01-18 格式:DOCX 页数:8 大小:56.13KB
下载 相关 举报
LCD显示的温度表的设计.docx_第1页
第1页 / 共8页
LCD显示的温度表的设计.docx_第2页
第2页 / 共8页
LCD显示的温度表的设计.docx_第3页
第3页 / 共8页
LCD显示的温度表的设计.docx_第4页
第4页 / 共8页
LCD显示的温度表的设计.docx_第5页
第5页 / 共8页
LCD显示的温度表的设计.docx_第6页
第6页 / 共8页
LCD显示的温度表的设计.docx_第7页
第7页 / 共8页
LCD显示的温度表的设计.docx_第8页
第8页 / 共8页
亲,该文档总共8页,全部预览完了,如果喜欢就下载吧!
资源描述

《LCD显示的温度表的设计.docx》由会员分享,可在线阅读,更多相关《LCD显示的温度表的设计.docx(8页珍藏版)》请在第壹文秘上搜索。

1、-bGN三16D2LC12 3 4 5 6 7Ddddddde-oC=33pfJ-JIL.C_C32.768kHzRA2RAIRA3RAORA40SC1MCLR0SC2VssVddRBORB7RB1RB6RB2RB5RB3RB4PIC16F84TemperatureDisplay8TLC555165LCDdisplayOfTemperatureTHERM.ASMShowsTemperaturefromThermistoronLCDLIST P=l6F84;16F84 Runs at 4 MHzINCLUDE pl6f84.inc_CONFIG _PWRTE_0N & _LP_OSC & _WD

2、T_0FF ; uses 32.768 kHz crystalERRORLEVEL -224ERRORLEVEL -302; supress annoying message because of tris ; supress message because of page change;Define Information#DEFINE RS PORTA, 0#DEFINE E PORTA, 1;Macro;RAO is RS line of LCD;RAl is E line OfLCD;RB0-RB3 are D4-D7 of LCDEStrobeMACRO;StrobetheErBit

3、bsfEbcfEENDMCBLOCKOCHTemp;atemporaryvariablecount;counterbin;binarynumbertobeconvertedtoBCDhundreds;BCDhundredsresultlens_and_ones;BCDtensandonesresultsavetmr;usedtosavevalueoftmrdispvalue;usedtoholdtemperaturetobedisplayedtableindex;pointstotablevaluetodisplayENDCORGO;startatlocation0goto main;jump

4、overtomainroutineDataformessagetobeoutputshomsg:addwfPCL,fmdtTMROValue:,OmldtTemperature,O;MessagetoOutput;OutputtheCharactersRatiosofPrescalerpreratio:addwfPCL,f;selectoffsetusingWdtD,2D,4,D,8,D,16,D,32,D64D,128;InitializetheponsInit:cirfPORTAclrfPORTBmovlwB,00010000,trisPORTAmovlwBWilOOOOtrisPORTB

5、movlwB1OOl(X)Oir;RA4input,othersoutputs;RB4.RB5input,othersoutputs;pull-upsenabled;prescalerassignedtoRA4;prescalersetto1:16optionreturn;InitializetheLCDinitlcd:movlwD40callnmsecbcfRSmovlw0x03callNybbleOutcallDlay5EStrobenopnopEStrobenopnopbcfRSmovlw0x02callNybbleOut;Wait40msecsbeforeReset;sendan8bi

6、linstruction;ResetCommand;SendtheNybble;Wait5msecsbeforeSendingAgain;Wait244useesbeforeSendingtheSecondTime;Wait244useesbeforeSendingtheThirdTime;sendan8bitinstruction;Set4BitModenopnopmovlw0x028callSendINSmovlwOxOlOcallSendINSmovlwOxOOlcallSendINScallDlay5movlw0x006callSendINSmovlwOx(X)C;4bit,2Line

7、,5x7font;displayshiftoff;CleartheDisplayRAM;Note,Cantakeupto4.1msecs;incrementcursor;displayoncursoroffcallSendINSreturnSendthecharacterinWouttotheLCDSendASCIIaddlw0,SendCHARmovwfTempswapfTemp,wbsfRScallNybbleOutmovfTemp,w;SendnbrasASCIIcharacter;SendtheCharactertotheLCD;SavetheTemporaryValue;Sendth

8、eHighNybble;RS=1;SendtheLowNybblebsfRScallNybbleOutreturnSendaninstructioninWouttotheLCDSendINSmovwfTempswapfTemp,wbcfRScallNybbleOutmovfTemp,W;SendtheInstructiontotheLCD;SavetheTemporaryValue;SendtheHighNybble;RS=O;SendtheLowNybblebcfRScallNybbleOutreturnSendthenibbleinWouttotheLCDNybbleOul;SendaNy

9、bbletoIheLCDmovwfPORTBEStrobenopnop;StrobeouttheLCDDatareturnOutputthemessageontheLCDOutMessage:movwfFSR;PointatfirstletterOutLoop:movfFSR,w;GetpointerintoWincfFSR,f;Setupfornextlettercallshomsg;Gelcharactertooutputiorlw0;AttheEndoftheMessage?btfscSTATUS,Z;Skipifnotatendreturn;Yes-EqualtoZerocallSen

10、dCHAR;OutputtheASCIICharactergotoOutLoop;GetthenextcharacterChangebinarynbrinbintoBCDbinary_to_bcd;byScottDattaloclrfhundredsSWiipfbin,Waddwfbin,WandlwB,0000111skpndcaddlw0x16skpndcaddlw0x06addlw0x06skpdcaddlw-0x06btfscbin,4addlwOx16-1+0x6skpdcaddlw-0x06btfscbin,5addlw0x30btfscbin,6addlw0x60btfscbin

11、,7addlw0x20addlw0x60rlfhundreds,fbtfsshundreds,0addlw-0x60movwftens_and_onesbtfscbin,7incfhundreds,freturnDelayroutinemsec250movlw0;250msecdelay(adjustedtotryand;allowfor2.5%lowlooptime)goto$+2Dlay5movlw5;delayfor5millisecondsnmsec:;delayfor#msecinWonentrynop;eachnopis0.122millisecondsnopnop;eachtot

12、alloopis8X0.122=0.976msecnopaddlwHFF;sameassubtracting1fromWhtfssSTATUS,Z;skipifresultiszerogotonmsec;thisis2X0.122msecreturn;backtocallingpointDisplaybinaryvalueinWindecimalDispDecmovwfbincallbinary_to_bcdmovfhundreds,WcallSendASCIIswapftens_and_ones,WandlwHFcallSendASCIImovftens_and_ones,WandlwH,F

13、callSendASCIIreturnTheMainroutinemain:callInit;initializeports,setuptimercallinitlcd;initializetheLCDmovlwH,80;positionat1stlinecolumn0callSendINSmovlwm-2;sendTMR0Value:messagecallOutMessagemovlwH,C0callSendINS;positionat2ndlinecolumn0movlwml-2;sendTemperature:messagecallOutMessagesholoop:movlwH8C;p

14、ositionat1stlinecolumn12callSendINSbcfINTCON,TOIFClrfTMROcallmsec250callmsec250callmsec250callmsec250movfTMRO,WmovwfsavetmrbtfscINTCON,TOIFgotooverloadcallDispDecmovlwHCCcallSendINSmovlw2movwfPCLATHmovlwD,64subwfsavetmr,WmovwftableindexcallIemptablelmovwfdispvalueswapfdispvalue,WandlwH,OF,callSendASCIImovfdispvalue,WandlwH,OF,callSendASCIImovlw.,callSendCHARmovlw3mo

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 通信/电子 > 电子设计

copyright@ 2008-2023 1wenmi网站版权所有

经营许可证编号:宁ICP备2022001189号-1

本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。第壹文秘仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知第壹文秘网,我们立即给予删除!