基于51单片机的源代码

  • 格式:doc
  • 大小:54.00 KB
  • 文档页数:16

下载文档原格式

  / 16
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

基于51单片机的源代码

JIN1 EQU P1.0

JIN2 EQU P1.1

JIN3 EQU P1.2

JIN4 EQU P1.3

INH EQU P2.3

CP EQU P2.2

ORG 0000H

AJMP MAIN

ORG 0100H

MAIN: MOV SP,#70H

MOV TMOD,#20H ;自动重装

MOV SCON,#50H

MOV PCON,#80H ;双倍波特率SMOD=1 MOV TH1,#0FFH ;57600MHZ波特率初值

MOV TL1,#0FFH

MOV P1,#00H

MOV P2,#00H

SETB TR1

SETB P2.1

LOOP: LCALL keep

LCALL SHUCHU

ACALL QINGLING

AJMP LOOP QINGLING: CJNE R0,#17,QINGLING1

MOV R0,#00H QINGLING1: CJNE R1,#9,FANHUI

MOV R1,#00H

FANHUI: RET

SHUCHU: ACALL SHUA

ACALL SHUB

ACALL SHUC

ACALL SHUD

SHUA: MOV R3,#4

SETB JIN1

LLS: MOV R2,#8

LJMP keep

INC R1

SETB INH

CLR JIN1

CLR INH

LLS1: LJMP keep

SETB CP

CLR CP

DJNZ R2,LLS1

DJNZ R3,LLS

RET SHUB: MOV R3,#4

SETB JIN2 QQS: MOV R2,#8

LJMP keep

INC R1

SETB INH

CLR JIN2

CLR INH QQS1: LJMP keep

SETB CP

INC R0

CLR CP

DJNZ R2,QQS1

DJNZ R3,QQS

RET SHUC: MOV R3,#4

SETB JIN3 JJS: MOV R2,#8

LJMP keep

INC R1

SETB INH

CLR JIN3

CLR INH JJS1: LJMP keep

SETB CP

INC R0

CLR CP

DJNZ R2,JJS1

DJNZ R3,JJS

RET SHUD: MOV R3,#4

SETB JIN4 KKS: MOV R2,#8

LJMP keep

INC R1

SETB INH

CLR JIN4

CLR INH KKS1: LJMP keep

INC R0

CLR CP

DJNZ R2,KKS1

DJNZ R3,KKS

RET

keep: JB P2.1,KEEO

CLR P2.1

CJNE R1,#1,PAN1

MOV R1,#00H

LJMP KEEP1

KEEO: RET

PAN1: CJNE R1,#2,PAN2

LJMP KEEP2

PAN2: CJNE R1,#3,PAN3

LJMP KEEP3

PAN3: CJNE R1,#4,PAN4

LJMP KEEP4

PAN4: CJNE R1,#5,PAN5

LJMP KEEP5

PAN5: CJNE R1,#6,PAN6

LJMP KEEP6

PAN6: CJNE R1,#7,PAN7

LJMP KEEP7

PAN7: CJNE R1,#8,PAN8

LJMP KEEP8

PAN8: CJNE R1,#9,PAN9

LJMP KEEP9

PAN9: CJNE R1,#10,PAN10

LJMP KEEP10 PAN10: CJNE R1,#11,PAN11

LJMP KEEP11 PAN11: CJNE R1,#12,PAN12

LJMP KEEP12 PAN12: CJNE R1,#13,PAN13

LJMP KEEP13 PAN13: CJNE R1,#14,PAN14

LJMP KEEP14 PAN14: CJNE R1,#15,PAN15

LJMP KEEP15 PAN15: CJNE R1,#16,KEEO

LJMP KEEP16

KEEP1: CJNE R0,#1,LL1

MOV R0,#00H

LJMP SONGCHU LL1: CJNE R0,#2,LL2

MOV R0,#00H

MOV A,#02H

LJMP SONGCHU LL2: CJNE R0,#3,LL3

MOV R0,#00H

MOV A,#03H

LJMP SONGCHU LL3: CJNE R0,#4,LL4

MOV R0,#00H

MOV A,#04H

LJMP SONGCHU LL4: CJNE R0,#5,LL5

MOV R0,#00H

MOV A,#05H

LJMP SONGCHU LL5: CJNE R0,#6,LL6

MOV R0,#00H

MOV A,#06H

LJMP SONGCHU LL6: CJNE R0,#7,LL7

MOV R0,#00H

MOV A,#07H

LJMP SONGCHU LL7: CJNE R0,#8,LL8

MOV R0,#00H

MOV A,#08H

LJMP SONGCHU

LL8: RET

KEEP2: CJNE R0,#1,LL9

MOV R0,#00H

MOV A,#9

LJMP SONGCHU LL9: CJNE R0,#2,LL10

MOV R0,#00H

MOV A,#10

LJMP SONGCHU LL10: CJNE R0,#3,LL11

MOV R0,#00H

MOV A,#11

LJMP SONGCHU LL11: CJNE R0,#4,LL12