基于AT89C2051的红外遥控学习器源程序_第1页
基于AT89C2051的红外遥控学习器源程序_第2页
基于AT89C2051的红外遥控学习器源程序_第3页
基于AT89C2051的红外遥控学习器源程序_第4页
基于AT89C2051的红外遥控学习器源程序_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

基于AT89C2051的红外遥控学习器源程序源程序

ORG0000H

AJMPMAIN

ORG0003H

AJMPKEYPRESS

ORG000BH

AJMPTIMEOUT

ORG001BH

AJMPTIMEOUT

SENDDUAN

BITP3.0

JIEDUAN

BITP3.1

INTRPO

BITP3.2

JIEXUAN

BITP3.3

SENDLIGHT

BITP3.4

JIELIGHT

BITP3.5

CS

BITP3.7

DATADUAN

BITP1.6

CLK

BITP1.7

JIANWEI

EQUR5

JIANMA

EQUR6

SHANGJIAN

EQU07H;R7

OPENKEY

EQU81H

CLOSEKEY

EQU00H

CHUT0

EQU11H

CHUT1

EQU11H

BUFBEGIN

EQU18H

OPENT1

EQU88H

CLOSET1

EQU00H

OPENT0

EQU82H

CLOSET0

EQU00H

DATABEG1

EQU0AAH

DATABEG2

EQU33H

ORG0030H

MAIN:

MOV

IE,#80H

MOV

IP,#00H

MOV

P3,#0FFH

CLR

CS

SETBP1.0

SETBP1.1

SETBP1.2

CLR

P1.3

CLR

P1.4

CLR

P1.5

CLR

P1.6

CLR

P1.7

MOV

R3,#80H

MOV

R0,00H

CYCLE1:

MOV

@R0,#00H

INC

R0

DJNZR3,CYCLE1

MOV

PSW,#00H

MOV

SP,#07H

MOV

TMOD,#11H

MOV

TCON,#00HSTART:

MOV

SP,#07H

SETBSENDDUAN

CLR

F0

SETBEXO

WAITKEY:

MOV

C,F0

JNC

WAITKEY

CJNCJIANMA,#1BH,SEND

LCALLLEARNP

LJMPSTART

SEND:

LCALLSENDP

LJMPSTARTSENDP:

SETBSENDDUAN

CLR

F0

MOV

TMOD,#CHUT1

CLR

SENDLIGHT

MOV

A,JIANMA

CJNE

A,SHANGJIAN,SAME

SAME:

MOV

R0,#BUFBEGIN

CLR

TR1

LJMP

NEXT3

RETURN:

CLR

ET1

SETB

SENDDUAN

SETB

SENDLIGHT

CLR

F0

LCALLDELAY

RET

NEXT3:

CPLF0

JBF0,SEND1

SEND0:

CLRC

;1

MOVA,#0FFH

SUBBA,@R0

MOVR2,A

;1

INCR0

;1

MOVA,#0FFH

;1

SUBBA,@R0

;1

MOVR3,A

INCR0

CLRC

MOVA,#4FH

ADDCA,R2

MOVR2,A

MOVA,R3

ADDCA,#00H

MOVR3,A

MOVTL1,R2

MOVTH1,R3

SETBTR1

;1

SETBET1

;1

SEND1:

CLRC

MOVA,#0FFH

SUBBA,@RO

MOVTL1,A

INCR0

MOVA,#0FFH

SUBBA,@R0

MOVTH1,A

INCR0

SETBTR1

SETBET1

NEXT6:

CLRSENGGUAN

MOVR3,#03H

NEXT4:

DJNZR3,NEXT4

SETBSENDDUAN

MOVR3,#07H

NEXT5:

DJNZR3,#NEXT5

SJMPNEXT6TIMA1OUT:CLRET1

;2

CLRTR1

;2

SETBSENDDUAN

;1

CJNE@R0,#DATABEG2,TIM1NT2

MOVDPTR,#RETURN

;2

MOVR1,SP

;2

MOV@R1,DPH

;2

DECR1

