悬赏
2
分 芯积分未解决
程序在keil里编译没有错也没有警告,但是烧录到51单片机里显示不出来。是我程序不对吗?还是单片机的显示有问题?望各位大神指导啊,急用啊。要是能给个新的程序也行
SW1 BIT P0.0
SW2 BIT P0.1
SW3 BIT P0.2
SW4 BIT P0.3
SW5 BIT P0.4
SW6 BIT P0.5
DIG1 BIT P0.0
DIG2 BIT P0.1
DIG3 BIT P0.2
DIG4 BIT P0.3
DIG5 BIT P0.4
DIG6 BIT P0.5
DAT164 BIT P0.6
CLK164 BIT P0.7
BEEP BIT P2.0
SPK BIT P2.1
DI0832 BIT P2.2
DO0832 BIT P2.3
CK0832 BIT P2.4
CS0832 BIT P2.5
DAT24 BIT P2.6
CLK24 BIT P2.7
LED1 BIT P1.0
LED2 BIT P1.1
LED3 BIT P1.2
LED4 BIT P1.3
LED5 BIT P1.4
LED6 BIT P1.5
LED7 BIT P1.6
LED8 BIT P1.7
RX BIT P3.0
TX BIT P3.1
KEY BIT P3.2
JDQ BIT P3.3
STPA BIT P3.4
STPB BIT P3.5
STPC BIT P3.6
STPD BIT P3.7
BUFF_LED1 EQU 22H
BUFF_LED2 EQU 23H
BUFF_LED3 EQU 24H
BUFF_LED4 EQU 25H
BUFF_LED5 EQU 26H
BUFF_LED6 EQU 27H
BUFF_LED_LP EQU 28H ;T0键盘显示扫描缓存
BUFF_KEY EQU 29H
BUFF_164 EQU 2AH
BUFF_DEL EQU 2BH
BUFF_DEL0 EQU 2CH
BUFF_DEL1 EQU 2DH
DIG_PORT EQU P0
HOR EQU 30H ;小时值缓存
MIN EQU 31H ;分钟值缓存
SEC EQU 32H ;秒值缓存
org 000h
JMP main
org 003h
jmp ex_int0
ORG 00BH
JMP T0_INT
ORG 100H
MAIN: MOV SP ,#40H
MOV PSW,#00H
MOV R0,#7FH ;初始化RAM区,
CLR_RAM:MOV A,#00H
MOV @R0,A
DJNZ R0,CLR_RAM
MOV P1,#0FFH ;INIT
MOV P2,#0FFH
MOV P0,#0FFH
MOV P3,#0FFH
clr beep
clr jdq
clr spk
lcall del
setb BEEP
lcall del
clr beep
CLR JDQ
CLR SPK
SETB KEY
MOV TMOD,#21h
MOV TH0,#HIGH(65536-4000) ;T0=4MS
MOV TL0,#LOW(65535-4000)
SETB TR0
mov ie,#10000011b
mov ip,#00000010b
ajmp $
ex_int0:push psw
push acc
JNB SW1,SW1_OK
JNB SW2,SW2_OK
JNB SW3,SW3_OK
JNB SW4,SW4_OK
JNB SW5,SW5_OKA
JNB SW6,SW6_OKA
JMP return
SW5_OKA: JMP SW5_OK
SW6_OKA: JMP SW6_OK
SW1_OK: MOV A,HOR
CJNE A,#24,SW1_OVER
MOV HOR,#00H
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW1_OVER:INC HOR ;时加1
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW2_OK: MOV A,HOR
CJNE A,#00,SW2_OVER
MOV HOR,#23
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW2_OVER:DEC HOR ;时减1
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW3_OK: MOV A,MIN
CJNE A,#59,SW3_OVER
MOV MIN,#00H
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW3_OVER:INC MIN ;分加1
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW4_OK: MOV A,MIN
CJNE A,#00,SW4_OVER
MOV MIN,#59
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW4_OVER:DEC MIN ;分减1
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW5_OK: MOV A,SEC
CJNE A,#59,SW5_OVER
MOV SEC,#00H
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW5_OVER:INC SEC ;秒加1
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW6_OK: MOV A,SEC
CJNE A,#00,SW6_OVER
MOV HOR,#59
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
SW6_OVER:DEC SEC ;时减1
SETB BEEP
LCALL DEL
CLR BEEP
JMP return
return:pop acc
pop psw
reti
DEL: MOV buff_del,#03 ;为演示方便,人为插入的延时
DEL01: MOV buff_del0,#200
DEL02: MOV buff_del1,#200
DJNZ buff_del1,$
DJNZ buff_del0,DEL02
DJNZ buff_del,DEL01
RET
BIN_BCD: MOV B,#10
DIV AB
RET
;------------- T0 INTRRUPT 数码管扫描定时中断---------------------------
T0_INT: PUSH ACC
PUSH PSW
MOV TH0,#HIGH(65536-4000) ;T0=4MS
MOV TL0,#LOW(65536-4000)
INC BUFF_LED_LP
MOV A,BUFF_LED_LP
CJNE A,#250,CONT_SCAN ;250*4MS=1S
MOV BUFF_LED_LP,#00H
INC SEC
MOV A,SEC
CJNE A,#60,CONT_SCAN
MOV SEC,#00H
INC MIN
MOV A,MIN
CJNE A,#60,CONT_SCAN
MOV MIN,#00H
INC HOR
MOV A,HOR
CJNE A,#24,CONT_SCAN ;24:00:00时BEEP报时,
MOV HOR,#00H
SETB beep
clr LED1
lcall del
CLR beep
setb LED1
CONT_SCAN:MOV A,SEC
LCALL BIN_BCD
MOV BUFF_LED6,B
MOV BUFF_LED5,A
MOV A,MIN
LCALL BIN_BCD
MOV BUFF_LED4,B
MOV BUFF_LED3,A
MOV A,HOR
LCALL BIN_BCD
MOV BUFF_LED2,B
MOV BUFF_LED1,A
MOV A,BUFF_LED_LP
MOV B,#06
DIV AB
MOV A,B
RL A
MOV DPTR,#TAB_SCAN
JMP @A+DPTR
TAB_SCAN: AJMP SCAN_L1
AJMP SCAN_L2
AJMP SCAN_L3
AJMP SCAN_L4
AJMP SCAN_L5
AJMP SCAN_L6
SCAN_L1: MOV DIG_PORT,#11111110B
MOV A,BUFF_LED1
JMP END_SCAN
SCAN_L2: MOV DIG_PORT,#11111101B
MOV A,BUFF_LED2
JMP END_SCAN
SCAN_L3: MOV DIG_PORT,#11111011B
MOV A,BUFF_LED3
JMP END_SCAN
SCAN_L4: MOV DIG_PORT,#11110111B
MOV A,BUFF_LED4
JMP END_SCAN
SCAN_L5: MOV DIG_PORT,#11101111B
MOV A,BUFF_LED5
JMP END_SCAN
SCAN_L6: MOV DIG_PORT,#11011111B
MOV A,BUFF_LED6
END_SCAN: MOV DPTR,#TAB_LED
MOVC A,@A+DPTR
LCALL SEND164
EXIT_T0: POP PSW
POP ACC
RETI
TAB_LED: DB 0C0H,0F9H,0A4H,0B0H,99H,92H ;数码管显示字型表
DB 82H,0F8H,80H,90H,88H,83H,0A7H
DB 0A1H,86H,8EH
SEND164: MOV BUFF_164,#08 ;发送数据到74164
PUSH ACC
SND164_LP:CLR CLK164
RLC A
MOV DAT164,C
SETB CLK164
DJNZ BUFF_164,SND164_LP
POP ACC
RET
END