毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 课程设计 >> 正文

单片机教学打铃控制器程序设计 第4页

更新时间:2010-7-7:  来源:毕业论文

  CLS_AL_H:
  MOV A,R7
  ACALL HBCD
  MOV DIS_MEM3,A
  ACALL DIS_TIME
  ACALL DISPLAY
  MOV A,NEW_TIME
  CJNE A,#0FFH,JMP_5
  MOV NEW_TIME,#0
  DJNZ TIME_OVER,JMP_5
  AJMP WAITE
  JMP_5: ACALL KEY_CHECK
  MOV A,KEY_ST
  CJNE A,#0FFH,SET_AL_H
  MOV KEY_ST,#0
  MOV TIME_OVER,#20
  JNB UP,AL_H_UP
  JNB DOWN,AL_H_DOWN
  JNB LEFT,SET_AL_M
  JNB RIGHT,SET_AL_M
  JNB ESC,JMP_AL_LIST
  JNB ENTER,JMP_SET_AL_OK
  SJMP SET_AL_H
  JMP_ESC_AL:
  AJMP ESC_AL
  JMP_OK_AL:
  AJMP OK_AL
  JMP_ADD_AL:
  AJMP ADD_AL
  JMP_SET_AL_OK:
  AJMP SET_AL_OK
  JMP_AL_LIST:
  AJMP AL_LIST
  AL_H_UP:CJNE R6,#23,INC_H_AL
  MOV R6,#0FFH
  INC_H_AL:INC R6
  AJMP GATE_AL_H
  AL_H_DOWN:
  CJNE R6,#0,DEC_H_AL
  MOV R6,#24
  DEC_H_AL:DEC R6
  AJMP GATE_AL_H
  ;----------分修改----------------
  SET_AL_M:
  JNB FLASH_S,GATE_AL_M
  MOV DIS_MEM3,#0AAH
  SJMP CLS_AL_M
  GATE_AL_M:
  MOV A,AL_NUMBER
  ACALL HBCD
  MOV DIS_MEM1,A
  MOV A,R7
  ACALL HBCD
  MOV DIS_MEM3,A
  CLS_AL_M:
  MOV A,R6
  ACALL HBCD
  MOV DIS_MEM2,A
  ACALL DIS_TIME
  ACALL DISPLAY
  MOV A,NEW_TIME
  CJNE A,#0FFH,JMP_6
  MOV NEW_TIME,#0
  DJNZ TIME_OVER,JMP_6
  AJMP WAITE
  JMP_6: ACALL KEY_CHECK
  MOV A,KEY_ST
  CJNE A,#0FFH,SET_AL_M
  MOV KEY_ST,#0
  MOV TIME_OVER,#20
  JNB UP,AL_M_UP
  JNB DOWN,AL_M_DOWN
  JNB LEFT,JMP_SET_AL_H
  JNB RIGHT,JMP_SET_AL_H
  JNB ESC,JMP_AL_LIST
  JNB ENTER,SET_AL_OK
  SJMP SET_AL_M
  JMP_SET_AL_H: 毕业论文http://www.751com.cn
  AJMP SET_AL_H
  AL_M_UP:CJNE R7,#59,INC_M_AL
  MOV R7,#0FFH
  INC_M_AL:INC R7
  AJMP GATE_AL_M
  AL_M_DOWN:
  CJNE R7,#0,DEC_M_AL
  MOV R7,#60
  DEC_M_AL:DEC R7
  AJMP GATE_AL_M
  ;=====打铃点设置确认/返回到列表状态======
  SET_AL_OK:NOP
  MOV A,AL_NUMBER
  DEC A
  RL A
  ADD A,#80H
  MOV R0,A
  MOV A,R6
  MOV @R0,A
  INC R0
  MOV A,R7
  MOV @R0,A
  MOV R0,#80H
  MOV R2,AL_TOTA
  ACALL UP_LIST ;调升序排序程序
  AJMP ALARM_SET
  ;==========增加打铃时间点================
  ADD_AL: INC AL_TOTA
  MOV AL_NUMBER,AL_TOTA
  MOV R6,#08
  MOV R7,#0
  MOV A,AL_NUMBER
  DEC A
  RL A
  ADD A,#80H
  MOV R0,A
  MOV A,R6
  MOV @R0,A
  INC R0
  MOV A,R7
  MOV @R0,A
  AJMP SET_AL_H
  ;==========打铃设置取消/返回==========
  ESC_AL: MOV R4,#TOTA_ADDR
  MOV R0,#AL_TOTA
  MOV R3,#1
  ACALL RD_EEROM
  MOV A,AL_TOTA
  JZ EXIT_SET_AL
  RL A
  MOV R3,A
  MOV R0,#80H
  MOV R4,#00H
  ACALL RD_EEROM
  EXIT_SET_AL:
  AJMP NEW_DIS
  ;=========打铃设置确认/返回===========
  OK_AL: MOV R0,#AL_TOTA
  MOV R3,#1
  MOV R4,#TOTA_ADDR
  ACALL WR_EEROM
  MOV A,AL_TOTA
  JZ JMP_NEW_DIS
  MOV A,AL_TOTA
  RL A
  MOV R0,#80H
  MOV R3,A
  MOV R4,#0
  ACALL WR_EEROM
  JMP_NEW_DIS:
  AJMP NEW_DIS
  JMP_AL_SET:
  AJMP ALARM_SET
  ;========删除打铃时间点===========
  DEL_AL: MOV A,AL_TOTA
  JZ JMP_AL_SET
  JNB FLASH_S,GATE_DIS
  MOV DIS_MEM1,#0AAH
  MOV DIS_MEM2,#0AAH
  MOV DIS_MEM3,#0AAH
  SJMP CLS_DIS
  GATE_DIS:
  MOV A,AL_NUMBER
  ACALL HBCD
  MOV DIS_MEM1,A
  MOV A,AL_NUMBER
  DEC A
  RL A
  ADD A,#80H
  MOV R0,A
  MOV A,@R0
  ACALL HBCD
  MOV DIS_MEM2,A
  INC R0
  MOV A,@R0
  ACALL HBCD
  MOV DIS_MEM3,A
  CLS_DIS:ACALL DIS_TIME
  ACALL DISPLAY
  MOV A,NEW_TIME
  CJNE A,#0FFH,JMP_7
  MOV NEW_TIME,#0
  DJNZ TIME_OVER,JMP_7
  AJMP WAITE
  JMP_7: ACALL KEY_CHECK
  MOV A,KEY_ST
  CJNE A,#0FFH,DEL_AL
  MOV KEY_ST,#0
  MOV TIME_OVER,#20
  JNB ENTER,DEL_LIST
  JNB ESC,JMP_AL_SET_D
  AJMP DEL_AL
  JMP_AL_SET_D:
  AJMP ALARM_SET
  ;------删除列表数据-----------
  DEL_LIST:
  MOV A,AL_TOTA
  DEC A
  JZ CLR_TOTA
  MOV A,AL_TOTA
  CLR C
  SUBB A,AL_NUMBER
  JZ NEW_LIST
  RL A
  MOV R3,A
  MOV A,AL_NUMBER
  DEC A
  RL A
  ADD A,#80H
  MOV R0,A
  INC A
  INC A
  MOV R1,A
  MOVE_LIST_AL:
  MOV A,@R1
  MOV @R0,A
  INC R1
  INC R0
  DJNZ R3,MOVE_LIST_AL
  NEW_LIST:
  DEC AL_TOTA
  MOV R0,#80H
  MOV R2,AL_TOTA
  ACALL UP_LIST
  LJMP ALARM_SET
  CLR_TOTA:
  MOV AL_TOTA,#0
  LJMP ALARM_SET
  ;=============================================
  ;*************T0中断服务子程序****************
  INT_T0: PUSH ACC ;保护现场
  PUSH PSW
  CLR TF2
  MOV TL0,#0B0H ;50mS 定时常数
  MOV TH0,#3CH
  DJNZ CT_50MS,CK_500MS
  MOV CT_50MS,#20 ;DELAY 1 SECOND
  MOV NEW_TIME,#0FFH;置秒标志
  MOV A,S_MEM
  CJNE A,#59,SECOND ;判断秒=59
  MOV S_MEM,#0FFH
  MOV A,M_MEM
  CJNE A,#59,MINUTE ;判断分=59
  MOV M_MEM,#0FFH
  MOV A,H_MEM
  CJNE A,#23,HOUR ;判断时=23
  MOV H_MEM,#0FFH
  HOUR: INC H_MEM ;时加1
  MINUTE: INC M_MEM ;分加1
  SECOND: INC S_MEM ;秒加1
  CPL FLASH_S
  SJMP EXIT_T0
  CK_500MS:
  MOV A,CT_50MS
  CJNE A,#10,EXIT_T0
  CPL FLASH_S ;秒闪
  EXIT_T0:POP PSW ;恢复现场
  POP ACC
  RETI ;中断返回
  ;======================================
  ;*********拆字查表子程序***************
  DIS_TIME:
  PUSH ACC
  PUSH B
  MOV A,DIS_MEM1
  ACALL DIS_H_L
  MOV DIS_BUF1,A
  MOV DIS_BUF2,B
  MOV A,DIS_MEM2
  ACALL DIS_H_L
  MOV DIS_BUF3,A
  MOV DIS_BUF4,B
  MOV A,DIS_MEM3
  ACALL DIS_H_L
  MOV DIS_BUF5,A
  MOV DIS_BUF6,B
  POP B
  POP ACC
  RET
  ;++++++++++++++++++++++++++++++++++++
  DIS_H_L:MOV B,A
  ANL A,#0FH
  MOV DPTR,#LEDSEG
  MOVC A,@A+DPTR
  XCH A,B
  SWAP A
  ANL A,#0FH
  MOV DPTR,#LEDSEG
  MOVC A,@A+DPTR
  RET
  ;======================================
  ;*********数码管扫描子程序*************
  ;执行时间:10mS
  ;++++++++++++++++++++++++++++++++++++++
  DISPLAY:PUSH ACC
  PUSH PSW
  PUSH 00H
  MOV P0,#0
  MOV A,#0FEH
  MOV R0,#DIS_BUF1
  DIS_LOOP:
  MOV P2,A
  MOV P0,@R0
  ACALL DLY_DIS
  MOV P0,#0
  RL A
  INC R0
  JB ACC.6,DIS_LOOP
  MOV P2,#0FFH
  POP 00H
  POP PSW
  POP ACC
  RET
  ;-----------------------------------
  DLY_DIS:PUSH 02H
  PUSH 03H
  MOV R2,#4
  DLY_LOOP:
  MOV R3,#204
  DJNZ R3,$
  DJNZ R2,DLY_LOOP
  POP 03H
  POP 02H
  RET
  ;======================================
  ;*********键盘检测子程序***************
  ;检测有无按键按下
  ;键闭合标志KEY_ST,ON:0FFH,OFF:00H
  ;++++++++++++++++++++++++++++++++++++++
  KEY_CHECK:
  PUSH ACC
  MOV P1,#0FFH
  MOV A,P1
  CPL A
  JZ KEY_OFF
  ACALL DISPLAY
  MOV A,P1
  CPL A
  JZ KEY_OFF
  MOV A,KEY_BUF
  CPL A
  JNZ KEY_OFF
  MOV KEY_BUF,P1
  ;XRL A,KEY_BUF
  ;JZ KEY_OFF
  MOV KEY_ST,#0FFH
  SJMP EXIT_K
  KEY_OFF:MOV KEY_ST,#0
  MOV KEY_BUF,P1
  EXIT_K: POP ACC
  RET
  ;=========================================
  ;****单字节十辣进制整数转换成单字节BCD码整数****
  ;入口条件:待转换的单字节十辣进制整数在累加器A中。
  ;出口信息:转换后的BCD码整数(十位和个位)仍在累加器A中,百位在R3中。
  ;影响资源:PSW、A、B、R3 堆栈需求: 2字节
  ;+++++++++++++++++++++++++++++++++++++++++
  HBCD: MOV B,#100 ;分离出百位,存放在R3中
  DIV AB
  MOV R3,A
  MOV A,#10 ;余数继续分离十位和个位
  XCH A,B
  DIV AB
  SWAP A
  ORL A,B ;将十位和个位拼装成BCD码
  RET
  ;=============================================
  ;********写24C02 EEPROM数据子程序***********
  ;R0:RAM地址指针,R2:8位移位计数器
  ;R3:数据字节计数器
  ;R4:24C02 存储地址
  ;------------------------------------------
  WR_EEROM:
  NOP
  W_LOOP: ACALL START24
  MOV A,#0A0H
  ACALL WBYTE
  MOV A,R4
  ACALL WBYTE
  MOV A,@R0
  ACALL WBYTE
  ACALL STOP24
  ACALL DISPLAY
  INC R0
  INC R4
  DJNZ R3,W_LOOP
  RET
  ;******读24C02 EEPROM数据子程序*********
  ;R0:RAM地址指针,R2:8位移位计数器
  ;R3:数据字节计数器
  ;R4:24C02 存储地址
  ;----------------------------------------
  RD_EEROM:
  NOP
  R_LOOP1: ACALL START24
  MOV A,#0A0H
  ACALL WBYTE
  MOV A,R4
  ACALL WBYTE
  ACALL START24
  MOV A,#0A1H
  ACALL WBYTE
  ACALL RBYTE
  MOV @R0,A
  INC R0
  INC R4
  DJNZ R3,R_LOOP1
  ACALL STOP24
  RET
  ;-----------------------------------
  RBYTE: NOP
  CLR SCL
  MOV R2,#08H
  SETB SDA
  RBY0: CLR SCL
  NOP
  SETB SCL
  NOP
  MOV C,SDA
  RLC A
  DJNZ R2,RBY0
  CLR SCL
  NOP
  CLR SCL
  SETB SDA
  NOP
  SETB SCL
  RET
  ;-------------------------------------
  WBYTE: NOP
  MOV R2,#08H
  WBY0: CLR SCL
  RLC A
  MOV SDA,C
  NOP
  SETB SCL
  DJNZ R2,WBY0
  CLR SCL
  NOP
  SETB SCL
  NOP
  JB SDA,$
  CLR SCL
  NOP
  RET
  ;---------------------------------
  START24: CLR SCL
  NOP
  SETB SDA
  NOP
  SETB SCL
  NOP
  CLR SDA
  NOP
  CLR SCL
  RET
  ;---------------------------------
  STOP24: CLR SCL
  NOP
  CLR SDA
  NOP
  SETB SCL
  NOP
  SETB SDA
  NOP
  CLR SCL
  RET
  ;==========================================
  ;**********双字节数据排序子程序**************
  ;功能:将打铃时间表按升序排列
  ;入口参数:R0:数据块首地址,R2:打铃时间点数(字数)
  ;影响:A,B,PSW,R0,R2,R3,R4
  ;=============================================
  UP_LIST: PUSH ACC
  PUSH PSW
  PUSH B
  MOV A,R0
  MOV R4,A
  DEC R2
  MOV A,R2
  JZ EXIT_LIST
  MOV R3,A
  CLR F0
  LOOP: MOV A,R4
  MOV R0,A
  MOV A,R3
  MOV R2,A
  CLR F0
  LOOP1: ACALL MIN_MAX
  DJNZ R2,LOOP1
  JNB F0,EXIT_LIST
  DJNZ R3,LOOP
  EXIT_LIST:
  POP B
  POP PSW
  POP ACC
  RET
  ;++++++++++++++++++++++++++++++++++++++++++++++
  MIN_MAX: MOV B,R0
  INC R0
  MOV A,@R0
  INC R0
  INC R0
  CLR C
  SUBB A,@R0
  MOV R0,B
  MOV A,@R0
  INC R0
  INC R0
  SUBB A,@R0
  JC EXIT_MM
  SETB F0
  MOV A,@R0
  MOV R0,B
  XCH A,@R0
  INC R0
  INC R0
  MOV @R0,A
  DEC R0
  MOV A,@R0
  INC R0
  INC R0
  XCH A,@R0
  DEC R0
  DEC R0
  MOV @R0,A
  EXIT_MM: MOV R0,B
  INC R0
  INC R0
  RET
  ;-----------------------------------------
  ;*******************段码表********************
  LEDSEG: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H ;'0,1,2,3,4,5,6,7'
  DB 7FH,6FH,40H ;'8,9,-,B,C,D,E,F'

上一页  [1] [2] [3] [4] 

单片机教学打铃控制器程序设计 第4页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©751com.cn 辣文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。