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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/10/09 07:10
Read: times


 
#171535 - mov T2MOD,#4
Responding to: ???'s previous message
Stefan Kanev said:

2)You are talking about "capture mode" , but maybe You want Timer2 in timer mode?

mov T2CON,#0
mov T2MOD,#4
regards


Hi Stefan,
MOV T2CON, #00h; is OK, But
MOV T2MOD, #4 ; I could not get it
Below is the part of datasheet that I'm refering to...

 
Table 10-2. T2MOD – Timer 2 Mode Control Register
T2MOD Address = 0C9H Reset Value = XXXX XX00B
Not Bit Addressable

T2MOD:
    ______________________________________
    | – | – | – | – | – | – |T2OE | DCEN |
    --------------------------------------
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1   |   0  |
    -------------------------------------- 
Symbol Function:
*(–)= Not implemented, reserved for future.

T2OE= Timer 2 Output Enable bit

DCEN= When set, this bit allows Timer 2 to be configured as 
an up/down counter.

To me, it appears that T2MOD can not be loaded above #3.
Please correct me if I'm wrong. Any link to Correct T2MOD Bits will be of great help.

Stefan Kanev said:


3)In subroutine "INPUT:" You change R2 (at least), but this is inside ISR,
You must preserve R2 and any other registers at ISR entering and restore bjust before RETI (or use register bank switching trough PSW) . Also PSW MUST!!! be preserved!!!

Yes, The suggestion is appriciated. I knew PUSH & POP should be used while entering & leaving ISR so that the registers used do not affect other part of the program after ISR. I just avoided doing that because I've used R2 only once there, and also PSW is not used/ reffered elsewhere in the program.

Also, as you have mentioned, P1.1 (LED) goes LOW or HIGH in DISPLAY subroutine, and this is causing TF2 SET.
So, how do I come out of this now?

Thanks.

List of 19 messages in thread
TopicAuthorDate
Problem using Timer2 in 89S52!            01/01/70 00:00      
   not a very useful suggestion from 'Plz'            01/01/70 00:00      
      further suggestion            01/01/70 00:00      
         Message & Readable code is here...            01/01/70 00:00      
            look in the assembler manual            01/01/70 00:00      
               New Code, hope it helps!            01/01/70 00:00      
                  what You are trying to make ?            01/01/70 00:00      
                     mov T2MOD,#4            01/01/70 00:00      
                        sorry            01/01/70 00:00      
                            t2mod=0 ; t2con=4 (tr2=1) It worked!            01/01/70 00:00      
                        PSW            01/01/70 00:00      
                  that is not a comment!            01/01/70 00:00      
                     Comments OR Explaination!!!            01/01/70 00:00      
                        Comments are mainly for YOU            01/01/70 00:00      
                        WRONG!            01/01/70 00:00      
                           Answer the "why" in your comments.            01/01/70 00:00      
                              I got (I)T2 working !!!            01/01/70 00:00      
                  Clear TF2 in your service routine            01/01/70 00:00      
                     Clearing TF2 in ISR            01/01/70 00:00      

Back to Subject List