




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Temperature Display661827TLC5553645RA3RAORA4OSC1MCLRSC2VssVddRBORB7RB1RB6RB2RB5PIC16F84RB3RB4o 1 EDD ooo6 DLCD display of TemperatureTHERM.ASM Shows Temperature from Thermistor on LCDLIST P=16F84;16F84 Runs at 4 MHzINCLUDE Hpl6f84.incnCONFIG PWRTE ON & LP OSC & WDT OFF ; uses 32.768 kHz crystalERROR
2、LEVEL -224; supress annoying message because of trisERRORLEVEL -302; supress message because of page change;Define Information#DEFTNE RS PORTA, 0#DEFINE E PORTA, 1;Macro;RAO is RS line of LCD;RAI is E line of LCD;RB0-RB3 are D4-D7 of LCDEStrobe MACRO; Strobe the nEn Bitbsf E bcf E ENDMCBLOCKOCHTemp;
3、a temporary variablecount;counterbin;binary number to be converted to BCDhundreds;BCD hundreds resulttens_and_ones;BCD tens and ones resultsavetmrO;used to save value of tmrOdispvalue;used to hold temperature to be displayedtableindex;points to table value to displayENDCORG 0; start at location 0got
4、o main; jump over to main routineData for message to be output; Message to Output; Output the Charactersshomsg:addwf PCL, f mO dtnTMR0 Value:H,0ml dtTemperature11,0Ratios of Prescalerpreratio:addwf PCL, f; select offset using Wdt D2,D4,D8,D16,D32,DD4,D128Initialize the portsInit:clrf PORTAclrf PORTB
5、movlw B WO 10000, tris PORTAmovlw BOO 110000tris PORTBmovlw BOO 100011,optionreturn;RA4 input, others outputs;RB4, RB5 input, others outputs;pull-ups enabled;prescaler assigned to RA4;prescaler set to 1:16initlcd:movlw D40 call nmsec bcf RS movlw 0 x03 call NybbleOut call Dlay5 EStrobe nop nop EStro
6、benop nop bcf RS movlw 0 x02 call NybbleOutInitialize the LCD; Wait 40 msecs before Reset; send an 8 bit instruction;Reset Command;Send the Nybble; Wait 5 msecs before Sending Again; Wait 244 usees before Sending the Second Time; Wait 244 usees before Sending the Third Time;send an 8 bit instruction
7、;Set 4 Bit Modenop nop movlw 0 x028 call SendINS movlw 0 x010 call SendINS movlw 0 x001 call SendINS call Dlay5 movlw 0 x006 call SendINS movlw OxOOC call SendINS return; 4 bit, 2 Line, 5x7 font; display shift off;Clear the Display RAM; Note, Can take up to 4.1 msecs;increment cursor; display on cur
8、sor offSend the character in W out to the LCDSendASCIIaddlw OSendCHAR movwf Temp swapf Temp, w bsf RS call NybbleOut movf Temp, w bsf RS call NybbleOut returnSend nbr as ASCII character;Send the Character to the LCD;Save the Temporary Value;Send the High Nybble;RS= 1;Send the Low NybbleSend an instr
9、uction in W out to the LCDSendINSmovwf Temp swapf Temp, wbcf RScall NybbleOut movf Temp, w bcf RScall NybbleOut return; Send the Instruction to the LCD;Save the Temporary Value;Send the High Nybble;RS = 0;Send the Low NybbleSend the nibble in W out to the LCDNybbleOut; Send a Nybble to the LCDmovwf
10、PORTB EStrobe; Strobe out the LCD Datanop nopreturnOutput the message on the LCDOutMessage:movwfFSRPoint at first letterOutLoop:movfincfcalliorlwbtfscFSR, wFSR, f shomsg 0STATUS, Zreturn call; Get pointer into W; Set up for next letter; Get character to output; At the End of the Message?; Skip if no
11、t at end; Yes - Equal to ZerogotoSendCHAROutLoop; Output the ASCII CharacterGet the next characterChange binary nbr in bin to BCDbinary_to_bcdbinary_to_bcd;by Scott Dattaloclrf hundreds swapf bin, W addwf bin, W andlwBOOOOllir skpndcaddlw 0 x16 skpndcaddlw 0 x06addlw 0 x06 skpdc addlw -0 x06 btfsc b
12、in,4addlw Ox 16 - 1 + 0 x6 skpdcaddlw -0 x06btfsc bin,5 addlw 0 x30btfsc bin, 6 addlw 0 x60btfsc bin,7addlw 0 x20addlw 0 x60 rlf hundreds, f btfss hundreds, 0addlw -0 x60 movwf tens_and_ones btfsc bin,7incf hundreds, f returnDelay routinemsec250 movlw 0goto $+2DIay5 movlw 5 nmsec:nopnopnopnop addlw
13、HFF btfss STATUS, Z goto nmsec return;250 msec delay (adjusted to try and;allow for 2.5% low loop time);delay for 5 milliseconds;delay for # msec in W on entry;each nop is 0.122 milliseconds;each total loop is 8 X 0.122 = 0.976 msec;same as subtracting 1 from W;skip if result is zero;this is 2 X 0.1
14、22 msec;back to calling pointDisplay binary value in W in decimalDispDecmovwf bincall binary_to_bcd movf hundreds, W call SendASCII swapf tens_and_ones, W andlw HFcall SendASCIImovf tens_and_ones, W andlw HFcall SendASCII returnThe Main routinemain:call Init call initlcd movlw H80 call SendINS movlw
15、 mO -2 call OutMessage movlw HCO, call SendINS movlw ml -2 call OutMessage sholoop:movlw H8Ccall SendINS;initialize ports, set up timer;initialize the LCD;position at 1st line column 0;send *TMR0 Value: message;position at 2nd line column 0;send Temperature:* message;position at 1st line column 12;c
16、lear timer zero interrupt flag;zero TMRO;wait a total of one second;retrieve timer zero;save the value;check if timer overflowed;yes, display OVR1;display TMRO value;position at 2nd line column 12;set up PCLATH to page 2;1 st table value is for tmrO = 64;subtract 64 from tmrO value;get 1st two digit
17、s of temperature;save it in display value;get hi nibble in W;lowest 4 bits;display it;get lo nibble in W;lowest 4 bits;display it;send decimal point;set up for second table, (page 3);get decimal point;display it;repeat forever;output OVER;and continuebcf INTCON, TOIF clrfTMRO call msec250 call msec2
18、50 call msec250 call msec250 movfTMRO, W movwf savetmrO btfsc INTCON, TOIF goto overload call DispDec movlw HCC call SendINS movlw 2movwf PCLATH movlw D64subwf savetmrO, W movwf tableindex call temptablei movwf dispvalue swapf dispvalue, W andlw HOF call SendASCII movf dispvalue, W andlw HOF call Se
19、ndASCII movlwcall SendCHAR movlw 3movwf PCLATH movf tableindex, W call temptable2 call SendASCII goto sholoop overloadmovlw O call SendCHAR movlw V call SendCHAR movlw E* call SendCHAR movlw R, call SendCHAR movlw call SendCHAR goto sholooporg H20(T temptablei:; get temperature to displayaddwf PCL,
20、fdt 33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,40,41,41,42,42,43 dt 43,44,44,45,45,46,46,46,47,47,48,48,49,49,50,50,50,51,51,52,52 dt 53,53,53,54,54,55,55,56,56,56,57,57,58,58,58,59,59,60,60,60,61 dt 61,62,62,62,63,63,64,64,64,65,65,66,66,66,67,67,67,68,68,69,69 dt 69,70,70,70,71,71,72,72,72,73,73,73,74,74,74,75,75,75,76,76,77 dt 77,77,78,78,78,79,79,79,80,
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 電商平臺(tái)中內(nèi)容營(yíng)銷的核心要素與技巧
- 2025至2030年中國(guó)豬頭數(shù)據(jù)監(jiān)測(cè)研究報(bào)告
- 生態(tài)文明在農(nóng)業(yè)可持續(xù)發(fā)展中的作用
- 協(xié)會(huì)臨時(shí)合同范本
- 社交媒體在企業(yè)商務(wù)活動(dòng)中的有效利用
- 電商平臺(tái)的文化營(yíng)銷與社會(huì)責(zé)任承擔(dān)
- 2025至2030年中國(guó)混凝土膠合覆膜板數(shù)據(jù)監(jiān)測(cè)研究報(bào)告
- 科技創(chuàng)新背景下的綠色醫(yī)療物流與新能源自卸車研究
- 科技行業(yè)市場(chǎng)解析與戰(zhàn)略發(fā)展探討
- 2024年浙江杭州安孚商業(yè)管理有限公司人員招聘考試真題
- 2024年河北省公務(wù)員考試《行測(cè)》真題及答案解析
- 期末復(fù)習(xí)試題(試題)-2024-2025學(xué)年四年級(jí)上冊(cè)數(shù)學(xué)人教版
- 培訓(xùn)機(jī)構(gòu)收費(fèi)退費(fèi)管理規(guī)定
- JJF 2161-2024焊接檢驗(yàn)尺校準(zhǔn)規(guī)范
- 臨床癲癇MR成像與常見疾病
- 《實(shí)踐論》(原文)毛澤東
- 《基巖標(biāo)建設(shè)技術(shù)導(dǎo)則》
- 2024年急危重癥患者鼻空腸營(yíng)養(yǎng)管管理專家共識(shí)
- 高考化學(xué)一輪復(fù)習(xí)課件微專題19 電解質(zhì)溶液圖像分析
- 2024年中考語(yǔ)文復(fù)習(xí)分類必刷:非連續(xù)性文本閱讀(含答案解析)
- 全國(guó)川教版信息技術(shù)八年級(jí)下冊(cè)第一單元第3節(jié)《打印展示作品》教學(xué)設(shè)計(jì)
評(píng)論
0/150
提交評(píng)論