ORG 0H
LJMP MAIN //bypass interrupt vector table
ORG 0BH // Timer-Counter o interrupt vector
LJMP TINT // Jump to Timer counter interrupt routine
ORG 30H
MAIN: MOV R0,#20
MOV R1,#0 //Set time value = 0, seconds
MOV R2,#0 //minutes
MOV R3,#0 //hours
ACALL SETDIS //initialise the display
MOV TMOD,#0x01 //initialise counter-timer 0
MOV TH0,#0x3C
MOV TL0,#0xB0
SETB EA //Enable timer 0 interrupt
SETB ET0
SETB TR0
DISPL: ACALL DIST //Display time
ACALL DELAY3
AJMP DISPL
SETDIS: MOV A,#30H //Display initialisation routine
ACALL COMNWRT
ACALL DELAY1
MOV A,#0CH
ACALL COMNWRT
ACALL DELAY1
MOV A,#01
ACALL COMNWRT
ACALL DELAY2
MOV A,#06H
ACALL COMNWRT
ACALL DELAY1
RET
DIST: MOV A,#01 //Update display routine
ACALL COMNWRT //Reset display
ACALL DELAY2
// Your Code Here
RET
INCT:
INCE: RET
COMNWRT:
MOV P0,A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY1
CLR P2.2
RET
DATAWRT:
MOV P0,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY1
CLR P2.2
RET
DELAY1: MOV R5,#30 //Short delay
LP1: DJNZ R5,LP1
RET
DELAY2: MOV R5,#50 //long delay
HERE2: MOV R4,#50
HERE: DJNZ R4,HERE
DJNZ R5,HERE2
RET
DELAY3: MOV R5,#250 //extra long delay
HERE4: MOV R4,#250
HERE3: DJNZ R4,HERE3
DJNZ R5,HERE4
RET
// 0x3cb0 = 15536
// 65536-15536 = 50000
// 12000000/12 = 1000000 (assuming %12 machine cycle)
// 1000000/50000 = 20 (20 timer ticks per second)
TINT: // YOUR CODE HERE FINISH THIS ROUTINE
//Timer - counter interrupt service rountine ISR. Stop timer while servicing it.
//Clear timer interrupt flag
//Load TH0 and TL0 with 0x3CB0 (15536d)
//
//Restart timer after we've reloaded the TH0 and TL0 registers
//Decrement R0 (count down from 20); if not 0, then go to TINTE
//If timer has ticked 20 times, then refill R0 with 0d20 for next countdown
//flip port 2.3, output every second (for probing on the scope)
ACALL INCT //Increment time
TINTE: RETI
END
你之前不是问51么,现在怎么又是TMS弹片机,不同的硬件不同,你什么都没有交代
建议参考手册,或者例子程序,比如
https://wenku.baidu.com/view/9c4e2881720abb68a98271fe910ef12d2af9a99b.html