;1

MOV@R1,DPL

;2

RETI

;2

TIM1NET2:DECR0

TIM1NET1:CPLF0

;1

JBF0,SEND11

;2

SEND00:

MOVDPTR,#SENDO

;11

MOVR1,SP

MOV@R1,DPH

DECR1

MOV@R1,DPL

RETI

SEND11:

MOVDPTR,#SEND1

;11

MOVR1,SP

MOV@R1,DPH

DECR1

MOV@R1,DPL

RETI

LEARNP:

MOVR2,#02H

NEXT91:

MOVR3,#0FFH

NEXT81:

MOVR4,#0FFH

NEXT71:

DJNZR4,NEXT71

DJNZR3,NEXT81

GJNZR2,NEXT91

CLRF0

SETBEX0

MOVR2,#0AH

MEXT9:

MOVR3,#0FFH

NEXT8:

MOVR4,#0FFH

NEXT7:

JBF0,NEXT10

DJNZR4,NEXT7

DJNZR3,MEXT8

DJNZR2,NEXT9

CLREX0

RET

NEXT10:

CJNEJIANMA,#1BH,NEXT11

LJMPNEXT111

NEXT11:

RET

NEXT111:

CLRJIELIGHT

CLRJIEXUAN

CLRF0

MOVR0,#BUFBEGIN

SETBET0

MOVTCON,#00H

MOVTMOD,#CHUT0

MOVTL0,#00H

MOVTH0,#00H

MOVR2,#02H

NEXT92:

MOVR3,#0FFH

NEXT82:

MOVR4,#0FFH

NEXT72:

DJNZR4,NEXT72

DJNZR3,NEXT82

DJNZR2,NEXT92

CLRTR0

L1:

MOVC,JIEDUAN

JCL1

L4:

SETBTR0

L2:

MOVC,JIEDUAN

CLRTR0

MOV@R0,TL0

INCR0

MOVTH0,#00H

MOVTL0,#00H

L6:

SETBTR0

L3:

MOVC,JIEDUAN

JCL3

CLRTR0

CLRC

MOVA,TL0

ADDCA,#13H

MOV@R0,A

INCR0

MOVTH0,#00H

MOVTL0,#00H

SETBTR0

L5:

MOVC,JIEDUAN

JNCL5

CLRTR0

CLRC

;1

MOVA,TL0

;1

ADDCA,#13H

;1

MOV@R0,A

;2

INCR0

MOVA,TH0

ADDCA,#00H

MOV@R0,A

INCR0

MOVTH0,#00H

MOVTL0,#00H

SJMPL6

SHUJIAN:

SETBJIEXUAN

MOV@R0,#DATABEG1

INCR0

MOV@R0,#DATABEG2

SETBEX0

CLRF0

NEXT13:

JBF0,NEXT12

LJMPNEXT13

NEXT12:

LCALLWRITEP

SETBJIELIGHT

RET

TIME0OUT

CLRET0

CLRTR0

MOVDPTR,#SHUJIAN

MOV@R1,DPH

DECR1

MOV@R1,DPL

RETI

KEYPRESS:CLREX0

MOVR3,#0DH

CYCLE3:

MOVR4,#0FFH

CYCLE2:

DJNZR4,CYCLE2

DJNZR3,CYCLE3

MOVC,INTRPO

JNCNEXT1

RETI

NEXT1:

SETBF0

MOVC,P1.0

MOVACC.0,C

MOVC,P1.1

MOVACC.1,C

MOVC,P1.2

MOVACC.2,C

CLRP1.0

CLRP1.1

CLRP1.2

SETBP1.3

SETBP1.4

SETBP1.5

MOVC,P1.3

MOVACC.3,C

MOVC,P1.4

MOVACC.4,C

MOVC,P1.5

MOVACC.5,C

ANLA,300111111B

MOVJIANMA,A

SETBP1.0

SETBP1.1

SETBP1.2

CLRP1.3

CLRP1.4

CLRP1.5

LCALLJIANWEIP

RETI

