Tuesday, February 26, 2019

FMA Unit 3.4 Timer Registers



To control timer operation two special Functions Register are used
1.         TCON (Timer Control Register)
2.         TMOD (Timer Mode Selection Register)

TCON register
TCON is an 8-bit register, which controls the timer1 and timer0.

Bits and functions of every bits of TCON are as follows:


BIT
Function
TF1 / TF0
·      Timer 1 / Timer 0 overflow.
·      This bit is set (i.e. TF1=1 / TF0=1) by the microcontroller when timer1 / timer0 overflows.
TR1 / TR0
·      Timer 1 / Timer 0 run.
·      When this bit is set (i.e. TR1=1 / TR0=1) Timer1 / Timer0 is turn on.
·      When this bit is reset (i.e. TR1=0 / TR0=0) Timer1 / Timer0 is off.
IE1 / IE0
·      External interrupt (  / ) Edge flag.
·      This bit is set (i.e. IE1=1 / IE0=1) when external interrupt (  / ) arrives.
IT1 / IT0
·      External interrupt (  / ) triggered type control bit.
·      This bit is set (i.e. IT1=1 / IT0=1) when external interrupt (  / ) is edge triggered.
·      This bit is clear (i.e. IT1=0 / IT0=0) when external interrupt (  / ) is level triggered.





TMOD (Timer Mode) Register
Both Timer 0 and Timer 1 use the same register to set the various timer operation modes. It is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper four bits for Timer 1.



BIT
Function
Gate
·      Timer1 / Timer0 control. Every timer has a means of starting and stopping.  Timers do this by software or hardware.
·      This bit is reset (i.e. Gate=0) when timer 1 / timer 0 controlled by software.
It means when this bit is reset, timer1 / timer0 will start when TR1 / TR0 bit of TCON is set.
·      This bit is set (i.e. Gate=1) when timer 1 / timer 0 controlled by hardware.
It means when this bit is set, timer1 / timer0 will start after arriving of external interrupt (  / ) (provided that TR1 / TR0 bit of TCON should be set).
·      Timer or Counter selector.
·      When this bit is reset (i.e.  =0) Timer1 / Timer0 will work as timer.
·      When this bit is set (i.e.  =1) Timer1 / Timer0 will work as counter.
M1 & M0
M1
M0
Mode
Operating Mode
0
0
0
13-bit timer mode,
0
1
1
16-bit timer mode,
1
0
2
8-bit auto reload mode,
1
1
3
8-bit Spilt timer mode.


No comments:

Post a Comment