Disha Karnataki
Full Member level 5
i am doing a counter programing in 8051 using asm language inorder to count pulses at p3^4 pin for 1second here i have programmed one timer as timer & another timer as counter when i simulate this program it is working fine but it's showing different count on hardware when i reset at different instance please figure out what is problem in my programing.
Code:
org 0000h
ljmp main
org 001bh
ljmp isrt1 //isr routine
org 0100h
main:mov p1,#00h
mov p3,#0ffh
mov tmod,#15h //timer0 as counter & timer1 as timer
mov ie,#88h //timer interrupt for timer1
mov th1,#00h
mov tl1,#00h
mov r0,#0eh //for 1 second delay
setb tr0
k1:setb tr1 //start timer
cjne r0,#00h,k1
clr tr0
o1:mov p1,tl0
sjmp o1
isrt1: //isr routine
clr tr1
djnz r0,l12
l12: //creating 1 second delay
mov th1,#00h
mov tl1,#00h
reti
end
Last edited by a moderator: