Introduction To The AT89LP51RC2 Microcontroller Lecture AT89 Instructions
User Manual:
Open the PDF directly: View PDF .
Page Count: 26

1
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Introduction to the
AT89LP51RC2 Microcontroller
Dr. Jesús Calviño-Fraga P.Eng.
Department of Electrical and Computer Engineering, UBC
Office: KAIS 3024
E-mail: jesusc@ece.ubc.ca
Phone: (604)-827-5387
University of British Columbia
Electrical and Computer Engineering
ELEC291/ELEC292
Introduction to the AT89LP51RC2 2
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Objectives
• Introduction to the AT89LP51RC2
microcontroller.
• Introduction to the 8051 instruction set.
• Understand how an assembler compiler is used
and the files it generates.
• Calculate machine code execution time.
• Assemble a bread boarded AT89LP51RC2
microcontroller with LCD.
• Write, compile, download, and run programs into
the AT89LP51RC2/LCD microcontroller system.

2
Introduction to the AT89LP51RC2 3
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
AT89LP51RC2
Introduction to the AT89LP51RC2 4
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
AT89LP51RC2

3
Introduction to the AT89LP51RC2 5
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
AT89LP51RC2
Somewhere in the Datasheet it says that it can run
at up to 24 MHz, that is why I selected a
22.1184MHz crystal.
Introduction to the AT89LP51RC2 6
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
AT89LP51RC2 Features
• Industry standard. The 8051 is still a very common
processor.
• Very similar to original 8051/8052 from the 1980’s. Uses
the well know 8051 instruction set. Can be made
backward compatible.
• DIP! Easy to breadboard.
• 34 I/O pins. Also lots of useful peripherals.
• External memory interface. Rare nowadays.
• Lots of tools and resources.
• Not too complicated. User manual is “only” 254 pages.
• 1.7732 CA$ each in quantities of 100.

4
Introduction to the AT89LP51RC2 7
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
AT89LP51RC2 Draw Backs
• The built-in ADC (Analog to Digital
Converter) is atrocious! Useless for
ELEC291/292. We will be using an
external ADC.
• 8-bit processor. Well, this is an advantage
sometimes!
Introduction to the AT89LP51RC2 8
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
AT89LP51RC2 Pin Out

5
Introduction to the AT89LP51RC2 9
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
AT89LP51RC2 block diagram
Figure taken from
AT89LP51RC2 user
manual
Warning: it uses
different
instructions to
access the different
memory spaces!
Introduction to the AT89LP51RC2 10
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Assembling the AT89LP51RC2 Basic
System. Using Boot Loader only.
AT89LP51RC2
POL (31)
GND (20)
VCC (40)
5V
XTAL2 (18)
XTAL1 (19)
P4.5 (29)
Boot
22.1148MHz
BO230XS
VCC Out
5V
GND
TXD (10) RXD
(11) TXD
RXD
Reset
(9) RST#
USB
Advantages: Fewer wires, more I/O,
works on Windows, Linux, and Macs
5V
0.1µF
5V
0.1µF
5V
330Ω

6
Introduction to the AT89LP51RC2 11
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Assembling the AT89LP51RC2 ISP
System. Using SPI or Boot Loader.
SPI-ISP Advantages: Faster programming
times, fast mode configuration, NO need to
press buttons to start programming.
AT89LP51RC2
POL (31)
GND (20)
VCC (40)
5V
XTAL2 (18)
XTAL1 (19)
P4.5 (29)
Boot
22.1148MHz
BO230XS
VCC Out
5V
GND
TXD (10) RXD
(11) TXD
RXD
Reset
(9) RST#
USB
5V
330Ω
(6) MOSI
(7) MISO
(8) SCK
CBUS3
RTS
5V
0.1µF
5V
0.1µF
Note: CBUS3 is pin
6 of J3 in BO230XS
CTS (5) SS
Introduction to the AT89LP51RC2 12
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
BO230XS J3 and J1 Pins
CBUS36
CBUS05
CBUS14
GND3
CBUS22
VCC1
NamePIN
J3
RTS6
TXD5
RXD4
GND3
CTS2
VCC1
NamePIN
J1

7
Introduction to the AT89LP51RC2 13
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
BOM (Bill of Materials)
Push button switch2
AT89LP51RC2 IC 80C51 MCU 32K
FLASH 40-DIP
1
BO230XS serial USB adapter1
22.1184MHZ Crystal1
LED 5MM GREEN1
330Ωresistor1
0.1uF capacitors2
DescriptionQuantity
Introduction to the AT89LP51RC2 14
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Assembling the AT89LP51RC2
System
Wire length: 4
means 4 x 0.1
inches. 0.1
inches is the
distance
between
adjacent holes in
the breadboard.

