控制/MCU
;振荡器1MHzR/C
;命令时钟250kHz
include
page1macro
bsfSTATUS,RP0;page1
endm
page0macro
bcfSTATUS,RP0;page0
endm
cbLOCk0ch
time1,temp
lo_val,hi_val,msn,lsn
digit1,digit2
count,read
ssave,wsave
flags
endc
;==================================
org00
gotoinit
org04
btfssINTCON,T0IF
gotoend_int
MOVwfwsave
swapfSTATUS,w
MOVwfssave;中断保护
decfcount,f
decfszread,f
gotoint2
calladconv;A/D
MOVlw.16;
MOVwfread
int2MOVfcount,0
btfscSTATUS,Z
bsfflags,0;eot
bcfINTCON,T0IF
end_intswapfssave,w
MOVwfSTATUS;
swapfwsave,f;
swapfwsave,w
retfie;
;==========查表===============
tableaddwfPCL;portb
retlwb’01110111’;0
retlwb’00010100’;1
retlwb’00111011’;2
retlwb’00111110’;3
retlwb’01011100’;4
retlwb’01101110’;5
retlwb’01101111’;6
retlwb’00110100’;7
retlwb’01111111’;8
retlwb’01111100’;9
retlw0
retlw0
retlw0
retlw0
retlw0
retlw0
retlw0
;*********************温度转变******************
lookupaddwfPCL
retlw.99;00
retlw.99;01
retlw.99;02
retlw.99;03
retlw.91;04
retlw.81;05
retlw.73;06
retlw.66;07
retlw.59;08
retlw.52;09
retlw.45;0A
retlw.39;0B
retlw.31;0C
retlw.23;0D
retlw.13;0E
retlw.0;0F
retlw.0;catchfor》f0h
;==========a/d转变值存到temp==========
interpMOVflsn,0;初值
swapflsn,w;swap&save
MOVwfmsn;intow
MOVlw0fh
andwflsn,f;stripoffupperrubbish
andwfmsn,f;stripoffupperrubbish
MOVfmsn,0;reload
calllookup;getvalue
MOVwflo_val;saveit
incfmsn,w;incrementpointer
calllookup;getnextvalue
subwflo_val,w;getdifference&save
MOVwfhi_val
multaddwfhi_val,f;addtocurrent
decfszlsn,f;countdownonmultiplyloop
gotomult
swapfhi_val,w;divideby16
andlw0fh;extractuppernibble
subwflo_val,w;addlovaluetolovaluetogetresult
return
adconvbsfADCON0,GO;startconversion
MOVlw.5;waitdelay10uS
MOVwftemp
decfsztemp,f;loopforawhile
goto$-1
btfscADCON0,GO;testforendofconversion
goto$-1
retlw0
bin_bcdMOVwfdigit1;firstdigit
clrfdigit2;seconddigit
tenlopMOVlw.10
subwfdigit1,w;findouthowmany10’s
btfscSTATUS,C
incfdigit2,f
btfscSTATUS,C
MOVwfdigit1;remainder1’sleft
btfscSTATUS,C
gototenlop
return
;=======================================
initclrfPORTB
clrfPORTA
clrfADCON0
clrfflags
page1
MOVlwb’11110011’
MOVwfTRISA
MOVlwb’10000000’;
MOVwfTRISB;setupportb
MOVlwb’00000100’;/32
MOVwfOPTION_REG
MOVlwb’00000010’
MOVwfADCON1
page0
MOVlwb’00001000’;setupchangeofstateonportb
MOVwfINTCON;towakeup
sleep;shutdown
MOVlwb’11000001’;seta/dinternalrcclock
;channel0,a/drunning
MOVwfADCON0;doit
MOVlw.153;timeoutvalue
MOVwfcount
MOVlw.16;intervaltimerreload
MOVwfread
MOVlwb’10100000’;setupchangeofstateonportb
MOVwfINTCON;towakeup
calladconv;performA/Dconversion
;==================main====================
mainbtfscflags,0;testfortimeout
gotoinit;yessoshutdown
MOVfADRES,0;loadvalue
MOVwflsn;storeforconversion
callinterp;usinginterpolationmethod
callbin_bcd;convertinto2digits
MOVfdigit1,0;loadmsb
calltable;convertinto7segmentformat
MOVwfPORTB;sendtodisplay
bsfPORTA,2;enablecharacter
btfssTMR0,6;testbit
goto$-1;loop
bcfPORTA,2
MOVfdigit2,0;loadlsb
calltable;convertinto7segmentformat
MOVwfPORTB;sendtodisplay
bsfPORTA,3;enablecharacter
btfscTMR0,6;testbit
goto$-1;loop
bcfPORTA,3
gotomain
end
全部0条评论
快来发表一下你的评论吧 !