《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,callSendAS
15、CIImovfdispvalue,WandlwH,OF,callSendASCIImovlw.,callSendCHARmovlw3movwfPCLATHmovfUbleindex,Wcalltemptable2callSendASCIIgotosholoopoverloadmovlwOcallSendCHARmovlw,VcallSendCHARmovlwE,callSendCHARmovlwR,callSendCHARmovlw,callSendCHARgotosholoop;cleartimerzerointerruptflag;zeroTMRO;waitatotalofonesecon
16、d;retrievetimerzero;savethevalue;checkiftimeroverflowed;yes,display,OVR;displayTMROvalue;positionat2ndlinecolumn12;setupPCLATHtopage2;1sttablevalueisforImrO=64;subtract64fromtmrvalue;get1sttwodigitsoftemperature;saveitindisplayvalue;gethinibbleinW;lowest4bits;displayit;getIonibbleinW;lowest4bits;dis
17、playit;senddecimalpoint;setuptorsecondtable,(page3);getdecimalpoint;displayit;repeatforever;outputOVER;andcontinueorgH,200,Iemptablel:;gettemperaturetodisplayaddwfPCL,fdt33,34,34,35,35,36,36,37,37,38,温39,39,40,40,40,41,41,42,42,43dt43,44,44,45,45,46,46,46,47,47,48,48,49,49,50,50,50,51,51,52,52dt53,5
18、3,53,54,54,55,55,56,56,56,57,57,58,58,58,59,59,60,60,60,61dt61,62,62,62,63,63,64,64,64,65,65,66,66,66,67,67,67,68,68,69,69dt69,70,70,70,71,71,72,72,72,73,73,73,74,74,74,75,75,75,76,76,77dt77,77,78,78,78,79,79,79,80,80,80,81,81,81,81,82,82,82,83,83,83dt84,84,84,85,85,85,86,86,86,86,87,87,87,88,88,88,
19、89,89,89,89,90dt90,90,91,91,91,91,92,92,92,92,93,93,93,94,94,94,94,95,95,95,95dt96,96,96,96,97,97,97,97,98,98,98,98,99,99,99,99,99,00,00,00dt00,01,01,01orgH,300,temptable2:addwfPCL,fdt7,2,7,2,7,2,6,1,6,1,5,0,5,0,4,9,4,8,3,827,1,6,1,5,0,4dt9,3,8,2,6,1,5,0,4,837,2,6,0,4,9,3,7,1,6,0,4,8,2,7,1,5dt9,3,7,1,5,9,3,7,1,5,9,3,7,1,5,9,3,7,0,4,8,2,6,9,3,7,1,4dt8,2,6,9,3,7,0,4,4,7,1,5,8,2,5,9,2,6,9,3,6,036,0,3,7,0dt3,7,0,3,6,0,3,6,9,3,6,9,2,5,8,2,5,8,1,4,7,0,3,6,9,258dt1,4,7,0,3,5,87,4,7,0,2,5,8,1,3,6,9,2,4,7,0,2,5,7,00,5dt8,0,3,5,8,0,3,5,8,0,357,0,2,4,7,9,1,4,6,8,0,3,5endthermistor在室温下为9K