8
Introduction to the AT89LP51RC2 15
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Assembling the AT89LP51RC2
System
It should take about 30 minutes!
Introduction to the AT89LP51RC2 16
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Assembling the AT89LP51RC2
System

9
Introduction to the AT89LP51RC2 17
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
BO230XS
• Very simple circuit that allows to connect to
many different types of microcontrollers.
• Adds serial port connection to computer via
USB.
• Allows for In System Programming (ISP) for
many microcontrollers. Some examples: The
whole AT89LP family from Atmel/Microchip, The
C8051/EFM8 family from Silabs, Some STM32F
ARMs from ST Microelectronics, the LPC824
ARM from NXP, all PIC32MX from Microchip,
the ATMega328 (and other members of the
family) from Atmel/Microchip, and some
MSP430 from Texas Instruments.
Introduction to the AT89LP51RC2 18
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Add LED/Resistor to P3.7
AT89LP51RC2
330Ω
P3.7
VCC=5V
5 1.8
10
330
LED
V V
I mA
−
= ≈
Ω
LED turns-on
with logic zero.
LED voltage drop
@ 10mA (approx):
IR=1.4V
Red=1.8V
Yellow=1.9V
Green=2.0V
Blue=2.9V

10
Introduction to the AT89LP51RC2 19
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
; Blinky.asm: toggles an LED attached to pin 17 (P3.7)
$MODLP51
org 0000H
ljmp myprogram
; When using a 22.1184MHz crystal in fast mode
; one cycle takes 1.0/22.1184MHz = 45.21123 ns
WaitHalfSec:
mov R2, #89
L3: mov R1, #250
L2: mov R0, #166
L1: djnz R0, L1 ; 3 cycles->3*45.21123ns*166=22.51519us
djnz R1, L2 ; 22.51519us*250=5.629ms
djnz R2, L3 ; 5.629ms*89=0.5s (approximately)
ret
myprogram:
mov SP, #7FH
M0:
cpl P3.7
lcall WaitHalfSec
sjmp M0
END
Blinky
Introduction to the AT89LP51RC2 20
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Compile “Blinky.asm” and flash
“Blinky.hex”.
• Download and install CrossIDE from the course
web page.
• Start CrossIDE and create a new assembly file.
copy and paste the code from previous slides.
Save as “Blinky.asm”.
• Click Build->ASM51. Click the “Browse” button
beside “Complete path of assembler” and select
a51.exe from the “Call51\bin” folder where you
installed CrossIDE. Then press “Ok”.

11
Introduction to the AT89LP51RC2 21
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Flash and run into the AT89LP51RC2
using Boot Loader
• While pressing button “BOOT”, press and
release button “RESET”.
• On Crosside, click “fLash”->”Atmel 89LP
Bootloader”. Make sure the file “Blinky.hex” is
selected. Also make sure that the “Port” box is
set to the USB port # assigned to the BO230XS.
Click the “Flash” button and wait until it finishes.
• Press and release “RESET”. The program starts
running!
Introduction to the AT89LP51RC2 22
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Flash and run into the
AT89LP51RC2 using SPI-ISP
• On Crosside, click “fLash”->”Atmel 89LP
Using SPI”. Make sure the file
“Blinky.hex” is selected. Click the “Flash”
button and wait until it finishes. Done!
(Works only on Windows)

12
Introduction to the AT89LP51RC2 23
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Summary: Blinky
• To run “Blinky” in the AT89LP51RC2 we
need to complete the following steps:
1. Assemble the AT89LP51RC2
Microcontroller system in a bread board.
Attach LED to P3.7. (Or any other available
pin, just change the code!)
2. Edit and Compile “Blinky.asm”.
3. Flash and run “Blinky.hex” into the
AT89LP51RC2 processor.
Introduction to the AT89LP51RC2 24
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
8051 Instruction Set
1. Arithmetic Operations
2. Logical Operations
3. Data Transfer
4. Boolean Variable Manipulation
5. Program Branching and Machine Control
WARNING: I did my best to change the number of cycles per instruction
to the actual values for the AT89LP51RC2, but there may be errors. The
ultimate reference is the AT89LP51RC2 user manual!
Note: not showing AT89LP51RC2 extended instructions.

