LCD显示的温度表的设计_第1页
LCD显示的温度表的设计_第2页
LCD显示的温度表的设计_第3页
LCD显示的温度表的设计_第4页
LCD显示的温度表的设计_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论