《LCD显示的温度表的设计.docx》由会员分享,可在线阅读,更多相关《LCD显示的温度表的设计.docx(8页珍藏版)》请在第一文库网上搜索。
1、-bGN16D2LC12 3 4 5 6 7Ddddddde-oC=33pfJ-JI1.C_C32.768kHzRA2RAIRA3RAORA40SC1MC1R0SC2VssVddRBORB7RB1RB6RB2RB5RB3RB4PIC16F84TemperatureDisp1ay8T1C5551651CDdisp1ayOfTemperatureTHERM.ASMShowsTemperaturefromThermistoron1CDINC1UDEp16f84.inc_CONFIG_PWRTE_0N&_1P_OSC&_WDT_0FF;uses32.768kHzcrysta1ERROR1EVE1-22
2、4ERROR1EVE1-302;supressannoyingmessagebecauseoftris;supressmessagebecauseofpagechange;DefineInformation#DEFINERSPORTA,0#DEFINEEPORTA,1;Macro;RAOisRS1ineof1CD;RA1isE1ineOf1CD;RB0-RB3areD4-D7of1CDEStrobeMACRO;StrobetheErBitbsfEbcfEENDMCB1OCKOCHTemp;atemporaryvariab1ecount;counterbin;binarynumbertobeco
3、nvertedtoBCDhundreds;BCDhundredsresu1t1ens_and_ones;BCDtensandonesresu1tsavetmr;usedtosaveva1ueoftmrdispva1ue;usedtoho1dtemperaturetobedisp1ayedtab1eindex;pointstotab1eva1uetodisp1ayENDCORGO;startat1ocation0gotomain;jumpovertomainroutineDataformessagetobeoutputshomsg:addwfPC1,fmdtTMROVa1ue:,Om1dtTem
4、perature,O;MessagetoOutput;OutputtheCharactersRatiosofPresca1erpreratio:addwfPC1,f;se1ectoffsetusingWdtD,2D,4,D,8,D,16,D,32,D64D,128;Initia1izetheponsInit:cirfPORTAc1rfPORTBmov1wB,00010000,trisPORTAmov1wBWi1OOOOtrisPORTBmov1wB1OO1(X)Oir;RA4input,othersoutputs;RB4.RB5input,othersoutputs;pu11-upsenab1
5、ed;presca1erassignedtoRA4;presca1ersetto1:16optionreturn;Initia1izethe1CDinit1cd:mov1wD40ca11nmsecbcfRSmov1w0x03ca11Nybb1eOutca11D1ay5EStrobenopnopEStrobenopnopbcfRSmov1w0x02ca11Nybb1eOut;Wait40msecsbeforeReset;sendan8bi1instruction;ResetCommand;SendtheNybb1e;Wait5msecsbeforeSendingAgain;Wait244usee
6、sbeforeSendingtheSecondTime;Wait244useesbeforeSendingtheThirdTime;sendan8bitinstruction;Set4BitModenopnopmov1w0x028ca11SendINSmov1wOxO1Oca11SendINSmov1wOxOO1ca11SendINSca11D1ay5mov1w0x006ca11SendINSmov1wOx(X)C;4bit,21ine,5x7font;disp1ayshiftoff;C1eartheDisp1ayRAM;Note,Cantakeupto4.1msecs;incrementcu
7、rsor;disp1ayoncursoroffca11SendINSreturnSendthecharacterinWouttothe1CDSendASCIIadd1w0,SendCHARmovwfTempswapfTemp,wbsfRSca11Nybb1eOutmovfTemp,w;SendnbrasASCIIcharacter;SendtheCharactertothe1CD;SavetheTemporaryVa1ue;SendtheHighNybb1e;RS=1;Sendthe1owNybb1ebsfRSca11Nybb1eOutreturnSendaninstructioninWout
8、tothe1CDSendINSmovwfTempswapfTemp,wbcfRSca11Nybb1eOutmovfTemp,W;SendtheInstructiontothe1CD;SavetheTemporaryVa1ue;SendtheHighNybb1e;RS=O;Sendthe1owNybb1ebcfRSca11Nybb1eOutreturnSendthenibb1einWouttothe1CDNybb1eOu1;SendaNybb1etoIhe1CDmovwfPORTBEStrobenopnop;Strobeoutthe1CDDatareturnOutputthemessageont
9、he1CDOutMessage:movwfFSR;Pointatfirst1etterOut1oop:movfFSR,w;GetpointerintoWincfFSR,f;Setupfornext1etterca11shomsg;Ge1charactertooutputior1w0;AttheEndoftheMessage?btfscSTATUS,Z;Skipifnotatendreturn;Yes-Equa1toZeroca11SendCHAR;OutputtheASCIICharactergotoOut1oop;GetthenextcharacterChangebinarynbrinbin
10、toBCDbinary_to_bcd;byScottDatta1oc1rfhundredsSWiipfbin,Waddwfbin,Wand1wB,0000111skpndcadd1w0x16skpndcadd1w0x06add1w0x06skpdcadd1w-0x06btfscbin,4add1wOx16-1+0x6skpdcadd1w-0x06btfscbin,5add1w0x30btfscbin,6add1w0x60btfscbin,7add1w0x20add1w0x60r1fhundreds,fbtfsshundreds,0add1w-0x60movwftens_and_onesbtfs
11、cbin,7incfhundreds,freturnDe1ayroutinemsec250mov1w0;250msecde1ay(adjustedtotryand;a11owfor2.5%1ow1ooptime)goto$+2D1ay5mov1w5;de1ayfor5mi11isecondsnmsec:;de1ayfor#msecinWonentrynop;eachnopis0.122mi11isecondsnopnop;eachtota11oopis8X0.122=0.976msecnopadd1wHFF;sameassubtracting1fromWhtfssSTATUS,Z;skipif
12、resu1tiszerogotonmsec;thisis2X0.122msecreturn;backtoca11ingpointDisp1aybinaryva1ueinWindecima1DispDecmovwfbinca11binary_to_bcdmovfhundreds,Wca11SendASCIIswapftens_and_ones,Wand1wHFca11SendASCIImovftens_and_ones,Wand1wH,Fca11SendASCIIreturnTheMainroutinemain:ca11Init;initia1izeports,setuptimerca11ini
13、t1cd;initia1izethe1CDmov1wH,80;positionat1st1ineco1umn0ca11SendINSmov1wm-2;sendTMR0Va1ue:messageca11OutMessagemov1wH,C0ca11SendINS;positionat2nd1ineco1umn0mov1wm1-2;sendTemperature:messageca11OutMessagesho1oop:mov1wH8C;positionat1st1ineco1umn12ca11SendINSbcfINTCON,TOIFC1rfTMROca11msec250ca11msec250c
14、a11msec250ca11msec250movfTMRO,WmovwfsavetmrbtfscINTCON,TOIFgotoover1oadca11DispDecmov1wHCCca11SendINSmov1w2movwfPC1ATHmov1wD,64subwfsavetmr,Wmovwftab1eindexca11Iemptab1e1movwfdispva1ueswapfdispva1ue,Wand1wH,OF,ca11SendASCIImovfdispva1ue,Wand1wH,OF,ca11SendASCIImov1w.,ca11SendCHARmov1w3movwfPC1ATHmovfUb1eindex,Wca11temptab1e2ca11SendASCIIgotosho1oopover1oadmov1wOca11SendCHARmov1w,Vca11S