13
Introduction to the AT89LP51RC2 25
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Arithmetic Operations (ADD)
FunctionCBOpcodeMnemonic
(A) = (A) + (Rn) 1128H-2FHADD A, Rn
(A) = (A) + (C) + #data 2234HADDC A,#data
(A) = (A) + (C) + ((Ri)) 2136H-37HADDC A, @Ri
(A) = (A) + (C) + (direct) 2235HADDC A, direct
(A) = (A) + (C) + (Rn) 1138H-3FHADDC A, Rn
(A) = (A) + #data 2224HADD A, #data
(A) = (A) + ((Ri)) 2126H-27HADD A, @Ri
(A) = (A) + (direct) 2225HADD A, direct
Introduction to the AT89LP51RC2 26
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Arithmetic Operations (SUB)
(A) = (A) - (C) - (Rn) 1198H-9FHSUBB A, Rn
FunctionCBOpcodeMnemonic
(A) = (A) - (C) - (direct) 2295HSUBB A, direct
(A) = (A) - (C) - #data 2294HSUBB A, #data
(A) = (A) - (C) - ((Ri)) 2196H-97HSUBB A, @Ri

14
Introduction to the AT89LP51RC2 27
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Arithmetic Operations (INC)
FunctionCBOpcodeMnemonic
(A) = (A) + 1 1104HINC A
(DPTR) = (DPTR) + 1 21A3HINC DPTR
((Ri)) = ((Ri)) + 1 2106H-07HINC @Ri
(direct) = (direct) + 1 2205HINC direct
(Rn) = (Rn) + 1 1108H-0FHINC Rn
Introduction to the AT89LP51RC2 28
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Arithmetic Operations (DEC)
FunctionCBOpcodeMnemonic
(A) = (A) - 1 1114HDEC A
((Ri)) = ((Ri)) - 1 2116H-17HDEC @Ri
(direct) = (direct) -1 2215HDEC direct
(Rn) = (Rn) - 1 1118H-1FHDEC Rn

15
Introduction to the AT89LP51RC2 29
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Arithmetic Operations (Other)
FunctionCBOpcodeMnemonic
(B15–8 ), (A7–0 ) = (A) x (B)21A4HMUL AB
Converts (A) to BCD11D4HDA A
(B15–8 ), (A7–0 ) = (A) / (B)4184HDIV AB
Introduction to the AT89LP51RC2 30
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Logic Operations (AND)
FunctionCBOpcodeMnemonic
(A) = (A) AND (Rn) 1158H-5FHANL A, Rn
(direct) = (direct) AND #data 3353HANL direct,
#data
(direct) = (direct) AND A 2252HANL direct, A
(A) = (A) AND #data 2254HANL A, #data
(A) = (A) AND ((Ri)) 2156H-57HANL A, @Ri
(A) = (A) AND (direct) 2255HANL A, direct

16
Introduction to the AT89LP51RC2 31
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Logic Operations (OR)
FunctionCBOpcodeMnemonic
(A) = (A) OR (Rn) 1148H-4FHORL A, Rn
(direct) = (direct) OR #data 3343HORL direct,
#data
(direct) = (direct) OR (A) 2242HORL direct, A
(A) = (A) OR #data 2244HORL A, #data
(A) = (A) OR ((Ri)) 2146H-47HORL A, @Ri
(A) = (A) OR (direct) 2245HORL A, direct
Introduction to the AT89LP51RC2 32
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Logic Operations (XOR)
FunctionCBOpcodeMnemonic
(A) = (A) XOR (Rn) 1168H-6FHXRL A, Rn
(direct) = (direct) XOR #data 3363HXRL direct,
#data
(direct) = (direct) XOR (A) 2262HXRL direct, A
(direct) = (A) XOR #data 2264HXRL A, #data
(A) = (A) XOR ((Ri)) 2166H-67HXRL A, @ Ri
(A) = (A) XOR (direct) 2265HXRL A, direct

17
Introduction to the AT89LP51RC2 33
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Logic Operations (Other)
Rotate (A) Right Through Carry1113HRRC A
(A3-0 ) ↔(A7-4 ) 11C4HSWAP A
FunctionCBOpcodeMnemonic
(A) = 0 11E4HCLR A
Rotate (A) Right1103HRR A
Rotate (A) Left Through Carry1133HRLC A
Rotate (A) Left1123HRL A
(A) = (A’) 11F4HCPL A
Introduction to the AT89LP51RC2 34
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Data Transfer (MOV 1 of 3)
(direct) = (A) 22F5HMOV direct, A
(Rn) = #data 2278H-7FHMOV Rn, #data
(Rn) = (direct) 22A8H-AFHMOV Rn, direct
(direct) = (Rn) 2288H-8FHMOV direct, Rn
FunctionCBOpcodeMnemonic
(A) = (Rn) 11E8H-EFHMOV A, Rn
(Rn) = (A) 11F8H-FFHMOV Rn, A
(A) = #data 2274HMOV A, #data
(A) = ((Ri)) 11E6H-E7HMOV A, @Ri
(A) = (direct) 22E5HMOV A, direct

