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:08
Read: times


 
#85607 - Hardware isnt responding
Hi,
I m new to this forum. For my project to start with,I was given a simple task which is :
**********************************************
"LED is connected on any bit,
Push Button connected on any bit,
Set your code in such a way that when ever the push button is pressed,the LED goes ON and with that 5-seconds counter is also start, the LED only goes OFF if the 5 second counter reaches to 5 Seconds orthe push button is released which ever occur ealier,
if the push button is remained pressed uptill 5 seconds go back to the inital check of button pressed or not and continue with what ever the status of the switch."
***********************************************
The corresponding prog. is going well with the 535 simulator but when i tried it on actual hardware ..to my surprise, it is not responding there in the way it shd do. I wish if anyone of you may go through the prog. and find out the fault in it . Coding is here:

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


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