\$\begingroup\$
\$\endgroup\$
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.
Shyam MittalShyam Mittal
asked Mar 1, 2019 at 17:05
1 Answer 1
\$\begingroup\$
\$\endgroup\$
3
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
-
\$\begingroup\$ And can you tell the command for setting timer 1 in mode 0 specifically? \$\endgroup\$Shyam Mittal– Shyam Mittal2019年03月02日 12:49:45 +00:00Commented 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\$Dave Tweed– Dave Tweed2019年03月02日 12:52:38 +00:00Commented Mar 2, 2019 at 12:52
-
\$\begingroup\$ I got that. Thanks Dave. \$\endgroup\$Shyam Mittal– Shyam Mittal2019年03月03日 21:49:55 +00:00Commented Mar 3, 2019 at 21:49
lang-vhdl