#INCLUDE"P16F877.inc"
W_TEMP EQU 20H ; 实际上20H、A0H、120H和1A0H
STATUS_TEMP EQU 21H ;在体0中建立保护单元
PCLATH_TEMP EQU 22H ;在体0中建立保护单元
ORG 000H
GOTO A1
ORG 004H;定时中断入口地址
GOTO ZD01;
ORG 0CH
Q1 ADDWF PCL,1
RETLW 00C0H ;0
RETLW 00F9H ;1
RETLW 00A4H ;2
RETLW 00B0H ;3
RETLW 0099H ;4
RETLW 0092H ;5
RETLW 0082H ;6
RETLW 00F8H ;7
RETLW 0080H ;8
RETLW 0090H ;9
RETLW 0088H ;A
RETLW 0083H ;B
RETLW 00C6H ;C
RETLW 00A1H ;D
RETLW 0086H ;E
RETLW 008EH ;F
A1 MOVLW 1;位1显示数
MOVWF 50H;
MOVLW 2;位2显示数
MOVWF 51H;
MOVLW 3;位3显示数
MOVWF 52H;
MOVLW 4;位4显示数
MOVWF 53H;
CLRF 60H
MOVLW 4;显示位数
MOVWF 40H;
MOVLW B00000001;位码
MOVWF 41H;
MOVLW 50H;
MOVWF FSR ;间接寻址
BSF STATUS,RP0;选择体1
BCF STATUS,RP1;
MOVLW 00H;1:2TMRO比例
MOVWF OPTION_REG;分频1/2
BCF STATUS,RP0;体0
BCF STATUS,RP1;
MOVLW 0FFH;
MOVFW TMR0;初值
BCF INTCON,T0IF;清定时中断标志
BSF INTCON,T0IE;开定时中断
BSF INTCON,GIE;开总中断
;**********************************************************
; 按键修改数据程序
;**********************************************************
A2 BSF STATUS,RP0
BCF STATUS,RP1;体1
MOVLW 0FFH
MOVWF TRISB;设置B口为输入口
BCF STATUS,RP0
BCF STATUS,RP1;体0
BTFSC PORTB,0;判断B口第0位是否按下
GOTO A3;位0则按下按键
MOVLW 1;按下存1到EEPROM
MOVWF 61H;数据寄存器
CALL WR1;写数据到EEPROM
A3 BCF STATUS,RP0
BCF STATUS,RP1;体0
BTFSC PORTB,1;判断B口第1位是否按下
GOTO A4;
MOVLW 2;按下存2到EEPROM
MOVWF 61H;数据寄存器
CALL WR1;写数据到寄存器
A4 BCF STATUS,RP0;
BCF STATUS,RP1;体0
BTFSC PORTB,2;判断B口第2位是否按下
GOTO A5;
MOVLW 3;
MOVWF 61H;
CALL WR1;
A5 BCF STATUS,RP0;
BCF STATUS,RP1;
BTFSC PORTB,3;
GOTO A6;
MOVLW 4;
MOVWF 61H;
CALL WR1;
A6 BCF STATUS,RP0;
BCF STATUS,RP1;
BTFSC PORTB,4;
GOTO A7;
MOVLW 5;
MOVWF 61H;
CALL WR1;
A7 BCF STATUS,RP0;
BCF STATUS,RP1;
BTFSC PORTB,5;
GOTO A8;
MOVLW 6;
MOVWF 61H;
CALL WR1;
A8 BCF STATUS,RP0;
BCF STATUS,RP1;
BTFSC PORTB,6;
GOTO A9;
MOVLW 7;
MOVWF 61H;
CALL WR1;
A9 BCF STATUS,RP0;
BCF STATUS,RP1;
BTFSC PORTB,7;
GOTO A10;
MOVLW 8;
MOVWF 61H;
CALL WR1;
A10
CALL RD01;调用读数据程序
GOTO A2;
上一页
1
2
下一页
评论
我来说两句……
验证码:
技术专区