18
Introduction to the AT89LP51RC2 35
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Data Transfer (MOV 2 of 3)
(A) = ((A) + (DPTR)) 3193HMOVC A, @A +
DPTR
(DPTR) = #data15-0 (DPH) =
#data15-8 (DPL) = #data7-0
3390HMOV DPTR,
#data16
((Ri)) = #data 2276H-77HMOV @Ri, #data
FunctionCBOpcodeMnemonic
(direct1) = (direct2) (source)
(destination)
3385HMOV direct1,
direct2
((Ri)) = (direct) 22A6H-A7HMOV @Ri, direct
((Ri)) = A 11F6H-F7HMOV @Ri, A
(direct) = #data 3375HMOV direct,
#data
(direct) = ((Ri)) 2286H-87HMOV direct, @Ri
Introduction to the AT89LP51RC2 36
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Data Transfer (MOV 3 of 3)
FunctionCBOpcodeMnemonic
(A) = ((A) + (PC)) 4183HMOVC A, @A +
PC
((DPTR)) = (A) 11F0HMOVX
@DPTR,A
((Ri)) = (A) 11F2H-F3HMOVX @Ri, A
(A) = ((DPTR)) 21E0HMOVX A,
@DPTR
(A) = ((Ri)) 21E2H-E3HMOVX A, @Ri

19
Introduction to the AT89LP51RC2 37
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Data Transfer (Other)
(A3-0) = ((Ri3-0 )) 21D6H-D7HXCHD A, @Ri
FunctionCBOpcodeMnemonic
(SP) = (SP) + 1 ((SP)) = (direct) 22C0HPUSH direct
(A) = ((Ri)) 21C6H-C7HXCHA, @Ri
(A) = (direct) 22C5HXCHA, direct
(A) = (Rn) 11C8H-CFHXCHA, Rn
(direct) = ((SP)) (SP) = (SP) - 1 22D0HPOP direct
Introduction to the AT89LP51RC2 38
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Boolean Variable Manipulation
(C) = (C) OR (bit’) 22A0HORL C, bit’
(C) = (bit) 22A2HMOV C, bit
(C) = (C) AND (bit’) 22B0HANL C, bit’
(C) = (C) OR (bit) 2272HORL C, bit
(bit) = (C) 2292HMOV bit, C
(C) = (C) AND (bit) 2282HANL C, bit
(bit) = (bit) 22B2HCPL bit
FunctionCBOpcodeMnemonic
(C) = 0 11C3HCLR C
(C) = (C) 11B3HCPL C
(bit) = 1 22D2HSETB bit
(C) = 1 11D3HSETB C
(bit) = 0 22C2HCLR bit

20
Introduction to the AT89LP51RC2 39
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Program Branching (1 of 3)
(PC) = (A) + (DPTR) 2173HJMP @A +
DPTR
(PC) = (PC) + 2 (PC) = (PC) +
rel
3280HSJMP rel
(PC) = addr15-0 4302HLJMP addr 16
FunctionCBOpcodeMnemonic
(PC) = (PC) + 2 (PC10-0 ) =
page address
32AAA10001ACALL addr 11
(PC) = (PC) + 2 (PC10-0 ) =
page address
32AAA00001AJMP addr 11
Return from interrupt4132HRETI
Return from ACALL/CALL4122HRET
(PC) = addr15-0 4312HLCALL addr 16
Introduction to the AT89LP51RC2 40
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Program Branching (2 of 3)
(PC) = (PC) + 3 IF (bit) = 1 THEN
(bit) = 0 and (PC) = (PC) + rel
3/4310HJBC bit, rel
(PC) = (PC) + 3 IF (bit) = 0
THEN (PC) = (PC) + rel
3/4330HJNB bit, rel
FunctionCBOpcodeMnemonic
(PC) = (PC) + 2 IF (A) = 0 THEN
(PC) = (PC) + rel
2/3260HJZ rel
(PC) = (PC) + 3 IF (bit) = 1
THEN (PC) = (PC) + rel
3/4320HJB bit, rel
(PC) = (PC) + 2 IF (C) ≠0 THEN
(PC) = (PC) + rel
2/3250HJNC rel
(PC) = (PC) + 2 IF (C) = 1 THEN
(PC) = (PC) + rel
2/3240HJC rel
(PC) = (PC) + 2 IF (A) ≠0 THEN
(PC) = (PC) + rel
2/3270HJNZ rel

