Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Adding interrupts in real time timer with 8051

Status
Not open for further replies.

gokcercakir

Newbie level 1
Joined
May 17, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
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
 

timer with 8051

Both your interrupt service routine addressing (2004h) and the program start (2010h) is obviously a result of using some kind of monitor in some devboard you are using - there is no point discussing your problem further until you tell us about it.

The standard ISRs in '51 are placed at the lowest addresses; the T0 ISR is located at 000Bh.

Please read the manuals, both for '51 and for the devboard you are using.

wek
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top