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.

asked Mar 1, 2019 at 17:05
\$\endgroup\$

1 Answer 1

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
answered Mar 1, 2019 at 17:42
\$\endgroup\$
3
  • \$\begingroup\$ And can you tell the command for setting timer 1 in mode 0 specifically? \$\endgroup\$ Commented Mar 2, 2019 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\$ Commented Mar 2, 2019 at 12:52
  • \$\begingroup\$ I got that. Thanks Dave. \$\endgroup\$ Commented Mar 3, 2019 at 21:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.