ark5230
Advanced Member level 3
- Joined
- Jun 29, 2009
- Messages
- 862
- Helped
- 163
- Reputation
- 324
- Reaction score
- 140
- Trophy points
- 1,323
- Location
- India
- Activity points
- 6,187
I am trying to produce delay of 1/20 s (50 ms) using Timer/counter 0.
Crystal frequency is 11.0592 MHz and machine cycle is 11.085µs.
for 50ms the machine cycles required is 46079 decimal.
The counter is to be loaded with 65536-46079=19457=4C01Hex
TH0=04CH and TL0=01H.
SETB TR0 initiates timing and Polling TF0 gives the end of the required time.
Now the problem is IF Timer 0 is to be configured for the above purpose, What should be TMOD value?
TMOD = 01010001B configures this but also configures Timer 1 as counter !!
If timer 1 is not to be configure what should be the TMOD value.
A simple explanation of these setting will be of help.
Crystal frequency is 11.0592 MHz and machine cycle is 11.085µs.
for 50ms the machine cycles required is 46079 decimal.
The counter is to be loaded with 65536-46079=19457=4C01Hex
TH0=04CH and TL0=01H.
SETB TR0 initiates timing and Polling TF0 gives the end of the required time.
Now the problem is IF Timer 0 is to be configured for the above purpose, What should be TMOD value?
TMOD = 01010001B configures this but also configures Timer 1 as counter !!
If timer 1 is not to be configure what should be the TMOD value.
A simple explanation of these setting will be of help.
Code:
MOV TMOD,#01010001B ; TIMER CONFIGURATION
MOV TH0,#4CH ; VALUE IN TH0 FOR 1/20 S DELAY
MOV TL0,#01H ; VALUE IN TL0 FOR 1/20 S DELAY
SETB TR0 ; START TIMER (FOR 1/20 S DELAY)
JNB TF0,$ ; WAIT TILL COUNTING IS OVER
CLR TF0 ; CLEAR TIMER FLAG TF0
RET