21
Introduction to the AT89LP51RC2 41
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Program Branching (3 of 3)
(PC) = (PC) + 1 1100HNOP
Decrement and Jump if not zero43D5HDJNZ direct,rel
FunctionCBOpcodeMnemonic
Compare and jump if not equal
rel
43B5HCJNE A, direct,
rel
Decrement and Jump if not zero33D8H-DFHDJNZ Rn, rel
Compare and jump if not equal
rel
43B6H-B7HCJNE @Ri,
#data, rel
Compare and jump if not equal
rel
43B8H-BFHCJNE Rn, #data,
rel
Compare and jump if not equal
rel
43B4HCJNE A, #data,
rel
Introduction to the AT89LP51RC2 42
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
The 8051 Assembly Language
Instruction
•An Assembly language instruction consists of four
fields:
[label : ] mnemonic [operands] [;comment]
•Examples:
L1: MOV A, #’*’ ; Load Acc with ASCII for ‘*’
NOP
; We can just have comments!
L3: ; We can also place labels anywhere
DJNZ R0, L3

22
Introduction to the AT89LP51RC2 43
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Writing and compiling an 8051
assembly language program
EDITOR
ASSEMBLER
myfile.asm
myfile.lst
myfile.hex
Microcontroller chip
or soft-processor
Introduction to the AT89LP51RC2 44
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
AT89LP51RC2 Block Diagram
Internal
Interrupts
8-bit bus
CPU
Oscillator
Interrupt
Control
32k FLASH
ROM 1152 bytes
XRAM
256 bytes
RAM
Timer 2
Timer 1
Timer 0
BUS
CONTROL 5 I/O
PORTS
SERIAL
PORT
P
0
P
1
P
2
P
3
P
4
TXD RXD
External
Interrupts
MOVXMOVMOVC
Notice the different
instructions to
access the different
memory spaces!
(Simplified)

23
Introduction to the AT89LP51RC2 45
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Adding an LCD
(2)
P1.1
(3)
P1.2
(4)
P1.3
AT89LP51RC2
(12)
P3.2
(13)
P3.3
(14)
P3.4
(15)
P3.5
VSS (1)
VDD (2)
V0 (3)
RS (4)
RW (5)
E (6)
D0 (7)
D1 (8)
D2 (9) LCD
D3 (10)
D4 (11)
D5 (12)
D6 (13)
D7 (14)
A (15)
K (16)
5V
2k
• Example configures
LCD in 4-bit mode.
Saves pins and wires!
• Standard Hitachi
HD44780 controller
• Pin assignments
arbitrary, but source
code must match
wiring
•Pins 7, 8, 9, 10, 15,
16 not connected.
Introduction to the AT89LP51RC2 46
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Soldering Wires to LCD

24
Introduction to the AT89LP51RC2 47
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
AT89LP51RC2/LCD
Introduction to the AT89LP51RC2 48
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Lab 1 Demo
• ‘LCD_test_4bit.asm’: this a test program for the
AT89LP51RC2/LCD with the pins as shown in
previous slides. Test program prints ‘A’ in
column 1 of row 1, and ‘B’ in column 3 of row 2.
• Write your name (or a short version of it!) on row
1. Write your student number in row 2.
• Add extra functionality/features for extra marks.
• This lab could take you a long time to complete.
Start early!
• Be as neat as possible. You’ll be using the
AT89LP51RC2/LCD system for the next three
weeks!

25
Introduction to the AT89LP51RC2 49
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Save your ICs!
• Integrated circuits (ICs) are delicate
devices that can be damaged easily by:
– Applying an inappropriate voltage.
– Connecting live signals to the IC when not
power up.
– Electrostatic discharges. This happens
frequently!
Introduction to the AT89LP51RC2 50
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Chairs Available in labs

26
Introduction to the AT89LP51RC2 51
© Jesús Calviño-Fraga, 2009-2019. Not to be copied, used, or revised without
explicit written permission from the copyright owner.
Electrostatic Discharges and The
Blue/Gray Chairs of Death!
• Some of the chairs in MCLD labs are blue/gray.
• The blue/gray chairs are NOT really designed
for an electronics lab use: they don’t dissipate
electrostatic charge. The black foamy chairs
are designed for lab use: they dissipate
electrostatic charge.
• If you are wearing a sweater, the air is dry, and
you are seating in a blue chair you will likely get
charged. If you discharge through your circuit it
may permanently damage the ICs. Solution:
before touching your circuit, touch the grounded
metal rack in the work bench.