JIANWEIP:CJNEJIANMA,#36H,NEXT14

MOVJIANWEI,#01H

LJMPLAST

NEXT14:

CJNEJIANMA,#35H,NEXT15

MOVJIANWEI,#02H

LJMPLAST

NEXT15:

CJNEJIANMA,#35H,NEXT16

MOVJIANWEI,#03H

LJMPLAST

NEXT16:

CJNEJIANMA,#2EH,NEXT17

MOVJIANWEI,#04H

LJMPLAST

NEXT17:

CJNEJIANMA,#2DHNEXT18

MOVJIANWEI,#05H

LJMPLAST

NEXT18:

CJNEJIANMA,#2BH,NEXT19

MOVJIANWEL,#06H

LJMPLAST

NEXT19:

CJNEJIANMA,#1EH,NEXT20

MOVJIANWEI,#07H

LJMPLAST

NEXT20:

CJNEJIANMA,#1DH,NEXT21

MOVJIANWEL,#09H

LJMPLAST

NEXT21:

CJNEJIANMA,#1BH,NEXT22

MOVJIANWEI,#09H

LJMPLAST

NEXT22:

CLRFO

LAST:

RET

READP:

MOVRO,BUFBEGIN

MOVA,JIANWEI

MOVB,50

MULAB

MOVR3,A

SHUJUDIZHI

INCR3

LCALLREADCOM

READNET2:MOVA,R3

LCALLWRITEADRESS

LCALLREADBYTE

CJNE,#DATABEG1,READNET1

MOVAR3

INCA

LACLLWRITEADRESS

LCALLREADBYTE

CJNEA,#DATABEG2,READNET1

CLRCS

RET

READNET1:MOV@RO,A

INCRO

INCR3

LJMPREADNET2

WRITEP:

MOVRO,BUFBEGIN

MOVA,JIAWEI

MOVB,50

MUL

AB

MOVR3,A

;KAISHISHU

JUDIZHI

INCR3

LCALLEWEN

WRITNET1:LACLLWRITECOM

MOV,R3

LCALLWRITEADRESS

MOVA,@RO

CJNEA,#DATABEG1,WRITNET2

INCRO

MOVA,@RO

CJNEA,DATABEG2,WRITNET3

LCALLEWDS

CLRCS

RET

WRITNRT3:DECRO

WRITNET2:LCALLWRITEBYTE

INCRO

INCR3

LJMPWRITNE1

RET

WRITBYTE:MOVR2,#08H

BOUT1:

CLRCLK

RLCA

MOVDATADUAN,C

NOP

SETBCLK

NOPDJNZR2,BOUT1

CLRDATADUAN

RET

READBYTE:SETBDATAUAN

MOVR2,#08H

BIN1:

CLRCLK

NOP

SETBCLK

NOP

MOVC,DATADUAN

RLCA

DJNZR2,BIN1

RET

READCOM:

CLRCS

CLRCLK

SETBDATADUAN

SETBCS

NOP

SETBCLK

;1

NOP

CLRCLK

NOP

SETBCLK

;1

NOP

CLRDATAUAN

CLRCLK

NOP

SETBCLK

;0

RET

WRITECOM:CLRCS

NOP

CLRCLK

SETBDATADUAN

SETBCS

NOP

SETBCLK

;1

NOP

CLRDATADUAN

NOP

CLRCLK

NOP

SETBCLK

;0

NOP

SETBDATADUAN

NOP

CLRCLK

NOP

SETBCLK

;1

RET

WRITEADRESS:MOVR2,#07H

RLCA

;TIAOGUO

DI7WEI

BOUT2:

CLRCLK

RLCA

MOVDATADUAN,C

NOP

DJNAR2,BOUT2

CLRDATAUAN

RET

EQEN:

CLRCS

CLRCLK

SETBDATADUAN

SETBCS

SETBCLK

;1

NOP

CLRCLK

NOP

CLRDATADUAN

SETBCLK

;0

NOP

NOP

CLRCLK

NOP

温馨提示

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

评论

0/150

提交评论