Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/23/05 10:41
Read: times


 
#85609 - Interrupt ?
Responding to: ???'s previous message
Maria Siddiqua said:
Hi,
 
org 00h
jmp start
org 0bh
jmp timer
org 30h

start:	mov R0,#00h   
; R0 is used bcoz timer's count can be as high as 65536 so 
;R0 will have the value of 100 which will multiply with 50000 
;of timer to make 5sec.

	mov tmod,#01h           
; timer mode 1 is selected

	mov tl0,#low(-50000)  
;initializing the timer 

        mov th0,#high(-50000)

	setb EA 
                
	setb ET0                
; enabling the timer

main:	jb p2.2,$	       
;if key is pressed, move on to next inst. , if not pressed 
;jump on the same inst. 

	call bouncing_delay	
; introducing bouncing delay og 40msec

	clr p1.0		
;light up the LED

	mov R0,#00h

	setb TR0               
; starting the timer

timer:	mov tl0,#low(-50000)

	mov th0,#high(-50000)

	inc R0		
;50,000 * 100=5000,000microsec=5sec

	cjne R0,#100,skip
;when timer is out,move on to next inst., if not jump on skip

        mov R0,#00h             
; reinitializing  R0

	clr TR0 		
;stop timer 

	setb p1.0		
; switch of LED

	call delay
		
	jmp main		

skip:	jnb p2.2,exit		
;if button is released,move on to next inst, if not, jump to 
;exit
        setb p1.0		
; make LED off

	clr TR0			
; stop timer

	jmp main

exit:	jmp timer		
	
bouncing_delay:mov R4,#100
lp1:    mov R3,#200
	djnz R3,$
	djnz R4,lp1
	ret


delay:	mov R2,#100
loop2:	mov R5,#200
loop1:	mov R6,#250	
	djnz R6,$
	djnz R5,loop1
	djnz R2,loop2
	ret

end




Hi Maria,

How does it not work as you expect ? You have a timer interrrupt vector, you are starting the timer, and you are stopping the timer,but you aren't USING the timer ! You are using hardcoded delay loops.

Look on the site here with our search facility, and look for timer code examples.

This is a popular problem, and you will find lots of code to help.

Steve



List of 5 messages in thread
TopicAuthorDate
Hardware isnt responding            01/01/70 00:00      
   Interrupt ?            01/01/70 00:00      
   Delay subroutines            01/01/70 00:00      
   State machines?            01/01/70 00:00      
   Timer Problem            01/01/70 00:00      

Back to Subject List