0
\$\begingroup\$

What will be result of this statement:

MOV TMOD,#00H

Will it set it to timer 0 in mode 0 or to timer 1 in mode 0?

Other statements like:

MOV TMOD,#01H ;----- sets timer 0 mode 1
MOV TMOD,#10H ;----- sets timer 1 mode 1

didn't create any ambiguity.

\$\endgroup\$
1
\$\begingroup\$

Actually, all of those statements modify BOTH timers:

MOV TMOD,#00H ; set timer 0 mode 0 AND timer1 mode 0
MOV TMOD,#01H ; set timer 0 mode 1 AND timer1 mode 0
MOV TMOD,#10H ; set timer 0 mode 0 AND timer1 mode 1

If you want to modify only one of the timers, you must do a read-modify-write, preserving the bits on the timer you're not changing.

For example, if you want to force Timer0 to mode 0 without changing anything else, you might do:

ANL TMOD,#FCh ; binary 11111100 -- bit mask with two LSBs cleared
\$\endgroup\$
  • \$\begingroup\$ And can you tell the command for setting timer 1 in mode 0 specifically? \$\endgroup\$ – Shyam Mittal Mar 2 at 12:49
  • \$\begingroup\$ You can't work it out from the information given so far? Look again at the definition of the TMOD register. \$\endgroup\$ – Dave Tweed Mar 2 at 12:52
  • \$\begingroup\$ I got that. Thanks Dave. \$\endgroup\$ – Shyam Mittal Mar 3 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.