gokcercakir
Newbie level 1
timer with 8051
This program is a real time timer. it has 4 display and will redound in every 10 mseconds. Everything seems ok but there is a problem. i want to add it some interrupts. i tried every way but i couldnt. Can anybody help me with this problem. sorry for my english. The codes i added are written bold. And the codes i removed are italic writen. I really need help about this. Thanks.
DISPLAY1 EQU 31h
DISPLAY2 EQU 32h
DISPLAY3 EQU 34h
DISPLAY4 EQU 35h
OVERBIT EQU 36
OVERBIT2 EQU 37
OVERBIT3 EQU 38
ORG2004h
JMP ISRTFO
ORG 2100h
MOV P2, #00h
MOV P1, #00h
MOV DPTR, #TABLO
MOV R1, #00h
MOV R2, #00h
MOV R3, #00h
MOV R4, #00h
MOV IE , #82h
MOV TH0, #0DBh
MOV TL0,#0FFh
MOV TMOD , #81h
MOV SP,#70h
SETB TR0
MAIN:
CALL SEND_TIME
JMP MAIN
CLR EA
MOV TCON,#10h
MOV TMOD, #81h
MAIN:
MOV TH0, #0DBh
MOV TL0, #0FFh
CALL MOV_TIME
TIMER:
CALL SEND_TIME
JNB TCON.5, TIMER
CLR TF0
JMP MAIN
;========================================================
MOV_TIME:
MOV A, R1
MOVC A, @A+DPTR
MOV DISPLAY1, A
INC R1
CJNE R1, #0Ah, disp1
MOV R1, #00h
SETB OVERBIT
NOP
disp1:
MOV A, R2
MOVC A, @A+DPTR
MOV DISPLAY2, A
JNB OVERBIT, ovr
INC R2
CLR OVERBIT
ovr:
CJNE R2, #0Ah, disp2
MOV R2, #00h
SETB OVERBIT2
NOP
disp2:
MOV A, R3
MOVC A, @A+DPTR
MOV DISPLAY3, A
JNB OVERBIT2, ovr2
INC R3
CLR OVERBIT2
ovr2:
CJNE R3, #0Ah, disp3
MOV R3, #00h
SETB OVERBIT3
NOP
disp3:
MOV A, R4
MOVC A, @A+DPTR
MOV DISPLAY4, A
JNB OVERBIT3, ovr3
INC R4
CLR OVERBIT3
ovr3:
CJNE R4, #0Ah, disp4
MOV R4, #00h
disp4:
RET
;========================================================
SEND_TIME:
MOV P1, #00h
SETB P2.3
MOV P1, DISPLAY1
CALL DELAY
CLR P2.3
MOV P1, #00h
CALL DELAY
SETB P2.2
MOV P1, DISPLAY2
CALL DELAY
CLR P2.2
MOV P1, #00h
SETB P2.1
MOV P1, DISPLAY3
CALL DELAY
CLR P2.1
MOV P1, #00h
SETB P2.0
MOV P1, DISPLAY4
CALL DELAY
CLR P2.0
RET
;=================================================================
DELAY:
MOV R0, #0FAh
WAIT:
NOP
NOP
DJNZ R0, WAIT
RET
ISRTF0:
MOV THO,#0DBh
MOV TL0,#0FFh
CLR TF0
CALL MOV_TIME
reti
;=================================================================
TABLO:
DB 0C0h
DB 0F9h
DB 0A4h
DB 0B0h
DB 99h
DB 92h
DB 82h
DB 0F8h
DB 80h
DB 90h
END
i think the problem is about the interrupt or start adress places. But as i know the T0 interrupt is adressed at 2004H in 8051 microcontroller. Please help
This program is a real time timer. it has 4 display and will redound in every 10 mseconds. Everything seems ok but there is a problem. i want to add it some interrupts. i tried every way but i couldnt. Can anybody help me with this problem. sorry for my english. The codes i added are written bold. And the codes i removed are italic writen. I really need help about this. Thanks.
DISPLAY1 EQU 31h
DISPLAY2 EQU 32h
DISPLAY3 EQU 34h
DISPLAY4 EQU 35h
OVERBIT EQU 36
OVERBIT2 EQU 37
OVERBIT3 EQU 38
ORG2004h
JMP ISRTFO
ORG 2100h
MOV P2, #00h
MOV P1, #00h
MOV DPTR, #TABLO
MOV R1, #00h
MOV R2, #00h
MOV R3, #00h
MOV R4, #00h
MOV IE , #82h
MOV TH0, #0DBh
MOV TL0,#0FFh
MOV TMOD , #81h
MOV SP,#70h
SETB TR0
MAIN:
CALL SEND_TIME
JMP MAIN
CLR EA
MOV TCON,#10h
MOV TMOD, #81h
MAIN:
MOV TH0, #0DBh
MOV TL0, #0FFh
CALL MOV_TIME
TIMER:
CALL SEND_TIME
JNB TCON.5, TIMER
CLR TF0
JMP MAIN
;========================================================
MOV_TIME:
MOV A, R1
MOVC A, @A+DPTR
MOV DISPLAY1, A
INC R1
CJNE R1, #0Ah, disp1
MOV R1, #00h
SETB OVERBIT
NOP
disp1:
MOV A, R2
MOVC A, @A+DPTR
MOV DISPLAY2, A
JNB OVERBIT, ovr
INC R2
CLR OVERBIT
ovr:
CJNE R2, #0Ah, disp2
MOV R2, #00h
SETB OVERBIT2
NOP
disp2:
MOV A, R3
MOVC A, @A+DPTR
MOV DISPLAY3, A
JNB OVERBIT2, ovr2
INC R3
CLR OVERBIT2
ovr2:
CJNE R3, #0Ah, disp3
MOV R3, #00h
SETB OVERBIT3
NOP
disp3:
MOV A, R4
MOVC A, @A+DPTR
MOV DISPLAY4, A
JNB OVERBIT3, ovr3
INC R4
CLR OVERBIT3
ovr3:
CJNE R4, #0Ah, disp4
MOV R4, #00h
disp4:
RET
;========================================================
SEND_TIME:
MOV P1, #00h
SETB P2.3
MOV P1, DISPLAY1
CALL DELAY
CLR P2.3
MOV P1, #00h
CALL DELAY
SETB P2.2
MOV P1, DISPLAY2
CALL DELAY
CLR P2.2
MOV P1, #00h
SETB P2.1
MOV P1, DISPLAY3
CALL DELAY
CLR P2.1
MOV P1, #00h
SETB P2.0
MOV P1, DISPLAY4
CALL DELAY
CLR P2.0
RET
;=================================================================
DELAY:
MOV R0, #0FAh
WAIT:
NOP
NOP
DJNZ R0, WAIT
RET
ISRTF0:
MOV THO,#0DBh
MOV TL0,#0FFh
CLR TF0
CALL MOV_TIME
reti
;=================================================================
TABLO:
DB 0C0h
DB 0F9h
DB 0A4h
DB 0B0h
DB 99h
DB 92h
DB 82h
DB 0F8h
DB 80h
DB 90h
END
i think the problem is about the interrupt or start adress places. But as i know the T0 interrupt is adressed at 2004H in 8051 microcontroller. Please help