Unit-3
Unit-3
Input/Output (I/O) pin − All the circuits within the microcontroller must be connected to one of its
pins except P0 port because it does not have pull-up resistors built-in.
Input pin − Logic 1 is applied to a bit of the D register. The output of transistor is turned off and
the other pin remains connected to the power supply voltage over a pull-up resistor of high
resistance.
When the external memory is used then the lower address byte (addresses A0A7) is applied on it,
else all bits of this port are configured as input/output.
When P0 port is configured as an output then other ports consisting of pins with built-in pull-up
resistor connected by its end to 5V power supply, the pins of this port have this resistor left out.
Input Configuration
If any pin of this port is configured as an input, then it acts as if it “floats”, i.e. the input has
unlimited input resistance and in-determined potential.
Output Configuration
When the pin is configured as an output, then it acts as an “open drain”. By applying logic 0 to a
port bit, the appropriate pin will be connected to ground (0V), and applying logic 1, the external
output will keep on “floating”. In order to apply logic 1 (5V) on this output pin, it is necessary to
build an external pull up resistor.
Port 1
P1 is a true I/O port as it doesn’t have any alternative functions as in P0, but this port can be
configured as general I/O only. It has a built-in pull-up resistor and is completely compatible with
TTL circuits.
Port 2
P2 is similar to P0 when the external memory is used. Pins of this port occupy addresses intended
for the external memory chip. This port can be used for higher address byte with addresses A8-
A15. When no memory is added then this port can be used as a general input/output port similar to
Port 1.
Port 3
In this port, functions are similar to other ports except that the logic 1 must be applied to
appropriate bit of the P3 register.
When pins are configured as an output (i.e. logic 0), then the single port pins can receive a current
of 10mA.
When these pins are configured as inputs (i.e. logic 1), then built-in pull-up resistors provide very
weak current, but can activate up to 4 TTL inputs of LS series.
If all 8 bits of a port are active, then the total current must be limited to 15mA (port P0: 26mA).
If all ports (32 bits) are active, then the total maximum current must be limited to 71mA.
Interrupt of 8051 microcontroller
Interrupts are the events that temporarily suspend the main program, pass the control to the
external sources and execute their task. It then passes the control to the main program where it had
left off.
8051 has 5 interrupt signals, i.e. INT0, TFO, INT1, TF1, RI/TI. Each interrupt can be
enabled or disabled by setting bits of the IE register and the whole interrupt system can be
disabled by clearing the EA bit of the same register.
Upon receiving the interrupt signal the Microcontroller , finish current instruction and saves
the PC on stack
Starts to execute the interrupt service routine until RETI (return from interrupt)
Upon executing the RETI the microcontroller returns to the place where it was interrupted.
Get pop PC from stack
Each interrupt has a specific place in code memory where program execution (interrupt
service routine) begins.
External Interrupt 0: 0003h
Timer 0 overflow: 000Bh
External Interrupt 1: 0013h
Timer 1 overflow: 001Bh
Serial : 0023h
Timer 2 overflow(8052+) 002bh
Timer0 registers is a 16 bits register and accessed as low byte and high byte. The low byte is referred as a
TL0 and the high byte is referred as TH0. These registers can be accessed like any other registers.
Timer1 registers is also a 16 bits register and is split into two bytes, referred to as TL1 and TH1.
TMOD (timer mode) Register: This is an 8-bit register which is used by both timers 0 and 1 to set the
various timer modes. In this TMOD register, lower 4 bits are set aside for timer0 and the upper 4 bits are
set aside for timer1. In each case, the lower 2 bits are used to set the timer mode and upper 2 bits to specify
the operation.
TMOD
In upper or lower 4 bits, first bit is a GATE bit. Every timer has a means of starting and stopping.
Some timers do this by software, some by hardware, and some have both software and hardware controls.
The hardware way of starting and stopping the timer by an external source is achieved by making GATE=1
in the TMOD register. And if we change to GATE=0 then we do no need external hardware to start and
stop the timers.
The second bit is C/T bit and is used to decide whether a timer is used as a time delay generator or
an event counter. If this bit is 0 then it is used as a timer and if it is 1 then it is used as a counter.
In upper or lower 4 bits, the last bits third and fourth are known as M1 and M0 respectively. These are used
to select the timer mode.
1 0 2 8-bit auto reload mode, 8-bit auto reload timer/counter; THx holds a value which is
to be reloaded into TLx eachtime it overflows.
Mode 1- It is a 16-bit timer; therefore it allows values from 0000 to FFFFH to be loaded into the timer’s
registers TL and TH. After TH and TL are loaded with a 16-bit initial value, the timer must be started. We
can do it by “SETB TR0” for timer 0 and “SETB TR1” for timer 1. After the timer is started. It starts count
up until it reaches its limit of FFFFH. When it rolls over from FFFF to 0000H, it sets high a flag bit called
TF (timer flag). This timer flag can be monitored. When this timer flag is raised, one option would be stop
the timer with the instructions “CLR TR0“ or CLR TR1 for timer 0 and timer 1 respectively. Again, it must
be noted that each timer flag TF0 for timer 0 and TF1 for timer1. After the timer reaches its limit and rolls
over, in order to repeat the process the registers TH and TL must be reloaded with the original value and TF
must be reset to 0.
Mode 1 programming
The following are the characteristics and operations of mode 1:
It is a 16-bit timer; therefore, it allows values of 0000 to FFFFH to be loaded into the timer’s
registers TL and TH.
After TH and TL are loaded with a 16-bit initial value, the timer must be start ed. This is done by
“SETB TRO” for Timer 0 and “SETB TR1″ for Timer 1.
After the timer is started, it starts to count up. It counts up until it reaches its limit of FFFFH. When
it rolls over from FFFFH to 0000, it sets high a flag bit called TF (timer flag). This timer flag can be
monitored. When this timer flag is raised, one option would be to stop the timer with the
instructions “CLR TRO” or “CLR TR1″, for Timer 0 and Timer 1, respectively. Again, it must be
noted that each timer has its own timer flag: TFO for Timer 0, and TF1 for Timer 1.
After the timer reaches its limit and rolls over, in order to repeat the process the registers TH and TL
must be reloaded with the original value, and TF must be reset to 0.
Mode0- Mode 0 is exactly same like mode 1 except that it is a 13-bit timer instead of 16-bit. The 13- bit
counter can hold values between 0000 to 1FFFH in TH-TL. Therefore, when the timer reaches its
maximum of 1FFH, it rolls over to 0000, and TF is raised.
Mode 2- It is an 8 bit timer that allows only values of 00 to FFH to be loaded into the timer’s register TH.
After TH is loaded with 8 bit value, the 8051 gives a copy of it to TL. Then the timer must be started. It is
done by the instruction “SETB TR0” for timer 0 and “SETB TR1” for timer1. This is like mode 1. After
timer is started, it starts to count up by incrementing the TL register. It counts up until it reaches its limit
of FFH. When it rolls over from FFH to 00. It sets high the TF (timer flag). If we are using timer 0, TF0
goes high; if using TF1 then TF1 is raised. When Tl register rolls from FFH to 00 and TF is set to 1, TL is
reloaded automatically with the original value kept by the TH register. To repeat the process, we must
simply clear TF and let it go without any need by the programmer to reload the original value. This makes
mode 2 auto reload, in contrast in mode 1 in which programmer has to reload TH and TL.
Mode 2 programming
When the TL register rolls from FFH to 0 and TF is set to 1, TL is reloaded automatically with the
original value kept by the TH register. To repeat the process, we must simply clear TF and let it go
without any need by the programmer to reload the original value. This makes mode 2 an auto-
reload, in contrast with mode 1 in which the programmer has to reload TH and TL.
It must be emphasized that mode 2 is an 8-bit timer. However, it has an auto- reloading capability. In auto-
reload, TH is loaded with the initial count and a copy of it is given to TL. This reloading leaves TH
unchanged, still holding a copy of the original value. This mode has many applications, including setting
the baud rate in serial communication, as we will see in Chapter 10.
Steps to program in mode 2
To generate a time delay using the timer’s mode 2, take the following steps.
Load the TMOD value register indicating which timer (Timer 0 or Timer 1) is to be used, and select
the timer mode (mode 2).
Load the TH registers with the initial count value.
Start the timer.
Keep monitoring the timer flag (TF) with the “JNB TFx, target” instruc tion to see whether it is
raised. Get out of the loop when TF goes high.
Clear the TF flag.
Go back to Step 3, since mode 2 is auto-reload.
Mode3- Mode 3 is also known as a split timer mode. Timer 0 and 1 may be programmed to be in mode 0, 1
and 2 independently of similar mode for other timer. This is not true for mode 3; timers do not operate
independently if mode 3 is chosen for timer 0. Placing timer 1 in mode 3 causes it to stop counting; the
control bit TR1 and the timer 1 flag TF1 are then used by timer0.
TCON register- Bits and symbol and functions of every bits of TCON are as follows:
BIT Symbol Functions
Timer1 over flow flag. Set when timer rolls from all 1s to 0.
Cleared
7 TF1 When the processor vectors to execute interrupt service
routine Located at program address 001Bh.
generate an interrupt.
The 8051 has two pins for transferring and receiving data by serial communication.
These two pins are part of the Port3(P3.0 &P3.1)
These pins are TTL compatible and hence they require a line driver to make them
RS232 compatible
Max232 chip is one such line driver in use.
Serial communication is controlled by an 8-bit register called SCON register; it is a
bit addressable register.
Interfacing to PC
SCON (Serial control) register
These two bits of SCON register determine the framing of data by specifying the number of bits per
character and start bit and stop bits. There are 4 serial modes.
SM0 SM1
0 0 Serial Mode 0
1 0 Serial Mode 2
1 1 Serial Mode 3
REN (Receive Enable) also referred as SCON.4.When it is high; it allows the 8051 to receive data
on the RxD pin. So to receive and transfer data REN must be set to 1.When REN=0, the receiver is
disabled. This is achieved as below
SETB SCON.4
TI (Transmit interrupt) is the D1 bit of SCON register. When 8051 finishes the transfer of 8-bit
character, it raises the TI flag to indicate that it is ready to transfer another byte. The TI bit is
raised at the beginning of the stop bit.
RI (Receive interrupt) is the D0 bit of the SCON register. When the 8051 receives data serially, via
RxD, it gets rid of the start and stops bits and places the byte in theSBUF register. Then it raises the
RI flag bit to indicate that a byte has been received and should be picked up before it is lost. RI is raised
halfway through the stop bit.
ADDRESSING MODES OF 8051:
The way in which the data operands are accessed by different instructions is known as the addressing
modes. There are various methods of denoting the data operands in the instruction. The 8051
microcontroller supports mainly 5 addressing modes. They are
This is a 1-byte instruction. This instruction rotates the A register content to the left.
Instruction Syntax
The Structure or Syntax of the 8051 Microcontroller Assembly Language is discussed here. Each line or
statement of the assembly language program of 8051 Microcontroller consists of three fields: Label,
Instruction and Comments.
Before seeing about these three fields, let us first see an example of how a typical statement or line in an
8051 Microcontroller Assembly Language looks like.
Fig: 8051 Instruction Structure
TESTLABEL: MOV A, 24H ; THIS IS A SAMPLE COMMENT
In the above statement, the “TESTLABEL” is the name of the Label, “MOV A, 24H” is the Instruction and
the “THIS IS A SAMPLE COMMENT” is a Comment.
NOTE: The brackets for Label and Comments mean that these fields are optional and may not be used in
all statements in a program.
Label :
The Label is programmer chosen name for a Memory Location or a statement in a program. The Label part
of the statement is optional and if present, the Label must be terminated with a Colon (:).
An important point to remember while selecting a name for the Label is that they should reduce the need
for documentation.
Instruction :
The Instruction is the main part of the 8051 Microcontroller Assembly Language Programming as it is
responsible for the task performed by the Microcontroller. Any Instruction in the Assembly Language
consists of two parts: Op-code and Operand(s).
The second part of the instruction is called the Operand(s) and it represents the Data on which the
operation is performed. There are two types of Operands: the Source Operand and the Destination Operand.
The Source Operand is the Input of the operation and the Destination Operand is where the result is stored.
The assembly language mnemonics are in the form of op-code, such as MOV, ADD, JMP, and so
on, which are used to perform the operations.
Fig: Assembly Language Syntax
Op-codeThe op-code is a single instruction that can be executed by the CPU. Here the op-code is a MOV
instruction.
Operands The operands are a single piece of data that can be operated by the op-code. Example,
multiplication operation is performed by the operands that are multiplied by the operand.
Syntax: MUL a,b;
CommentsThe last part of the Structure of 8051 Assembly Language is the Comments. Comments are
statements included by the developer for easier understanding of the code and is used for proper
documentation of the Program.
Comments are optional and if used, they must begin with a semicolon (;) or double slash (//) depending on
the Assembler.
The following statements will show a few possible ways of using Label, Instruction and Comments
The Assembly Language Directives do not have any effect on the contents of the 8051 Microcontroller
Memory (except DB and DW directives). These Directives are dependent on the Assembler Program and in
case of ASM51 Assembler, the following are the categories of Directives.
Fig:
Assembly Language Directives.
We will now see about few of the important and frequently used Assembly Language Directives. The most
useful directives are 8051 programming, such as: ORG (Set Origin)
The 8051 Microcontroller Assembly Language Program will start assembling from the Program Memory
Address 0000H. This is also the address from which the 8051 Microcontroller will start executing the code.
In order place the Program and Data anywhere in the Address Space of the 8051 Microcontroller, you can
use the ORG Directive.
Example:
ORG 0000H ; Tells the Assembler to assemble the next statement at 0000H
LJMP MAIN ; Code Memory at 0000H. Jump to MAIN.
ORG 000BH ; Tells the Assembler to assemble the next statement at 000BH
MAIN: NOP ; Code Memory at 000BH. MAIN starts here.
Fig: Assembly Language Directives DB
DB (Define Byte)
The DB Directive is used to define a Byte type variable. Using this directive, you can define data in
Decimal, Binary, HEX or ASCII formats. There should be a suffix of ‘B’ for binary and ‘H’ for HEX. The
ASCII Characters are placed in single quotation marks (like ‘string’).
Example:
ORG 0000H ; Tells the Assembler to assemble the next statement at 0000H
DB 10 ; Define Byte 10 (Decimal) and store at 0000H
DB 30H ; Define Byte 30 (HEX) and store at 0001H
DB ‘STRING’ ; Define String ‘STRING’ and store at 0002H to 0007H
DB 00001111B ; Define Byte 00001111 (Binary) and store at 0008H
DB 1234H ; Define Byte 34 (HEX) and store at 0009H. Only lower byte is accepted as DB can allocate
only a Byte of Memory.
DW (Define Word)
The Define Word (DW) Directive is used to include a 16-bit data in a program. The functionality
of DW is similar to that of DB except that DW generates 16-bit values.
EQU (Equate)
Using the EQU Directive, you can associate a Symbol (or Label) with a Value.
Example:
TMP EQU #30 ; Assigns the value #30 to the name TMP
RED_LED EQU P1.0 ; P1.0 is defined as RED_LED
END
The END Directive is used to stop the assembling process. This should be the last statement in the
program. END Directive cannot have a Label and the statements beyond END will not be processed by the
Assembler.
Example:
ORG 0000H
MOV A, 20H
MOV R0, #30
END
Data Type
The 8051 microcontroller contains a single data type of 8-bits, and each register is also of 8-bits size. The
programmer has to break down data larger than 8-bits (00 to FFH, or to 255 in decimal) so that it can be
processed by the CPU.
INSTRUCTION SET
8051 Microcontroller have set of instruction to perform different operations. There are five group of
instruction which are listed below.
Arithmetic Instructions
Logic Instructions
Data Transfer Instructions
Branch Instructions
Bit Manipulation Instructions
1. ARITHMETIC INSTRUCTION:
Arithmetic instructions perform several basic operations such as addition, subtraction, division,
multiplication etc. After execution, the result is stored in the first operand.
1. ADD A,Rn;
Instruction adds the register Rn (R0-R7) to the accumulator. After addition, the result is stored
in the accumulator
Before execution:
A=2Eh R4=12h
After execution:
A=40h R4=12h
2. ADD A,@Ri-
Adds the indirect RAM to the accumulator.
Ri: Register R0 or R1
Description:
Instruction adds the indirect RAM to the accumulator. Address of indirect RAM is stored in the
Ri register (R0 or R1). After addition, the result is stored in the accumulator. Register address:
R0=4Fh
Before execution:
A= 16h SUM= 33h
After execution :
A= 49h
3. ADDA,#DATA
Data: constant within 0-255 (0-FFh)
Description:
Instruction adds data (0-255) to the accumulator. After addition, the result is stored in the
accumulator.
ADD A,#33h
Before execution:
A= 16h
After execution:
A= 49h )
4. SUBB A,direct-
Instruction divides the value in the accumulator by the value in the B register. After division the
integer part of result is stored in the accumulator while the register contains the remainder. In case of
dividing by 1, the flag OV is set and the result of division is unpredictable. The 8-bit quotient is stored
in the accumulator and the 8-bit remainder is stored in the B register.
Before execution:
A=FBh (251dec.) B=12h (18 dec.)
After execution:
A=0Dh (13dec.) B=11h (17dec.) 13·18
+ 17 =251
8. DA A - Decimal adjust accumulator
Description: Instruction adjusts the contents of the accumulator to correspond to a BCD number after
two BCD numbers have been added by the ADD and ADDC instructions. The result in form of two 4-
digit BCD numbers is stored in the accumulator.
Before execution:
A=56h (01010110) 56BCD
B=67h (01100111)67BCD
After execution:
A=BDh (10111101)
After BCD conversion:
A=23h (00100011), C=1 (Overflow)
(C+23=123) = 56+67
Instruction performs logic AND operation between the accumulator and Rn register. The result is stored
in the accumulator.
Syntax:
ANL A,Rn
Before execution:
A= C3h (11000011 Bin.) R5= 55h (01010101 Bin.)
After execution:
A= 41h (01000001 Bin.)
XRL A,Rn - Exclusive OR register to accumulator Rn: any R register (R0-R7) Instruction performs
exclusive OR operation between the accumulator and the Rn register. The result is stored in the
accumulator.
Syntax:
XRL A,Rn
Before execution:
A= C3h (11000011 Bin.) R3= 55h (01010101 Bin.)
After execution:
A= 96h (10010110 Bin.)
CLR A - Clears the accumulator A: accumulator Instruction clears the accumulator.
Syntax:
CLR A
After execution:
A=0
Instruction complements all the bits in the accumulator (1==>0, 0==>1). Syntax:
CPL A
Before execution:
A=(00110110)
After execution:
A=(11001001)
RLC A - Rotates the accumulator one bit left through the carry flag A: accumulator
All eight bits in the accumulator and carry flag are rotated one bit left. After this operation, the bit 7 is
rotated into the carry flag position and the carry flag is rotated into the bit 0 position.
Syntax:
RLC A
Before execution:
A= C2h(11000010 Bin.) C=0
After execution:
A= 85h(10000100Bin.) C=1
RRC A - Rotates the accumulator one bit right through the carry flag A: accumulator All eight bits in
the accumulator and carry flag are rotated one bit right. After this operation, the carry flag is
rotated into the bit 7 position and the bit 0 is rotated into the carry flag position.
Syntax:
RRC A
Before execution:
A= C2h(11000010 Bin.) C=0
After execution:
A= 61h(01100001Bin.) C=0
SWAP A - Swaps nibbles within the accumulator A:
accumulator
A nibble refers to a group of 4 bits within one register (bit0-bit3 and bit4-bit7). This instruction
interchanges high and low nibbles of the accumulator.
Syntax:
SWAPA
Before execution: A=E1h (11100001)bin.
After execution:
A=1Eh (00011110)bin.
The instruction moves the Rn register to the accumulator. The Rn register is not affected. Syntax
MOV A,Rn
Beforeexecution:
R3=58h
After execution:
R3=58h A=58h
Instruction moves the indirectly addressed register of RAM to the accumulator. The register address is
stored in the Ri register (R0 or R1). The result is stored in the accumulator. The register is not affected.
Syntax:
MOV A,@Ri
Register Address SUM=F2h R0=F2h Before
execution:
SUM=58h
After execution:
A=58h SUM=58h
Instruction moves the indirectly adressed register of RAM to the direct byte. The register is not affected.
Syntax:
MOV Rx,@Ri Register
Address SUM=F3 Before
execution:
SUM=58h R1=F3
After execution:
SUM=58h TEMP=58h
MOVC A,@A+DPTR - Moves the code byte relative to the DPTR to the accumulator Instruction first
adds the 16-bit DPTR register to the accumulator. The result of addition is then used as a memory
address from which the 8-bit data is moved to the accumulator.
ANL C,bit - AND direct bit to the carry flag C: Carry flag Bit: any
bit of RAM,
Instruction performs logic AND operation between the direct bit and the carry flag. Syntax:
ANL C,bit
Before execution:
ACC= 43h (01000011 Bin.)C=1
After execution:
ACC= 43h(01000011 Bin.) C=0
C: Carry flag, Instruction clears the carry flag. After execution: C=0
Bit: any bit of RAM, Instruction clears the specified bit. Syntax:
CLR P0.3
Before execution:
P0.3=1 (input pin)
After execution:
P0.3=0 (output pin)
Bit: any bit of RAM, Instruction complements the specified bit of RAM (0==>1, 1==>0). Syntax:
CPL P0.3
Before execution:
P0.3=1 (input pin) After
execution: P0.3=0
(output pin)
C: Carry flag, Instruction complements the carry flag (0==>1, 1==>0). Syntax:
CPL C
Before execution:
C=1
After execution:
C=0
MOV bit,C - Moves the carry flag to the direct bit C: Carry flag, Bit: any bit ofRAM Instruction moves
the carry flag to the direct bit. After executing the instruction, the carry flag is not affected.
Syntax:
MOVP1.2,C
After execution:
If C=0 P1.2=0 If C=1 P1.2=1
MOV C,bit - Moves the direct bit to the carryflag C: Carry flag, Bit: any bit of RAM Instruction moves
the direct bit to the carry flag. After executing the instruction, the bit is not affected.
Syntax:
MOV C, P1.4
After execution:
If P1.4=0 C=0 If P1.4=1 C=1
Instruction sets the specified bit. The register containing that bit must belong to the group of the so called
bit addressable registers.
Syntax:
SETB P0.1
Before execution:
P0.1 = 34h (00110100) pin 1 is configured as an output After
execution:
P0.1 = 35h (00110101) pin 1 is configured as an inputs
6. Write an assembly language program to perform the subtraction of two 16-bit numbers.
MOV R0,#0DCH //LOWER NIBBLE OF NO.1
MOV R1,#0FEH //HIGHER NIBBLE OF NO.1
MOV R2,#34H //LOWER NIBBLE OF NO.2
MOV R3,#12H //HIGHER NIBBLE OF NO.2
CLR C // MOV
A,R0 SUBB
A,R2 MOV
22H,A MOV
A,R1 SUBB
A,R3 MOV
21H,A MOV
00H,C END
7. Program to find the sum of 10 numbers stored in the array
MOV R0,#50H
MOV R2,#6
CLR A
MOV R7,A
XYZ: ADD A,@R0
JNC NEXT
INC R7
NEXT: INC R0
DJNZ R2 , XYZ
END
MOV 50H,#00
MOVX A,@DPTR
MOV R0,A
INC DPTR
L1 MOVX A,@DPTR
CJNE A,50H,4115
L2 INC DPTR
DJNE R0,L1
MOV A,50H
MOVX @DPTR,A
L3 SJMP L3
JC L2
MOV 50H,A
SJMP L2
Calculating Time Delay: (By Assuming XTAL Frequency as 11.0592MHz)
In Hex In Decimal
(FFFF – YYXX + 1) * 1.085us Convert YYXX values of the TH, TL
Where YYXX are TH, TL initial values registers to decimal to get a NNNNN
respectively. decimal number, then
(65536 – NNNNN) * 1.085 us
Example
Indicate which mode and which timer are selected for each of the following.
(a) MOV TMOD, #01H (b) MOV TMOD, #20H (c) MOV TMOD, #12H
Solution:
We convert the value from hex to binary. From Figure 9-3 we have:
(a) TMOD = 00000001, mode 1 of timer 0 is selected.
(b)TMOD = 00100000, mode 2 of timer 1 is selected.
(c) TMOD = 00010010, mode 2 of timer 0, and mode 1 of timer 1 are
Find the timer’s clock frequency and its period for various 8051-based
system, with the crystal frequency 11.0592 MHz when C/T bit of TMOD is 0.
Solution:
Write a program to create square wave of 50% duty cycle (with equal portions
high and low) on the P1.5 bit use Timer 0 to generate the time delay.
Solution:
Write a program segment that uses timer 1 in mode 2 to toggle P1.0 once
whenever the counter reaches a count of 100. Assume the timer clock is taken
from external source P3.5 (T1).
The TMOD value is 60H
The initialization value to be loaded into
TH1 is 256 - 100 = 156 = 9CH