21. ⢠The PCON or Power Control register, as the name suggests is used to
control the 8051 Microcontrollerâs Power Modes and is located at
87H of the SFR .
⢠The addresses of the Port Registers are as follows: P0 â 80H, P1 â
90H, P2 â A0H and P2 â B0H.
⢠The Serial Control or SCON SFR is used to control the 8051
Microcontrollerâs Serial Port.
⢠Timer Control or TCON Register is used to start or stop the Timers of
8051 n address of 98H.
22. 8051 Timers
⢠Timer is a clock that controls the sequence of an event while counting
in fixed intervals of time.
⢠A Timer is used for producing precise time delay.
⢠Secondly, it can be used to repeat or initiate an action after/at a
known period of time.
⢠This feature is very commonly used in several applications. An
example could be setting up an alarm which triggers at a point of time
or after a period of time.
23. 8051 Timers
⢠8051 has two Timers designated as Timer0 and Timer1.
⢠Each of these timers is assigned a 16-bit register.
⢠The value of a Timer register increases by one every time a timer
counts.
⢠Timer takes a time period of one machine cycle to count one.
⢠Since 8051 is an 8 bit controller, the registers of 8051 Timers are
accessed as two different registers; one for lower byte and other for
higher byte. For example, register of Timer0 is accessed as TL0 for
lower byte and TH0 for higher byte. Similarly TL1 and TH1 are
registers assigned to Timer 1.
24. 8051 Timers
⢠The registers of Timers are loaded with some initial value. The value
of a Timer register increases by one after every machine cycle.
⢠One machine cycle duration is the 1/12th of the frequency of the
crystal attached to the controller.
⢠If the frequency of the crystal is 12 MHz, then the frequency for Timer
will be 1MHz (1/12 of crystal frequency) and hence the time (T = 1/f)
taken by the Timer to count by one is 1Âľs (1/1MHz).
⢠If no value is loaded into the Timer, it starts counting from 0000H.
25. 8051 Timers
⢠When the Timer reaches FFFFH, it reloads to 0000H.
⢠This roll over is communicated to the controller by raising a
flag corresponding to that Timer, i.e., a flag bit is raised (set high)
when the timer starts counting from 0000H again.
26. Program Status Word (PSW)
Flag 0 is a general-purpose flag available to the programmer.
P Even parity with the accumulator.
O V This flag is set after an addition or subtraction operation if the result in the accumulator is outside the signed 8-bit range
27. B register
⢠The B register is used together with the accumulator for multiply and
divide operations.
⢠The "B" register is only used by two 8051 instructions.
⢠The MUL AB instruction multiplies the values in A and B and stores
the low-byte of the result in A and the high-byte in B.
⢠The DIV AB instruction divides A by B leaving the integer result in A
and the remainder by B.
28. Stack Pointer
⢠The stack pointer (SP) is an 8-bit register at location 81H.
⢠The stack pointer contains the address of the item currently on top of
the stack.
⢠On power-up or reset the SP is set to 07H.