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.

about timer interrupts

Status
Not open for further replies.

Disha Karnataki

Full Member level 5
Full Member level 5
Joined
Jul 20, 2013
Messages
249
Helped
9
Reputation
18
Reaction score
8
Trophy points
18
Location
india
Activity points
2,231
this is the code in asm written
i.e the code written here is: it will display 55h & aah with some delay in between them on port1 & a timer is set. So when timer interrupts there will isr execution. here is the code:
org 0000h
ljmp main
org 000bh //start of isr
clr tf0
lcall delay
mov p1,#00h
lcall delay
mov p1,#88h
reti
org 0030h
main:
mov p1,#00h
mov tmod,#01h //timer initialisation
mov ie,#82h //interrupt initialization
up:mov p1,#055h //
lcall delay //
lcall delay // displaying 55h, aah with some delay
mov p1,#0aah //
lcall delay //
setb tr0 //starts the timer
sjmp up
delay:mov r0,#0f0h
l1:mov r0,#0ffh //creating some delay
k1:djnz r0,k1
djnz r1,l1
ret
end

explaination :initailly before timer interrupts there is continuous display of 55h & aah on port p1 and when timer interrupts then in isr routine 00h & 88h is displayed.

problem facing: here the timer interrupt is not at all ending it is not coming out of the isr routine inspite of writing RETI(it is an instruction to written from interrupt) only once it is executing the main program & then it is ending up in isr routine & is not terminating at all.
please help.
 

org 0000h
ljmp main

org 000bh //start of isr
clr tf0
clr tr0
mov p1,#00h
lcall delay1
mov p1,#88h
lcall delay1
setb tr0
reti


main:
mov p1,#00h
mov tmod,#01h //timer initialisation
mov ie,#82h //interrupt initialization
setb tr0 //starts the timer

up:
mov p1,#055h //
lcall delay //
lcall delay // displaying 55h, aah with some delay
mov p1,#0aah //
lcall delay //
sjmp up

delay:
mov r1,#0f0h
l1:mov r0,#0ffh //creating some delay
k1:djnz r0,k1
djnz r1,l1
ret

delay1:
mov r2,#0f0h
wl1:mov r3,#0ffh //creating some delay
wk1:djnz r3,wk1
djnz r2,wl1
ret
end
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top