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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/13/08 11:52
Read: times


 
#159017 - Multiple Problems
Responding to: ???'s previous message
Dear Ranjit,

A snipet of your posted code is as follows

Ranjit Kumar Gupta said:
I want to initialise the interrupt timer but can't do the same with following code please help.

;testing timer
; ORG 0

CALL INTR
jmp 40h

ORG 0BH
JMP IT1

org 40h
MOV SP,#60H
MOV @R1,#0
LOOP: SETB TR0
NOP
JMP LOOP

INTR: MOV SCON,#50H
MOV TH0,#F4H
MOV TL0,#F4H
MOV TMOD,#20H
SETB TR0
RET

IT1: MOV A,@R1
ADD A,#1
DA A
MOV @R1,A
reti

END


Problem:
1. you are initialising SFR related to timer zero, but you are configuring timer1 in auto reload. (actually you need to configure timer0 in same)

2. R1 is not initialised (or is it assumed to have any value that is there on reset?)

3. at org 0 you have 2 instructions 1 call & 1 jmp. instead you can have only 1 jmp instruction as sjmp 40h & at org 40 you can call INTR

4. The most important is, when you intend to use interrupt you need to enable it. Your code should have one of the following to enable timer0 interrupt in INTR subroutine
mov IE, #82h or
setb ET0 followed with setb EA

( Also why are you initialising SCON registor )


please make all four changes, test them & reply

Regards,
Mahesh

List of 6 messages in thread
TopicAuthorDate
Help need in Timer Interrupt            01/01/70 00:00      
    which timer are you using ?            01/01/70 00:00      
      Thanks Arun            01/01/70 00:00      
   where do you set R1?            01/01/70 00:00      
   Multiple Problems            01/01/70 00:00      
      Comments?            01/01/70 00:00      

Back to Subject List