跪求哪个高手给个stc89c51单片机的温度能在数码管上显示,然后数码管显示20度就会报警的程序。

2024-11-26 14:50:51
推荐回答(5个)
回答1:

TMPLEQU29H

TMPHEQU28H

FLAG1EQU38H

DATAINBITP3.7

ORG00H

LJMPMAIN1

ORG03H

LJMPZINT0

ORG13H

LJMPZINT1

ORG30H

MAIN1:SETBIT0

SETBEA

SETBEX0

SETBIT1

SETBEX1

SETBP3.6

SETBP3.2

MOV74H,#0

MOV75H,#0

MOV76H,#9

MOV77H,#0

MAIN:LCALLGET_TEMPER

LCALLCVTTMP

LCALLDISP1

AJMPMAIN

INIT_1820:SETBDATAIN

NOP

CLRDATAIN

MOVR1,#3

TSR1:MOVR0,#107

DJNZR0,$

DJNZR1,TSR1

SETBDATAIN

NOP

NOP

NOP

MOVR0,#25H

TSR2:JNBDATAIN,TSR3

DJNZR0,TSR2

CLRFLAG1

SJMPTSR7

TSR3:SETBFLAG1

CLRP1.7

MOVR0,#117

TSR6:DJNZR0,$

TSR7:SETBDATAIN

RET

GET_TEMPER:SETBDATAIN

LCALLINIT_1820

JBFLAG1,TSS2

NOP

RET

TSS2:MOVA,#0CCH

LCALLWRITE_1820

MOVA,#44H

LCALLWRITE_1820

ACALLDISP1

LCALLINIT_1820

MOVA,#0CCH

LCALLWRITE_1820

MOVA,#0BEH

LCALLWRITE_1820

LCALLREAD_1820

RET

WRITE_1820:MOVR2,#8

CLRC

WR1:CLRDATAIN

MOVR3,#6

DJNZR3,$

RRCA

MOVDATAIN,C

MOVR3,#23

DJNZR3,$

SETBDATAIN

NOP

DJNZR2,WR1

SETBDATAIN

RET

READ_1820:MOVR4,#2

MOVR1,#29H

RE00:MOVR2,#8

RE01:CLRC

SETBDATAIN

NOP

NOP

CLRDATAIN

NOP

NOP

NOP

SETBDATAIN

MOVR3,#9

RE10:DJNZR3,RE10

MOVC,DATAIN

MOVR3,#23

RE20:DJNZR3,RE20

RRCA

DJNZR2,RE01

MOV@R1,A

DECR1

DJNZR4,RE00

RET

CVTTMP:MOVA,TMPH

ANLA,#80H

JZTMPC1

CLRC

MOVA,TMPL

CPLA

ADDA,#1

MOVTMPL,A

MOVA,TMPH

CPLA

ADDCA,#0

MOVTMPH,A

MOV73H,#0BH

SJMPTMPC11

TMPC1:MOV73H,#0AH

TMPC11:MOVA,TMPL

ANLA,#0FH

MOVDPTR,#TMPTAB

MOVCA,@A+DPTR

MOV70H,A

MOVA,TMPL

ANLA,#0F0H

SWAPA

MOVTMPL,A

MOVA,TMPH

ANLA,#0FH

SWAPA

ORLA,TMPL

H2BCD:MOVB,#100

DIVAB

JZB2BCD1

MOV73H,A

B2BCD1:MOVA,#10

XCHA,B

DIVAB

MOV72H,A

MOV71H,B

TMPC12:NOP

DISBCD:MOVA,73H

ANLA,#0FH

CJNEA,#1,DISBCD0

SJMPDISBCD1

DISBCD0:MOVA,72H

ANLA,#0FH

JNZDISBCD1

MOVA,73H

MOV72H,A

MOV73H,#0AH

DISBCD1:RET

TMPTAB:DB0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,9

DISP1:MOVR1,#70H

MOVR0,#74H

MOVR5,#0FEH

PLAY:MOVP1,#0FFH

MOVA,R5

MOVP2,A

MOVA,@R1

MOVDPTR,#TAB

MOVCA,@A+DPTR

MOVP1,A

MOVA,@R0

MOVCA,@A+DPTR

MOVP0,A

MOVA,R5

JBACC.1,LOOP1

CLRP1.7

CLRP0.7

LOOP1:LCALLDL1MS

INCR1

INCR0

MOVA,R5

JNBACC.3,ENDOUT

RLA

MOVR5,A

MOVA,73H

CJNEA,#1,DD2

SJMPLEDH

DD2:MOVA,72H

CJNEA,#0AH,DD3

MOV72H,#0

DD3:MOVA,76H

CJNEA,72H,DDH

SJMPDDL

DDH:JNCPLAY1

SJMPLEDH

DDL:MOVA,75H

CJNEA,71H,DDL1

SJMPLEDH

DDL1:JNCPLAY1

LEDH:CLRP3.6

SJMPPLAY

PLAY1:SETBP3.6

SJMPPLAY

ENDOUT:MOVP1,#0FFH

MOVP2,#0FFH

RET

TAB:DB0C0H,0F9H,0A4H,0B0H,99H

DB92H,82H,0F8H,80H,90H,0FFH,0BFH

DL1MS:MOVR6,#5

DL1:MOVR7,#100

DJNZR7,$

DJNZR6,DL1

RET

ZINT0:PUSHACC

INC75H

MOVA,75H

CJNEA,#10,ZINT01

MOV75H,#0

ZINT01:POPACC

RETI

ZINT1:PUSHACC

INC76H

MOVA,76H

CJNEA,#10,ZINT11

MOV76H,#0

ZINT11:POPACC

RETI

ZZZ1:MOVDPTR,#TAB

MOVCA,@A+DPTR

MOVP0,A

RETI

END

报警值自己可以调节

回答2:

就是一个温度报警器吧,是使用C语言还是汇编语言呢?我用C语言做过类似的设计,如果需要,可以互相交流一下哈,或者你可以用LCD1602试试看。

回答3:

贴出你的电路,不然给你程序也不可能有得了。硬件电路不一样

回答4:

有偿代做!需要的联系!

回答5:

stc89c51片内有测温模块?