Вы находитесь на странице: 1из 86

EPB/SLK-51

(Low cost 8051 embedded kit with in-circuit


programming facility)

Users Manual
Edutech Systems
304, Sarjan Complex
Pratap Road
Baroda-390 001
Tel. (0265) 438317
Email: info@edutechonline.com
Site: www.edutechonline.com

Terms and Conditions for use of the EPB/SLK-51


For the purposes of this document, the term THE PRODUCT shall be used
to refer to EPB/SLK-51 (Educational Practice Board/Self-Learning
Card).
Terms and Conditions:
1) You agree to use THE PRODUCT entirely at your own risk, and
assume all responsibility for such use. The author and distributors of
THE PRODUCT do not warrant it fit or suitable for any particular
purpose.
2) There exists no warranty for on-board components specially the CPU
chip.

EPB/SLK-51 User Manual

CONTENTS:
Chapter 1

Introduction to EPB/SLK-51

04

Chapter 2

Features of EPB/SLK-51

06

Chapter 3

Before you install

07

Chapter 4

Understanding the EPB/SLK-51

09

Chapter 5

The Virtual Programmer

15

Chapter 6

Operating Steps

16

Chapter 7

Integrated Programming Tools

18

Chapter 8

Embedded Driver Routines

23

Chapter 9

Embedded Driver Description &


Example Programs

38

Chapter 10

FAQ

81

EPB/SLK-51 User Manual

Chapter 1
Introduction to Educational Practice Board
(EPB)/Self Learning Card (SLK-51)
Edutech Systems, Welcomes you to Educational Practice Board
(EPB)/Self-Learning Card (SLK-51) the first of its kind of approach to
learn, test and apply microcontroller.
This board is available in two versions. The first one is Educational
Practice Board (EPB) & the second version is the Self Learning Card
(SLK-51). Both the versions are basically same but only differ on the basis
of certain features.
The EPB is a complete learning platform designed to learn, test and apply
microcontroller 8051 based activities. This board has an extra breadboard
facility enabling the users to insert different components like LEDs,
Switches, 7-segment LEDs, Transistors, Relays, and ICs from 8 to 40 pins
etc and then interface with the 8051 controller. Also the EPB comes with a
wooden box package along with component box, hook up wires and
manual. This board is specially designed for institutes where large
numbers of students are suppose to use the platform. The breadboard
facility enables different users to test and apply number of components
with microcontroller 8051 which can again be reused.
The SLK-51 is also Educational Practice Board, which is a very low price
edition exclusively for students. For those working alone, its a quick
platform for building a circuit and applying the logic.
The SLK-51 contains a general-purpose area instead of a breadboard.
Here you can mount the component temporary or solder your circuit that is
to be interfaced with the controller. Also it does not come in wooden
packing.

EPB/SLK-51 User Manual

The SLK-51 is the first of its kind of platform designed for users who are
undergoing 8051 curriculum. Large number of exercises can be tried out
on SLK-51 board, which will enable the users to confidently undertake
their projects and application development.
Also both the EPB/SLK-51 has the capability of in-circuit programming
which will eliminate the need of any external programmer or eraser. You
can write and erase the chip memory (64K) for number of times.
This approach will lead you to develop your project in the way
professionals do.
Generally, you should try to develop any idea or project in a modular way.
You should divide the application into different modules and first try them
individually. Later you can club these modules once tested into a full fledge
application.
This exercises requires number of writing and erasing actions, which can
be easily done on this boards. Also all the port pins are available at your
dispersal and you can use them as per your requirement.
Thus unlike a conventional kit it does not restrict you to use only limited
features and lets you work to derive a truly single chip solution.

EPB/SLK-51 User Manual

Chapter 2
Features of EPB/SLK-51

The Educational Practice Board/Self Learning Card (SLK-51) consists of


the following feature:
Features of EPB/SLK-51:
1) Single chip design with 89C51RD2 chip.
2) In circuit programming facility thus eliminating the need of having a
separate programmer.
3) On board 64k Flash Program Memory.
4) On board power supply.
5) Serial connectivity to PC with on-board serial link.
6) General-purpose area to interface your own circuits.
7) All port pins brought to general-purpose area along with power supply
to enable quick and easy circuit building.
8) Facility to interface additional board either provided by Edutech or
design by third party.
9) Low cost & specially designed for students undergo 8051 curriculum &
projects.
10) Large number of practice examples and softwares like assembler
bundled with the accompany CD.

EPB/SLK-51 User Manual

Chapter 3
Before you install
Packing List:
Before installing the EPB/SLK-51 take a moment to enable your package
content to make sure you received everything.
In addition to this manual, the Educational Practice Board package
should include:
1) The EPB packed in a wooden box
2) Component box
3) Programming cable
4) CD ROM containing examples and utilities
5) Product Registration/Feedback card

The Self Development Kit (SDK-51) pack should include:


1) The Self-learning kit SLK-51
2) Specially Designed General-purpose Board (GPB-51)
3) Programming cable/Flat Cable
4) CD ROM
5) Feedback/Registration Card

EPB/SLK-51 User Manual

System Requirement:
The EPB/SLK-51 card has to be connected to the PC using the
programming cable provided with the pack. The programs are to be
developed on the PC using the utility tools provided and then transferred
to the EPB/SLK-51. Hence the PC should have the following specification:
Pentium PC with available serial port
Microsoft Windows 95/98 or above
CD drive for installation
10 MB Hard disk space
16 MB RAM (32 MB or above preferred)
Windows compatible mouse

EPB/SLK-51 User Manual

P 1 .0
P 1 .2
P 1 .4
P 1 .6
x
P 3 .1
P 3 .3
P 3 .5
P 3 .7
+5V

P 2 .3

P 2 .7

P 1 .0

P 1 .1

P 3 .4

P 3 .5

P 3 .7
P 3 .6

PRO G
O R ED LED
O G R EEN LED
R UN
1
3
5
7
9
11
13
15
17
19
P 2 .1

S W IT C H

P 2 .2

1
3
5
7
9
11
13
15
17
19

2
4
6
8
10
12
14
16
18
20

2
4
6
8
10
12
14
16
18
20
JP2

JP1

P 0 .5

EPB/SLK-51 User Manual


P 0 .4
P 0 .3

P 3 .0

P 3 .1

P 3 .2

P 3 .3

S U P P LY
P 0 .7

C P U
1
3
5
7
9
11
13
15
17
19

1
3
5
7
9
11
13
15
17
19

P 0 .2

P89051R D 24B P
P 0 .1

P O .0
P O .2
P O .4
P O .6
x
P 2 .1
P 2 .3
P 2 .5
P 2 .7
5V

2
4
6
8
10
12
14
16
18
20

2
4
6
8
10
12
14
16
18
20

P 1 .1
P 1 .3
P 1 .5
P 1 .7
P 3 .0
P 3 .2
P 3 .4
P 3 .6
X
GND

P O .1
P O .3
P O .5
P O .7
P O .0
P 2 .2
P 2 .4
P 2 .6
ALE
GND

Chapter 4
Understanding the EPB/SLK-51

The Block Diagram

PC
IN T E R F A C E

P 0 .0

P 0 .6

P 2 .0

P 2 .5
P 2 .4

P 2 .6

P 1 .2

P 1 .3

P 1 .4

P 1 .6
P 1 .5

P 1 .7

Block Description:
The power supply:
The EPB/SLK-51 card works on a +5 volt supply. The power unit provided
along with the package consists of an adapter, which takes 230V as input
and gives 9V AC as output. This 9V AC supply is plugged into the card.
The onboard power circuit rectifies and generates a regulated +5V supply.
The supply is also made available at the general-purpose area to enable
easy interface. It is also made available to the expansion slot so that the
same power supply can be used for powering the additional interface
cards. These cards can be either third party cards or proprietary
interfacing cards provided by Edutech Systems. Some of these cards
include LCD/keyboard, EEPROM, RTC, 7-segment, ADC, DAC, stepper
motor interfacing cards etc.
The CPU The EPB/SLK-51 contains 89C51RD2 controller from Philips. This
controller is pin-to-pin compatible with our conventional 8051/89C51 CPU.
The card has been designed to support 89C51 variants.
Due to various advantages and unique features, we have selected
89C51RD2. Though it is costly compared to 89C51, we have selected it to
provide the users, the exposure of latest trend in the industry and also
make the user aware of different features that eliminate certain
conventional requirement.
The EPB/SLK-51 has a unique feature of In-circuit programming. Because
of this feature, you can write and erase the chip without even removing it
from the socket. Thus you need not require any programmer unit to
program or erase the on-board chip.

EPB/SLK-51 User Manual

10

Also you enjoy a full 64KB of flash program memory. Thus you can design
application that requires more program memory. Also because of the
facility of allowing number of write/erase operation, you can easily develop
your programs in modular way. These modules can be loaded and tested
individually and later they can be merged with the main program. Thus
because of these features, you can easily do your R & D activity.
Moreover for those users who are new to the concept and are learning &
applying controller for the first time, can find this feature useful as they can
easily rectify & modify errors in their development programs.
Apart from these features, the chips have lot of other advantages. Details
can be studied referring to the data sheets.
Serial Port:
Since the EPB/SLK-51 is required to be connected to the PC, there exists
an on-board serial port. The program has to be developed using an IBMPC. Different tool sets can be used to develop the programs and convert
them to hex file format. The hex file is then copied to the board through the
serial port. Because there is a facility of in-circuit programming, we can
directly transfer the hex file to the board. The transfer is possible with the
help of virtual soft-programmer. More details of this virtual soft
programmer can be referred in the coming chapter.
To facilitate the downloading of the programs to the board, a programming
cable is provided in the pack.
Switch:
A special switch is provided on-board to select the mode of operation.
Because as discussed earlier, there is a facility of downloading a program
to the board and also to erase this program. Hence there are two modes
of operations i.e., the RUN mode and the Programming mode. In the
RUN mode, the program downloaded to the board executes. In the
program mode, you can either erase the on-board program or download a
new program.

EPB/SLK-51 User Manual

11

So to select the above mentioned option, a selector switch is provided.


You can press the switch to one position so that it selects the program
made. The release of the switch will again make the board into RUN
mode. Two LEDs are also provided to visually make sure that proper
selection of the option/mode is selected. The red LED will glow if the
program mode is selected and the green LED will glow if the RUN option
is selected. This visual indication makes it easy to confirm the mode
selection.
It is important to note that while changing the mode from
PROGRAM to RUN or vice versa, the power supply to the board
should be made OFF. The ON/OFF button provided on the power unit
can be used to ON/OFF the supply to the board. If this precaution is
not taken, it is likely to damage the chip.
General purpose Area:
The EPB/SLK-51 provides a general-purpose area for the user to practice
and interface number of components to the CPU. The EPB contains a
breadboard arrangement where the components can be inserted
temporarily and the interface can be studied. This arrangement is
generally suitable at an institute lab, where the components are to be
reused and a large number of users are supposed to try the interface. In
case of SLK-51, there exits a general purpose area where components
can be temporary placed or directly mounted. The general-purpose space
becomes very useful for the user doing some project around the SLK-51.
Looking to the card keeping the CPU on the topside, we see the following
picture.

EPB/SLK-51 User Manual

12

P3.7

P0.0

32 Port Lines
G
N
D

General Purpose Area

G
N
D

General Purpose Area

+
+5 V

General Purpose Area

5V

General Purpose Area


The
availability
of +5 volts and ground on to the general-purpose area makes the
interfacing more easy and simple. The breadboard has many strips.
The first block contains all the port line from P0.0 to P3.7. Remaining 4
block consists of general-purpose area. Ground and +5v are also
available. The arrangement hole is such that vertically the holes are short.
This makes the insertion of the component easy and more number of
components can be connected easily. Thus in the first block, 3 holes
vertically are shorted while in remaining block 4 holes are shorted
vertically.

EPB/SLK-51 User Manual

13

Expansion Slots:
Connecting other cards provided by Edutech Systems or any other third
party can further expand the EPB/SLK-51 card. The expansion slots have
got all the port-pins along with supply signal. These exist, two such slots
(JP1 and JP2) whose details are given below. JP1A and JP2A replicates
JP1 & JP2 for further use.
P O .0
P O .2
P O .4
P O .6
x
P 2 .1
P 2 .3
P 2 .5
P 2 .7
5V

P 1 .0
P 1 .2
P 1 .4
P 1 .6
x
P 3 .1
P 3 .3
P 3 .5
P 3 .7
+5V

1
3
5
7
9
11
13
15
17
19

2
4
6
8
1
1
1
1
1
2

1
3
5
7
9
11
13
15
17
19

2
4
6
8
1
1
1
1
1
2

JP1

0
2
4
6
8
0
JP2

0
2
4
6
8
0

1
3
5
7
9
11
13
15
17
19

2
4
6
8
1
1
1
1
1
2

1
3
5
7
9
11
13
15
17
19

2
4
6
8
1
1
1
1
1
2

0
2
4
6
8
0

0
2
4
6
8
0

P O .1
P O .3
P O .5
P O .7
P O .0
P 2 .2
P 2 .4
P 2 .6
ALE
GN D

P 1 .1
P 1 .3
P 1 .5
P 1 .7
P 3 .0
P 3 .2
P 3 .4
P 3 .6
X
GN D

We provide different cards like LCD/keyboard interface, 7segment/keyboard interfaces, E2PROM/RTC interface, ADC/DAC interface
etc. These different cards can be directly plugged with the EPB/SLK-51
and can be used to study and perform exercises using particular cards.
For more details you can contact us on info@edutechonline.com or visit
our site: www.edutechonline.com

Chapter 5
Virtual Programmer
EPB/SLK-51 User Manual

14

The EPB/SLK-51 has to be connected to the PC using the serial cable.


The program that is developed using the development tools is to be
downloaded to the board.
Since this board has the facility of in-system programming, we can
download or erase the program on board without using any programmer
device or even without removing the chip from the socket. This will avoid
the damage to the chip as well as it will be very easy to keep on
experiment without bothering about the programmer device.
To enable you to download the programs to the board, we provide a virtual
program utility (WINISP) bundled with the package. This utility is from
Philip and supports the onboard chip.
To start using the virtual program first you have to install the utility from the
CD provided with the pack. You can click the WINISP.exe to install the
program. Follow the instructions on the screen and complete the
installation. You can restart the computer if required. The program then
can be accessed from the start menu and program option you can even
create a shortcut on the desktop. Now let us see the virtual programmer
screen layout. The screen shows the layout of the WINISP utility.

EPB/SLK-51 User Manual

15

Chapter 6
Operating Steps
Instructions to use the
Educational Practice Board (EPB) / Self Learning Card (SLC)
The Educational Practice Board/ SLC is a general-purpose experiment
board designed to interface any relevant circuit and check the program
execution. This board is accompanied with different accessories like the
power unit, the programming cable and a CD-ROM. To use this board,
follow the following procedure:
1) From the CD provided, install the WINISP program to your computer.
This is a virtual programmer used to program the on-board CPU. You can
also use the Integrated Programming Tool (ITP) provided on the CD ROM
for accessing the virtual programmer utility. The CPU provided on the
board is having a unique In-System Programming facility so that you can
write and erase number of your test programs without removing the chip
from the circuit.
2) Now connect the board to the serial port of your PC using the
Programming cable provided.
3) From the Start option on your PC, run the WINISP program. You can
also use the IPT utility to execute the WINISP program. Select the proper
chip: 89C51RD2 from the chip select option. Select the communication
port and the crystal frequency (6 MHz in our case).
4) You will find a switch (Blue in color) called as the mode switch. This
switch when pressed enables the card in either (a) Run mode green
LED ON or (b) Program mode Red LED ON. To erase the memory, the
chip should be in the program mode and to execute the program, the chip
should be in the RUN mode.
Note that the power supply should be made OFF when the mode is
changed from RUN to PROGRAM or vice-versa.

EPB/SLK-51 User Manual

16

5) After selecting the PROGRAM option, on the board click on the Erase
Block option and select the first block sing the WINISP program.
Note: Do not select the Full Chip Erase option. Erase the selected block
by choosing the Erase block option. This will indicate the block erasure. If
there is any communication error, check the port connection and selection.
Switch the power supply OFF and then make it ON again and retry.
6) Now click on LOAD FILE & load the required hex file. Status
displays File loaded. This HEX file can be generated by using the
Assembler tool or the IDE provided with the package. Now click the
Program Part and wait till the status displays Programming Successful.
Caution: DO NOT TOUCH THE MISC BLOCK.
7) Now switch OFF the power & change the mode to execution mode
(green LED ON) by pressing the mode switch once. Now switch ON the
power supply and you can see the green LED ON. Also observe the
execution of the program.

EPB/SLK-51 User Manual

17

Chapter 7
Integrated Programming Tool
By this time, you must be conversant with the EPB/SLK-51 card. Now let
us try to understand how write a program, assemble it and transfer it to the
EPB/SLK-51.
There exists various tools like Assembler, Text editor, C-cross compiler,
Simulator/Debugger, Terminal software etc. which can be used to develop
8051 program on PC.
The CD enclosed in the package for EPB/SLK-51 consists of a utility - the
Integrated Programming Tool. This tool is an interface, which allows you to
write a program in note pad assemble the programs to generate .bin, .prn
and .hex files and further allows you to transfer the hex file to the EPB.
The utility is available on the CD (IPT folder). You have to copy this folder
to the windows directory of your systems. The ipt.exe file can be copied to
the folder of your choice or you can create a shortcut for easy access. The
IPT folder consists of different tools like notepad, winisp, assembler and
bin2hex converter utility. The assembler and the bin2hex converter utility
are DOS based utilities and hence it requires you to go to the DOS
prompt. T
The IPT-utility software allows the user to edit and assemble .asm
programs and than convert into HEX file on just one click!. This software is
developed to reduce the time needed to assemble the ASM program and
then converting that assembled program to HEX file. Generally, we have to
do this from DOS Prompt, since assembler and hex converters are DOS
based program. But using this software, you need not have to go to DOS
prompt every time you want to generate .bin and then .hex file from your
.asm files. For more details about the IPT, refer the help file provided with
the IPT.

EPB/SLK-51 User Manual

18

The IPT-Utility screen is shown below:

Writing the first program using the assembler utility:


EPB/SLK-51 User Manual

19

To start with, we will use the assembler provided with the pack to write our
first program.
In this case, we try to write a program to interface a simple LED to the port
pin P1.0 of the EPB/SLK-51. The LED is provided along with the package.
You can connect to the LED to the port pin P1.0 as shown.

Vc c

O N 8051
K IT

470
P 1 .0
R

LED

To momentary check the program, you can connect the LED to the port
directly. Now we write a program such that the LED connected to the port
pin P1.0 blinks continuous at the rate of 1 second.
Follow the following procedure to develop the first program.
1. Copy the IPT folder to windows directory and then run the ipt.exe file.
2. Give the program name and then type the following program in the
notepad window, which will be automatically invoked.

Program:
pin bit p1.0
EPB/SLK-51 User Manual

20

main:

org 0000h
sjmp main
org 0060h
clr pin
mov a,#4
acall delay
setb pin
mov a,#4
acall delay
sjmp main

delay:
again: mov r5,#250
sec: mov r7,#0a6h
onemil: nop
nop
nop
nop
djnz r7,onemil
djnz r5,sec
dec a
jnz again
ret
sjmp $
3. Click the respective buttons on the screen to generate the required
output. Once the hex file is generated, we transfer it to the EPB/SLK51 card. Select the program mode option (Red LED ON) and power on
the board. Using the WinISP button the virtual programmer is invoked.
Proper selection of chip, crystal frequency (6 MHz in our case),
communication port is made. The file generated is opened using the
menu. The block 0 is first erased and run the program is loaded into
the board using program port option. The screen indicates successful
completion of the task. If not recheck the cable connection, switch off
the EPB/SLK-51 power and resect the above procedure. Note that the
selection has to be in Program mode.

EPB/SLK-51 User Manual

21

4. Now switch off the power and change the mode to RUN mode and
make the power ON again. The Green LED should glow.
5. Observe the LED. It should be blinking so that, if you can now try more
exercises and use the EPB/SLK-51 to learn more programming
concepts, interface number of component and finally carry out your
project work using the EPB/SLC.
Note: If you are using the IDE tool, type the program in the editor & then
save it as .asm file. From the compile menu, select Assembler a file
option. This will generate a hex file, which can be further downloaded in
the EPB/SLK-51.
If you have any difficulty, please contact us.
You can write number of programs using the Educational Practice Board
and interfaced number of interface devices using the general-purpose
board. You can also refer to the Curriculum Workbook for more practice
examples.
Also the EPB/SLK-51 is an embedded study kit with number of embedded
routines for interfacing different components like the LCD, keyboard, ADC,
Serial EEPROM, RTC etc. You can use these embedded routines to
develop project based application or some real time applications using the
EPB. These routines will enable you to develop applications and
appreciate the strength of Microcontroller.
These routines can also be best used for testing the hardware developed
by you. You can interface the interface hardware to the EPB and write the
program using the embedded routines and assure that the hardware
developed by you is working properly.
Let us try to understand the embedded routines and see how to write the
interface related programs using these routines. Note that you have to
define the hardware port pin allocation in the program itself as the
embedded routines are generalized routines. Thus you can use these
routines to test and develop programs for your own hardware.
Following chapter discusses more on these embedded routines and
demonstrates some interface program examples. You can refer the
curriculum workbooks for more practice examples or write to us at
info@edutechonline.com for any assistance needed for developing your
project-based applications using the embedded routines.

EPB/SLK-51 User Manual

22

Chapter 8
Embedded Driver Routines
Introduction
The Educational Practice Board/SLK-51 optionally contains embedded
driver routines. These routines can be used to study different concepts of
8051 programming. They can also be used to directly interface devices
like LCD and Keyboard etc.
The EPB/SLK-51 has a 64KB of on-chip flash memory. These drivers are
embedded into the chip memory. Thus part of the flash memory is used in
embedding these drivers. As a result, the first 32KB of flash program
memory can be used for writing your programs.
You have to note that the last 32KB of program memory should not be
erased. This memory space contains the driver routines as well as the
serial-communication routines need to upload or download the programs
from the PC. Erasing the last 32KB of memory content will result in the
erasure of the embedded programs and the chip will function as normal
89C51 chip. You then will require external programmer since the WINISP
will not communicate with the chip.
To be more precise, the last 32KB of space is divided into two parts of
16KB each (last two memory blocks as seen from the WINISP). The first
16KB i.e. the 3rd block contains the drivers and the last block contains the
communication routines. If the 3rd block is erased, the driver routines will
be lost. You can still use this space to save your programs.
Thus, its better to avoid using/erasing the last 32KB of memory space.

EPB/SLK-51 User Manual

23

Memory map:
0
8K
16K

32K

48K

64K

Description of Embedded Drivers:


The Embedded Driver routines on the chip can be referred using their
direct address. To simplify the addressing of these routines, the locations
are mapped to some variable names. These names can be directly
mentioned in the programs. To make the programming still simpler,
separate header files are provided which can be included in the main
program.
The first header file is location.h. This file is to be included in the main
program. It defines the location of various embedded drivers incorporated
in the chip. With this feature you can access the driver routine using a
specific name instead of numeric value of the location. There are two
advantages of using this header file. Firstly you need not remember the
numeric locations while using the embedded routines and secondly in
case of upgradation of these embedded routines, your main programs
need not to be modified.

EPB/SLK-51 User Manual

24

The second header file is the embedded.h defines the hardware


interface in terms of pin allocation w.r.t different components. The
Embedded Driver routines are so designed that you can define your own
pin assignments for interfacing different components.
The Embedded.h file links the embedded routines and the pin
assignments. You have to mention the allocation of port pins in the main
program written by you. Thus you must include this header file when you
use the embedded driver features while interfacing the components.
The following lines describe how to use the header files for writing a
application program.
MOV R0, # Variable ; Variable name as per the embedded.h definition.
MOV @R0, #Port/Port-pin ; connected port/port-pin
Let us understand the use of header files with some example:
Suppose we interface a LCD to microcontroller such that 8 data lines of
LCD are connected to say port 0. The controls lines like LCD enable EN
pin is connected to port pin P1.0 and the LCD register select RS pin is
connected to port pin P1.1. The declaration of the above assignment is as
follows:
MOV R0, #lcd8d ; Variable for LCD Data Lines as per embedded.h
MOV @R0, #00h ; 00h defines port - 0
MOV R0, #lcd8en ; Variable for LCD Enable Line as per embedded.h
MOV @R0, #10h ; 10h defines port pin P1.0
MOV R0, #lcd8rs; Variable for LCD Register Select Line as per
;embedded.h
MOV @R0, #11h ; 11h defines port pin P1.1
The following table enlists different drivers embedded into the chip. The
table consists of Component/Function name, description of the embedded
routine, variable name used in location.h file and program location.
With the help of these standard routines, it becomes easy to interface
number of devices like LCD, keyboard, ADCs, RTC, EEPROM etc as per
your own pin assignments and develop an application around it.

EPB/SLK-51 User Manual

25

Table1:
Component / Function

Description Of Embedded
Routine

Variable Used

Program
Location

Delay

Delay in millisecond

delay_ms

80ffh

LCD
(4 bit data bus)

LCD Initialization
LCD command
LCD data

lcd4_init
lcd4_cmd
lcd4_dat

812ch
81b0h
8217h

LCD
(8 bit data bus)

LCD Initialization
LCD command
LCD data

lcd8_init
lcd8_cmd
lcd8_dat0

8289h
82eeh
8334h

Matrix Keyboard (5x5)

Key detect

keybrd_5

837ah

Matrix Keyboard (4x4)

Key detect

keybrd_4

846bh

Matrix Keyboard (3x3)

Key detect

keybrd_3

853fh

Matrix Keyboard (2x2)

Key detect

keybrd_2

85feh

7 segment

7 segment initialization
7 segment interrupt

seg_init
seg_int

86b9h
86e9h

RTC (connected at p3.6


& p3.7)

RTC write
RTC read

rtc_write
rtc_read

87a0h
8727h

EEPROM (connected at
p3.6 & p3.7)

EEPROM write
EEPROM read

write_srom
read_srom

8669h
88b0h

Parallel ADC (8 bit)

ADC read

adc_read

8980h

Serial ADC (connected


at p3.6 & p3.7)

Serial ADC read

ssadc_read

8a3bh

EPB/SLK-51 User Manual

26

Component /
Function
Graphic LCD

Printer
Counter
Serial
Communication
(Mode 1)
Serial
Communication
(Mode 2)
Serial ADC
(connected at p0.1
& p0.2)
EEPROM
(connected at p0.6
& p0.7)

Description Of Embedded
Routine
Graphic LCD initialization
Graphic LCD display on
Graphic LCD display off
Graphic LCD start line (cs1)
Graphic LCD start line (cs2)
Graphic LCD page (cs1)
Graphic LCD y-Address (cs1)
Graphic LCD page (cs2)
Graphic LCD y-address (cs2)
Graphic LCD Data (cs1)
Graphic LCD Data (cs2)
Graphic LCD clear screen (cs1)
Graphic LCD clear screen (cs2)

glcd_init
glcd_dispon
glcd_dispoff
glcd_srtlin1
glcd_srtlin2
glcd_page1
glcd_yadd1
glcd_page2
glcd_yadd2
glcd_send1
glcd_send2
glcd_clr1
glcd_clr2

Program
Location
8a7ah
8ae6h
8b43h
8ba0h
8beah
8c34h
8c7eh
8cc8h
8d12h
8d5ch
8da0h
95f5h
9629h

Printer initialization
Print character
Counter initialization
Serial communication initialization
Transmit character
Receive character
Serial communication initialization
Transmit character
Receive character
Serial ADC read

pri_init
print
counter
ser1_init
transmit1
receive1
ser2_init
transmit2
receive2
sadc_read

8e8fh
8eaah
8ee1h
8f08h
8f19h
8f23h
8f2eh
8f3fh
8f42h
949fh

EEPROM write
EEPROM read

write_rom
read_rom

94deh
9525h

EPB/SLK-51 User Manual

27

Variable Used

The following table enlists the register or location that must be used to
pass / receive the parameter in order to access the embedded drive
routine. Further note that we should not use the particular associated
location in your main program elsewhere.
Table2:
Component / Function
LCD

Related Register /
Location
70h

Command / Data write

Keyboard (All types)

71h

Returns key code

7 Segment

60h
61h
62h
63h
64h
65h
66h
67h

Data for Digit 1


Data for Digit 2
Data for Digit 3
Data for Digit 4
Data for Digit 5
Data for Digit 6
Data for Digit 7
Data for Digit 8

RTC

68h
69h
6ah
6bh
6ch
6dh
6eh

Second (write/read)
Minute (write/read)
Hour (write/read)
Day (write/read)
Date (write/read)
Month(write/read)
Year (write/read)

EEPROM
(All types)

7bh
7ch
7dh
7eh

Data 1
Data 2
Data 3
Data 4

Parallel ADC

79h
7ah

Channel selection
Data (read)

Serial ADC
(All types)

5eh
5fh

Data(lower byte)
Data(higher byte)

EPB/SLK-51 User Manual

28

Parameter

Component / Function

Related Register /
Location
72h
73h
74h
75h
76h
77h
78h

Data (CS1/CS2)
Startline (CS1)
Page (CS1)
Y-address (CS1)
Startline (CS2)
Page (CS2)
Y-address (CS2)

Printer

6fh

Data (write)

Counter

5ch
5dh
5bh

Lower byte
Higher byte
Transmit/Receive

Graphic LCD

Serial Communication
(All types)

Parameter

The following table enlists the variable name that must be used to defined
the port or port pin at which the desired component is required to be
connected. Reference to the programs given in Project Essentials
workbook will make it clear how to use these variable names.

EPB/SLK-51 User Manual

29

Table3:
Component

Variable
Used
Lcd4d
Lcd4en
Lcd4rs

lcd4 data(port) first four pins will get configured


lcd4 enable(port pin)
lcd4 register select(port pin)

LCD
(8 bit data bus)

Lcd8d
Lcd8en
Lcd8rs

lcd8 data(port)
lcd8 enable(port pin)
lcd8 register select(port pin)

Matrix Keyboard
(5x5)

kbrd5c1
kbrd5c2
kbrd5c3
kbrd5c4
kbrd5c5
kbrd5r1
kbrd5r2
kbrd5r3
kbrd5r4
kbrd5r5

keyboard column 1(port pin)


keyboard column 2(port pin)
keyboard column 3(port pin)
keyboard column 4(port pin)
keyboard column 5(port pin)
keyboard row 1(port pin)
keyboard row 2(port pin)
keyboard row 3(port pin)
keyboard row 4(port pin)
keyboard row 5(port pin)

Matrix Keyboard
(4x4)

kbrd4c1
kbrd4c2
kbrd4c3
kbrd4c4
kbrd4r1
kbrd4r2
kbrd4r3
kbrd4r4

keyboard column 1(port pin)


keyboard column 2(port pin)
keyboard column 3(port pin)
keyboard column 4(port pin)
keyboard row 1(port pin)
keyboard row 2(port pin)
keyboard row 3(port pin)
keyboard row 4(port pin)

LCD
(4 bit data bus)

EPB/SLK-51 User Manual

Description

30

Component

Variable
Used

Description

kbrd3c1
kbrd3c2
kbrd3c3
kbrd3r1
kbrd3r2
kbrd3r3

keyboard column 1(port pin)


keyboard column 2(port pin)
keyboard column 3(port pin)
keyboard row 1(port pin)
keyboard row 2(port pin)
keyboard row 3(port pin)

Matrix Keyboard
(2x2)

kbrd2c1
kbrd2c2
kbrd2r1
kbrd2r2

keyboard column 1(port pin)


keyboard column 2(port pin)
keyboard row 1(port pin)
keyboard row 2(port pin)

7 segment

segdat
seldig

7 segment data
Selects Digit in which data is to be displayed(port)

Parallel ADC (8 bit)

padcadr
padcsoc
padceoc
padcale
padcdat

ADC address line(port) first three pins will get configured


ADC start of conversion line(port pin)
ADC end of conversion line(port pin)
ADC ALE line(port pin)
ADC data(port)

Graphic LCD

Glcddat
Glcddi
glcden
glcdcs1
glcdcs2
glcdrst
glcdrw

Graphic lcd data(port)


Graphic lcd D/I(port pin)
Graphic lcd enable pin(port pin)
Graphic lcd cs1 pin(port pin)
Graphic lcd cs2 pin(port pin)
Graphic lcd rst pin(port pin)
Graphic lcd rw pin(port pin)

Printer

prdat
pbusy
pinit
pstrob

Printer data(port)
Printer busy(port pin)
Printer initialization(port pin)
Printer strobe(port pin)

Matrix Keyboard
(3x3)

EPB/SLK-51 User Manual

31

The following is the listing of the header files that is required during the
assembly of the program. You may refer to the 'Project Essentials'
workbook where more than 100 program examples are discussed
demonstrating the usage of the embedded driver routines. We are sure
that the reference of the Project Essentials workbook you will acquaint
yourself with the strength of the embedded routine and start developing
practical applications.
HEADER FILES:
Location.h:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DELAY
delay_ms

equ

80ffh

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LCD4
lcd4_init
lcd4_cmd
lcd4_dat

equ
equ
equ

812ch
81b0h
8217h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LCD8
lcd8_init
lcd8_cmd
lcd8_dat
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

equ
8289h
equ
82eeh
equ
8334h
KEYBOARD 5*5

keybrd_5

equ

837ah

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; KEYBOARD 4*4


keybrd_4

equ

846bh

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; KEYBOARD 3*3


keybrd_3

equ

853fh

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; KEYBOARD 2*2


keybrd_2

equ

EPB/SLK-51 User Manual

85feh

32

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 7-SEGMENT
seg_init
seg_int

equ
equ

86b9h
86e9h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RTC
rtc_write
rtc_read
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
write_srom
read_srom

equ
equ

87a0h
8727h

EEPROM SAME LINE


equ
equ

8669h
88b0h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; P_ADC
adc_read

equ

8980h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; S_ADC SAME LINE


ssadc_read

equ

8a3bh

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GRAPHIC LCD


glcd_init
glcd_dispon
glcd_dispoff
glcd_srtlin1
glcd_srtlin2
glcd_page1
glcd_yadd1
glcd_page2
glcd_yadd2
glcd_send1
glcd_send2
glcd_clr1
glcd_clr2

equ
equ
equ
equ
equ
equ
equ
equ
equ
equ
equ
equ
equ

EPB/SLK-51 User Manual

8a7ah
8ae6h
8b43h
8ba0h
8beah
8c34h
8c7eh
8cc8h
8d12h
8d5ch
8da0h
95f5h
9629h

33

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PRINTER
pri_init
print

equ
equ

8e8fh
8eaah

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; COUNTER
counter

equ

8ee1h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SERIAL TRANSMISSION MODE1


ser1_init
transmit1
receive1

equ
equ
equ

8F08h
8F19h
8F23h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SERIAL TRANSMISSION MODE2


ser2_init
transmit2
receive2

equ
equ
equ

8F2Eh
8F3Fh
8F42h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; S_ADC
sadc_read
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
write_rom
read_rom

equ

949fh

EEPROM
equ
equ

EPB/SLK-51 User Manual

94deh
9525h

34

Embedded.h:
;;;;;;;;;;;;;;;;;;;LCD 4 bit;;;;;;;;;;;;;;;;;
lcd4d
lcd4en
lcd4rs

equ a0h
equ a1h
equ a2h

;lcd4 data(port) first four pins will get configured


;lcd4 enable(port pin)
;lcd4 register select(port pin)

;;;;;;;;;;;;;;;;;;;LCD 8 bit;;;;;;;;;;;;;;;;;
lcd8d
lcd8en
lcd8rs

equ a3h
equ a4h
equ a5h

;lcd8 data(port)
;lcd8 enable(port pin)
;lcd8 register select(port pin)

;;;;;;;;;;;;;;;;;;;Keyboard 5x5;;;;;;;;;;;;;;;;;
kbrd5c1
kbrd5c2
kbrd5c3
kbrd5c4
kbrd5c5
kbrd5r1
kbrd5r2
kbrd5r3
kbrd5r4
kbrd5r5

equ a6h
equ a7h
equ a8h
equ a9h
equ aah
equ abh
equ ach
equ adh
equ aeh
equ afh

;keyboard column 1(port pin)


;keyboard column 2(port pin)
;keyboard column 3(port pin)
;keyboard column 4(port pin)
;keyboard column 5(port pin)
;keyboard row 1(port pin)
;keyboard row 2(port pin)
;keyboard row 3(port pin)
;keyboard row 4(port pin)
;keyboard row 5(port pin)

;;;;;;;;;;;;;;;;;;;Keyboard 4x4;;;;;;;;;;;;;;;;;
kbrd4c1
kbrd4c2
kbrd4c3
kbrd4c4
kbrd4r1
kbrd4r2
kbrd4r3
kbrd4r4

equ b0h
equ b1h
equ b2h
equ b3h
equ b4h
equ b5h
equ b6h
equ b7h

EPB/SLK-51 User Manual

;keyboard column 1(port pin)


;keyboard column 2(port pin)
;keyboard column 3(port pin)
;keyboard column 4(port pin)
;keyboard row 1(port pin)
;keyboard row 2(port pin)
;keyboard row 3(port pin)
;keyboard row 4(port pin)

35

;;;;;;;;;;;;;;;;;;;Keyboard 3x3;;;;;;;;;;;;;;;;;
kbrd3c1
kbrd3c2
kbrd3c3
kbrd3r1
kbrd3r2
kbrd3r3

equ b8h
equ b9h
equ bah
equ bbh
equ bch
equ bdh

;keyboard column 1(port pin)


;keyboard column 2(port pin)
;keyboard column 3(port pin)
;keyboard row 1(port pin)
;keyboard row 2(port pin)
;keyboard row 3(port pin)

;;;;;;;;;;;;;;;;;;;Keyboard 2x2;;;;;;;;;;;;;;;;;
kbrd2c1
kbrd2c2
kbrd2r1
kbrd2r2

equ beh
equ bfh
equ c0h
equ c1h

;keyboard column 1(port pin)


;keyboard column 2(port pin)
;keyboard row 1(port pin)
;keyboard row 2(port pin)

;;;;;;;;;;;;;;;;;;;7segment;;;;;;;;;;;;;;;;;
segdat
seldig

equ c2h
equ c3h

;7 segment data
;Selects Digit in which data is to be
;displayed(port)

;;;;;;;;;;;;;;;;;;;ADC 8-bit;;;;;;;;;;;;;;;;;
padcadr

equ c4h

padcsoc
padceoc
padcale
padcdat

equ c5h
equ c6h
equ c7h
equ c8h

;ADC address line(port) first three pins


;will get configured
;ADC start of conversion line(port pin)
;ADC end of conversion line(port pin)
;ADC ALE line(port pin)
;ADC data(port)

;;;;;;;;;;;;;;;;;;;Graphic LCD;;;;;;;;;;;;;;;;;
glcddat
glcddi
glcden
glcdcs1
glcdcs2
glcdrst
glcdrw

equ c9h
equ cah
equ cbh
equ cch
equ cdh
equ ceh
equ cfh

EPB/SLK-51 User Manual

;Graphic lcd data(port)


;Graphic lcd D/I(port pin)
;Graphic lcd enable pin(port pin)
;Graphic lcd cs1 pin(port pin)
;Graphic lcd cs2 pin(port pin)
;Graphic lcd rst pin(port pin)
;Graphic lcd rw pin(port pin)

36

;;;;;;;;;;;;;;;;;;;Printer;;;;;;;;;;;;;;;;;
prdat
pbusy
pinit
pstrob

equ d0h
equ d1h
equ d2h
equ d3h

;Printer data(port)
;Printer busy(port pin)
;Printer initialization(port pin)
;Printer strobe(port pin)

;;;;;;;;;;;;;;;;;;;I2C RTC;;;;;;;;;;;;;;;;;
irtcdat
irtcscl

equ d4h
equ d5h

;i2c RTC data(port pin)


;i2c RTC clock(port pin)

;;;;;;;;;;;;;;;;;;;I2C ADC;;;;;;;;;;;;;;;;;
iadcadr

equ d6h

iadcdat
iadcscl

equ d7h
equ d8h

;i2c ADC address line(port) first three


;pins must be configured
;i2c ADC data(port pin)
;i2c ADC clock(port pin)

Chapter 9
EPB/SLK-51 User Manual

37

Embedded Driver Description & Example Programs


1. Delay:
This driver routine is a general-purpose routine to generate delay. This
routine is embedded into the memory to enable the easy use of delay
routine. The delay routine is many times required to interface the devices
and develop an application. The user can thus call the delay routine and
pass appropriate parameter to the routine. Depending on the delay
requirement, the parameter value can be decided. This value can be 16-bit
value from 0000h to FFFFH. The lower byte is to be stored in the
accumulator and the higher byte in the B register. The delay routine
embedded in the chip is for generating a basic delay of 1 milli second.
Depending on the count parameter, you can thus get a delay from 1 ms
(for 0001H count) to 65.535 seconds (FFFFH)
Program location: 80ffh
Location name:
delay_ms
Count parameter location: Lower byte in Accumulator and higher byte
in B register.
2. The LCD driver for 4 Bit Interface:
The LCD embedded driver consists of three subroutines: (i) LCD
initialization, (ii) LCD command and (iii) LCD data. These routines are to
be called from the main program by using the appropriate variable name.
The details of these routines are as follows:
The LCD Initialization Routine:
This routine can be used to initialize the LCD connected at port as defined
by the user.
Program location:
Location name:

812ch
lcd4_init

The LCD Command routine:


This routine can be used to send different commands to the LCD such as
position of the cursor, shift cursor/screen, font size, etc.
Program location: 81b0h
Location name:
lcd4_cmd
Command parameter location: 70h

EPB/SLK-51 User Manual

38

LCD data routine:


This routine passes the data that is to be displayed on the LCD module.
Program location: 8217h
Location name:
lcd4_dat
Data parameter location: 70h
Let us make clear how to use these routines by considering following
program.
Suppose LCD is connected in 4-bit interface mode as per the following
connections.
8051 Port Pins
P2.0
P2.1
P2.2
P2.3
P2.4
P2.5

LCD Module (16 X 2)


D4 LCD Data Pin
D5 LCD Data Pin
D6 LCD Data Pin
D7 LCD Data Pin
EN Enable LCD
RS Register Select

The following must be incorporated in your program to make the above


connections working:
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h

EPB/SLK-51 User Manual

39

Now let us write a program to display 'A' on default position:


Test Program:
include embedded.h
include location.h
org 00h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
lcall lcd4_init
mov 70h,#'A'
lcall lcd4_dat
sjmp $

;LCD initialization routine


;31h is LCD data location
;LCD data display routine

3. The LCD driver for 8 Bit Interface:


This LCD embedded driver is meant for 8-bit data bus interface. As
mentioned above it also consists of three subroutines: (i) LCD initialization,
(ii) LCD command and (iii) LCD data. These routines are to be called from
the main program by using the appropriate variable name. The details of
these routines are as follows:
The LCD Initialization Routine:
This routine can be used to initialize the LCD connected at port as defined
by the user.
Program location:
Location name:

EPB/SLK-51 User Manual

8289h
lcd8_init

40

The LCD Command routine:


This routine can be used to send different commands to the LCD such as
position of the cursor, shift cursor/screen, font size, etc.
Program location: 82eeh
Location name: lcd8_cmd
Command parameter location: 70h
LCD data routine:
This routine passes the data that is to be displayed on the LCD module.
Program location: 8334h
Location name: lcd8_dat
Data parameter location: 70h
Let us make clear how to use these routines by considering following
program.
Suppose LCD is connected in 8-bit interface mode as per the following
connections.
8051 Port Pins
P0
P2.1
P2.0
P2.6

LCD Module (16 X 2)


LCD Data Pin
EN Enable LCD
RS Register Select
RD/WR Read/Write Pin

The following must be incorporated in your program to make the above


connections working:
clr p2.6

;make RD/WR pin of LCD low to


make ;LCD write enable

mov r0, #lcd8d


mov @r0, #00h
mov r0, #lcd8en
mov @r0, #21h
mov r0, #lcd8rs
mov @r0, #20h

EPB/SLK-51 User Manual

41

Now let us write a program to display 'VARUN' at centre position:


Test Program:
include embedded.h
include location.h
org 00h
mov sp, #7fh
clr p2.6

;make RD/WR pin of LCD low to


make ;LCD write enable

mov r0, #lcd8d


mov @r0, #00h
mov r0, #lcd8en
mov @r0, #21h
mov r0, #lcd8rs
mov @r0, #20h
lcall lcd8_init
mov 70h, #85h
lcall lcd8_cmd
mov 70h, #'V'
lcall lcd8_dat
mov 70h, #'A'
lcall lcd8_dat
mov 70h, #'R'
lcall lcd8_dat
mov 70h, #'U'
lcall lcd8_dat
mov 70h, #'N'
lcall lcd8_dat
sjmp $

EPB/SLK-51 User Manual

;LCD initialization for 8-bit mode


;LCD command for 8-bit mode
;LCD data for 8-bit mode

42

4. The 5 x 5 Matrix Keyboard driver:


This routine is meant to detect the pressed key. The main routine checks if
the flag bit 2f.7h is high. In the embedded routine the flag bit 2f.7h is made
high if a valid key is pressed. If you are using loop means you want to
consecutively check the pressed key, make sure that flag 2f.7h is cleared
before entering in to the loop. If you want to check the pressed key only
once, no need to clear the flag 2f.7h. After the key pressed, the key code
is available at RAM location 71h. Here key code means row/column
combination is moved to 71h.
For eg.
If you press F1 key then 22h is moved to 71h,here 22h means 2 nd
row and 2nd column.
Program location: 837ah
Location name: keybrd_5
Key code location: 71h
Let us make clear how to use this routine by considering following
program.
Suppose 5 x 5 matrix keyboard is connected as per the following
connections.
8051 Port Pins
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
P3.6
P3.7

5 X 5 Matrix Keyboard
Column1 of Keyboard
Column2 of Keyboard
Column3 of Keyboard
Column4 of Keyboard
Column5 of Keyboard
Row 1 of Keyboard
Row 2 of Keyboard
Row 3 of Keyboard
Row 4of Keyboard
Row 5 of keyboard

The following must be incorporated in your program to make the above


connections working:
EPB/SLK-51 User Manual

43

mov r0, #kbrd5c1


mov @r0, #10h
mov r0, #kbrd5c2
mov @r0, #11h
mov r0, #kbrd5c3
mov @r0, #12h
mov r0, #kbrd5c4
mov @r0, #13h
mov r0, #kbrd5c5
mov @r0, #14h
mov r0, #kbrd5r1
mov @r0, #15h
mov r0, #kbrd5r2
mov @r0, #16h
mov r0, #kbrd5r3
mov @r0, #17h
mov r0, #kbrd5r4
mov @r0, #36h
mov r0, #kbrd5r5
mov @r0, #37h
Let us write a program to display keycode of pressed key
Test Program:
include embedded.h
include location.h
org 0
mov sp,#7fh
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h

EPB/SLK-51 User Manual

44

mov r0, #kbrd5c1


mov @r0, #10h
mov r0, #kbrd5c2
mov @r0, #11h
mov r0, #kbrd5c3
mov @r0, #12h
mov r0, #kbrd5c4
mov @r0, #13h
mov r0, #kbrd5c5
mov @r0, #14h
mov r0, #kbrd5r1
mov @r0, #15h
mov r0, #kbrd5r2
mov @r0, #16h
mov r0, #kbrd5r3
mov @r0, #17h
mov r0, #kbrd5r4
mov @r0, #36h
mov r0, #kbrd5r5
mov @r0, #37h
lcall lcd4_init
again: mov 70h,#80h
lcall lcd4_cmd

;LCD initialization routine


;lcd cmd

mov 70h,#'K'
lcall lcd4_dat
mov 70h,#'e'
lcall lcd4_dat
mov 70h,#'y'
lcall lcd4_dat
mov 70h,#'='
lcall lcd4_dat
wait: lcall keybrd_5
jb 2fh.7, kb
sjmp wait

kb:

mov a,71h

EPB/SLK-51 User Manual

45

anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat
mov a,71h
anl a,#0fh
add a,#30h
mov 70h,a
lcall lcd4_dat
ljmp again
5. The 4 x 4 Matrix Keyboard driver:
This routine is for 4 x 4 matrix keyboard. All the concepts similar to that of
5 x 5 matrix keyboard driver routine. Here also flag 2f.7h becomes high
when a key is pressed. After the key pressed, the key code is available at
RAM location 71h.
Program location: 846bh
Location name:
keybrd_4
Key code location: 71h
Let us make clear how to use this routine by considering following
program.
Suppose 4 x 4 matrix keyboard is connected as per the following
connections.
8051 Port Pins
P0.0
P0.1
P0.2
P0.3
P0.5
P0.6
P0.7
P2.6

EPB/SLK-51 User Manual

4 X 4 Matrix Keyboard
Column1 of Keyboard
Column2 of Keyboard
Column3 of Keyboard
Column4 of Keyboard
Row 1 of Keyboard
Row 2 of Keyboard
Row 3 of Keyboard
Row 4 of Keyboard

46

The following must be incorporated in your program to make the above


connections working:
mov r0, #kbrd4c1
mov @r0, #00h
mov r0, #kbrd4c2
mov @r0, #01h
mov r0, #kbrd4c3
mov @r0, #02h
mov r0, #kbrd4c4
mov @r0, #03h
mov r0, #kbrd4r1
mov @r0, #05h
mov r0, #kbrd4r2
mov @r0, #06h
mov r0, #kbrd4r3
mov @r0, #07h
mov r0, #kbrd4r4
mov @r0, #26h

;p0.0
;p0.1
;p0.2
;p0.3
;p0.5
;p0.6
;p0.7
;p2.6

Let us write a program to display keycode of pressed key


Test Program:
include embedded.h
include location.h
org 00h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h

EPB/SLK-51 User Manual

47

mov r0, #kbrd4c1


mov @r0, #00h
mov r0, #kbrd4c2
mov @r0, #01h
mov r0, #kbrd4c3
mov @r0, #02h
mov r0, #kbrd4c4
mov @r0, #03h
mov r0, #kbrd4r1
mov @r0, #05h
mov r0, #kbrd4r2
mov @r0, #06h
mov r0, #kbrd4r3
mov @r0, #07h
mov r0, #kbrd4r4
mov @r0, #26h

;p0.0
;p0.1
;p0.2
;p0.3
;p0.5
;p0.6
;p0.7
;p2.6

lcall lcd4_init
agn:
lcall keybrd_4
jb 2fh.7,ok
sjmp agn
ok:

mov 70h,#01h
lcall lcd4_cmd
mov a,71h
anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat ;lcd dat
mov a,71h
anl a,#0fh
add a,#30h
mov 70h,a
lcall lcd4_dat
sjmp agn

EPB/SLK-51 User Manual

;lcd cmd

48

6. The 3 x 3 Matrix Keyboard driver:


This routine is for 3 x 3 matrix keyboard. All the concepts similar to that of
5 x 5 matrix keyboard driver routine. Here also flag 2f.7h becomes high
when a key is pressed. After the key pressed, the key code is available at
RAM location 71h.
Program location: 853fh
Location name:
keybrd_3
Key code location: 71h
Let us make clear how to use this routine by considering following
program.
Suppose 3 x 3 matrix keyboard is connected as per the following
connections.
8051 Port Pins
P0.0
P0.1
P0.2
P0.5
P0.6
P0.7

3 X 3 Matrix Keyboard
Column1 of Keyboard
Column2 of Keyboard
Column3 of Keyboard
Row 1 of Keyboard
Row 2 of Keyboard
Row 3 of Keyboard

The following must be incorporated in your program to make the above


connections working:
mov r0, #kbrd3c1
mov @r0, #00h
mov r0, #kbrd3c2
mov @r0, #01h
mov r0, #kbrd3c3
mov @r0, #02h
mov r0, #kbrd3r1
mov @r0, #05h
mov r0, #kbrd3r2
mov @r0, #06h
mov r0, #kbrd3r3
mov @r0, #07h

;p0.0
;p0.1
;p0.2
;p0.5
;p0.6
;p0.7

Let us write a program to display key code of pressed key

Test Program:
EPB/SLK-51 User Manual

49

include embedded.h
include location.h
org 00h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
mov r0, #kbrd3c1
mov @r0, #00h
mov r0, #kbrd3c2
mov @r0, #01h
mov r0, #kbrd3c3
mov @r0, #02h
mov r0, #kbrd3r1
mov @r0, #05h
mov r0, #kbrd3r2
mov @r0, #06h
mov r0, #kbrd3r3
mov @r0, #07h

;p0.0
;p0.1
;p0.2
;p0.5
;p0.6
;p0.7

lcall lcd4_init
agn:
lcall keybrd_3
jb 2fh.7,ok
sjmp agn
ok:

mov 70h,#01h
lcall lcd4_cmd
;lcd cmd
mov a,71h
anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat ;lcd dat
mov a,71h
anl a,#0fh

EPB/SLK-51 User Manual

50

add a,#30h
mov 70h,a
lcall lcd4_dat
sjmp agn
7. The 2 x 2 Matrix Keyboard driver:
This routine is for 2 x 2 matrix keyboard. All the concepts similar to that of
5 x 5 matrix keyboard driver routine. Here also flag 2f.7h becomes high
when a key is pressed. After the key pressed, the key code is available at
RAM location 71h.
Program location: 85feh
Location name: keybrd_2
Key code location: 71h
Let us make clear how to use this routine by considering following
program.
Suppose 2 x 2 matrix keyboard is connected as per the following
connections.

8051 Port Pins


P0.0
P0.1
P0.5
P0.6

2 X 2 Matrix Keyboard
Column1 of Keyboard
Column2 of Keyboard
Row 1 of Keyboard
Row 2 of Keyboard

The following must be incorporated in your program to make the above


connections working:
mov r0, #kbrd2c1
mov @r0, #00h
mov r0, #kbrd2c2
mov @r0, #01h
mov r0, #kbrd2r1
mov @r0, #05h
mov r0, #kbrd2r2
mov @r0, #06h

;p0.0
;p0.1
;p0.5
;p0.6

Let us write a program to display key code of pressed key


Test Program:
EPB/SLK-51 User Manual

51

include embedded.h
include location.h
org 00h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
mov r0, #kbrd2c1
mov @r0, #00h
mov r0, #kbrd2c2
mov @r0, #01h
mov r0, #kbrd2r1
mov @r0, #05h
mov r0, #kbrd2r2
mov @r0, #06h

;p0.0
;p0.1
;p0.5
;p0.6

lcall lcd4_init
agn:
lcall keybrd_2
jb 2fh.7,ok
sjmp agn
ok:

mov 70h,#01h
lcall lcd4_cmd
;lcd cmd
mov a,71h
anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat ;lcd dat
mov a,71h
anl a,#0fh
add a,#30h
mov 70h,a
lcall lcd4_dat
sjmp agn
8. The 7-segment LED Interface Driver:
EPB/SLK-51 User Manual

52

This routine can be used to interface the 7-segment LED to the controller.
Here there are two routines viz. the segment initialization routine and the
interrupt routine for refreshing the 7-segment LEDs. The Timer 0 is used to
generate the interrupt. Hence whenever the interrupt is generated, the
refreshing action takes place. This can be written as:
org 000bh
ljmp seg_int
reti
Program location for initialization:
Location name for initialization:
Program location for interrupt:
Location name for interrupt routine:
Location for data in respective digit:

86b9h
seg_init
86e9h
seg_int
60h, 61h, 62h, 63h, 64h, 65h,
66h, 67h

Let us make clear how to use this routine by considering following


program.
Suppose four 7-segment LEDs are connected as per the following
connections.
8051 Port Pins
P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
P3.0
P3.1
P3.2
P3.3

4 nos. of 7-segment LED


Segment a
Segment b
Segment c
Segment d
Segment e
Segment f
Segment g
Segment dp
Digit 1
Digit 2
Digit 3
Digit 4

The following must be incorporated in your program to make the above


connections working:
mov r0, #segdat
mov @r0, #00h
mov r0, #seldig
mov @r0, #03h

EPB/SLK-51 User Manual

53

Now let us write a program to display 0123 in the four segments


respectively.
Test Program:
include embedded.h
include location.h
org 0000h
ljmp main
org 000bh
lcall seg_int
reti
main:

mov sp, #7fh


mov r0, #segdat
mov @r0, #00h
mov r0, #seldig
mov @r0, #03h
lcall seg_init

;interrupt routine

;segment initialization routine

mov 60h,#3fh
lcall delay
mov 61h,#06h
lcall delay
mov 62h,#5bh
lcall delay
mov 63h,#4fh
sjmp $
;delay routine

delay:
EPB/SLK-51 User Manual

54

d3:
d2:
d1:

push 03h
push 06h
push 07h
mov r3,#9
mov r6,#0ffh
mov r7,#0ffh
nop
djnz r7,d1
djnz r6,d2
djnz r3,d3
pop 07h
pop 06h
pop 03h
ret

9. Real Time Clock:


This driver routine can be used to interface the RTC chip to the
microcontroller. It consists of two different routines: (i) to write the RTC
timekeeper registers and (ii) to read value of these registers. The RTC
timekeeper registers include seconds, minutes, hours, day, date, month
and year. During initialization the parameters are to be mentioned at the
given address. When the RTC is read, the parameters are returned at the
same locations as mentioned.
Program location for write operation:
87a0h
Location name for write operation:
rtc_write
Program location for read operation:
8727h
Location name for read operation:
rtc_read
Parameter location: 68h-seconds, 69h-minutes, 6ah-hours, 6bh-day,
6ch-date, 6dh-month
NOTE:
To use this Embedded Routine, the following interface connection
must be carried out between the Controller and the RTC chip:
8051 Port Pins
P3.6
P3.7

RTC (DS 1307)


SDA of RTC
SCLD of RTC

Let us understand with a test program that first loads all the parameters to
the RTC and then displays the clock and other parameters on LCD.
Test Program:
EPB/SLK-51 User Manual

55

include location.h
include embedded.h
org 0000h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
lcall lcd4_init
mov 68h,#00h
mov 69h,#60h
mov 6ah,#11h
mov 6bh,#07h
mov 6ch,#15h
mov 6dh,#06h
lcall rtc_write

;sec data
;minute data
;hour data
;day
;date
;month
;rtc write

loop:
lcall rtc_read ;rtc read
mov 70h,#80h
lcall lcd4_cmd

;lcd cmd

mov a,68h ;sec


anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat
mov a,68h
anl a,#0fh
add a,#30h
mov 70h,a
lcall lcd4_dat
mov 70h,#20h
lcall lcd4_dat
EPB/SLK-51 User Manual

56

mov a,69h ;min


anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat
mov a,69h
anl a,#0fh
add a,#30h
mov 70h,a
lcall lcd4_dat
mov 70h,#20h
lcall lcd4_dat
mov a,6ah ;hour
anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat
mov a,6ah
anl a,#0fh
add a,#30h
mov 70h,a
lcall lcd4_dat
mov 70h,#020h
lcall lcd4_dat
mov a,6bh ;day
anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat
mov a,6bh
anl a,#0fh
add a,#30h
mov 70h,a
lcall lcd4_dat

EPB/SLK-51 User Manual

57

mov 70h,#20h
lcall lcd4_dat
mov a,6ch ;date
anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat
mov a,6ch
anl a,#0fh
add a,#30h
mov 70h,a
lcall lcd4_dat
mov 70h,#0c0h
lcall lcd4_cmd
mov a,6dh ;month
anl a,#0f0h
swap a
add a,#30h
mov 70h,a
lcall lcd4_dat
mov a,6dh
anl a,#0fh
add a,#30h
mov 70h,a
lcall lcd4_dat
ljmp loop
end:sjmp end

EPB/SLK-51 User Manual

58

10. Serial EEPROM (same lines):


This routine can be used to interface the serial EEPROM to the
microcontroller.
There are two operations to interface the serial EEPROM: (i) to write
EEPROM and (ii) to read EEPROM. The data to be written to the memory
is stored at fixed location. The write routine is used to store the data at
fixed location in the memory.
In the Read operation also, the routine is called from the main program.
This routine reads the data stored in the EEPROM and sends it at fixed
locations, which then can be read.
Location for Write operation: 8669h
Location Name for Write operation: write_srom
Location for Read operation: 88b0h
Location Name for Read operation: read_srom
Data location (Read/Write): 7bh, 7ch, 7dh, 7eh
NOTE:
To use this Embedded Routine, the following interface connection
must be carried out between the Controller and the EEPROM chip:
8051 Port Pins
P3.6
P3.7

Serial EEPROM (24C16)


SDA of E2PROM
SCLK of E2PROM

Let us make clear how to use this routine by considering a program to


store the data in eeprom and read it back.

EPB/SLK-51 User Manual

59

Test Program
include location.h
include embedded.h
org 0000h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
lcall lcd4_init
mov 7bh,#30h
mov 7ch,#32h
mov 7dh,#35h
mov 7eh,#37h
lcall write_rom

;write ROM

mov 7bh,#0h
mov 7ch,#0h
mov 7dh,#0h
mov 7eh,#0h
lcall read_rom

;read ROM

mov a,7bh
mov 70h,a
lcall lcd4_dat
mov 70h,#20h
lcall lcd4_dat
mov a,7ch
mov 70h,a
lcall lcd4_dat
mov 70h,#20h
lcall lcd4_dat

EPB/SLK-51 User Manual

60

mov a,7dh
mov 70h,a
lcall lcd4_dat
mov 70h,#20h
lcall lcd4_dat
mov a,7eh
mov 70h,a
lcall lcd4_dat
sjmp $
11. Serial EEPROM (as per ASK):
The description for this routine is per the previous one. However this driver
routine is provided to make ASK card compatible with embedded routines.
Location for Write operation: 94deh
Location Name for Write operation: write_rom
Location for Read operation: 9525h
Location Name for Read operation: read_rom
Data location (Read/Write): 7bh, 7ch, 7dh, 7eh
NOTE:
To use this Embedded Routine, the following interface connection
must be carried out between the Controller and the EEPROM chip,
while using ASK:
8051 Port Pins
P0.6
P0.7

Serial EEPROM (24C16)


SDA of E2PROM
SCLK of E2PROM

Following is given a program to store the data in EEPROM and read it


back.

EPB/SLK-51 User Manual

61

Test Program
include location.h
include embedded.h
org 00h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
lcall lcd4_init
mov 7bh,#'s'
lcall write_rom
lcall read_rom
mov 70h,7bh
lcall lcd4_dat
sjmp $
12. Parallel ADC
This driver routine is designed to interface the 8-bit ADC to the
microcontroller.
Here the channel has to be first selected and then the ADC routine has to
be called. This ADC routine will store the ADC output data to a fixed
location, which can be accessed in the main program.
Location for ADC routine: 8980H
Location Name for ADC routine: adc_read
Channel Select Address (00H to 07H) location: 79H
ADC output location: 7aH
Let us make clear how to use this routine by considering following
program.
Suppose ADC - 0809 is connected as per the following connections.

EPB/SLK-51 User Manual

62

8051 Port Pins


P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7

8-bit ADC 0809


A0 Address lines of ADC
A1 Address lines of ADC
A2 Address lines of ADC
Start Address lines of ADC
ALE Address lines of ADC
EOC Address lines of ADC
D1
D2
D3
D4
D5
D6
D7

The following must be incorporated in your program to make the above


connections working:
mov r0,#padcadr
mov @r0,#00h
mov r0,#padcsoc
mov @r0,#03h
mov r0,#padcale
mov @r0,#04h
mov r0,#padceoc
mov @r0,#05h
mov r0,#padcdat
mov @r0,#01h
Now let us write a program to read the digital data from ADC and display it
on LCD.

EPB/SLK-51 User Manual

63

Test Program
include embedded.h
include location.h
org 00h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
lcall lcd4_init

;LCD initialization routine

mov r0,#padcadr
mov @r0,#00h
mov r0,#padcsoc
mov @r0,#03h
mov r0,#padcale
mov @r0,#04h
mov r0,#padceoc
mov @r0,#05h
mov r0,#padcdat
mov @r0,#01h
mov 79h, #07h

;ADC channel

again: mov 70h,#80h


lcall lcd4_cmd
mov 70h,#31h
lcall lcd4_dat

;lcd dat

lcall adc_read

;ADC read

mov 70h,#87h
lcall lcd4_cmd

EPB/SLK-51 User Manual

64

mov a, 7ah

;ADC data

anl a,#0f0h
swap a
mov dptr,#table
movc a,@a+dptr
mov 70h,a
lcall lcd4_dat
mov a, 7ah
anl a,#0fh
movc a,@a+dptr
mov 70h,a
lcall lcd4_dat
ljmp again
table:
db 30h;0
db 31h;1
db 32h;2
db 33h;3
db 34h;4
db 35h;5
db 36h;6
db 37h;7
db 38h;8
db 39h;9
db 41h;a
db 42h;b
db 43h;c
db 44h;d
db 45h;e
db 46h;f

EPB/SLK-51 User Manual

65

13. SERIAL ADC


This driver routine can be used to interface the serial ADC (ADS 1286)
with microcontroller.
Since this ADC is 12-bit serial ADC, we have to the received digital data
from serial ADC in two fixed locations.
Location for Serial ADC read:
Location name:
Data location:

8a3bh
ssadc_read
5eh, 5fh

NOTE:
To use this Embedded Routine, the following interface connection
must be carried out between the Controller and the ADC chip:
8051 Port Pins
P0.0
P3.6
P3.7

SERIAL ADC(ADS 1286)


CS of SERIAL ADC
SDA of SERIAL ADC
SCLD of SERIAL ADC

Let us make clear how to use this routine by writing a program to display
digital data from serial ADC.
Test Program
include embedded.h
include location.h
org 00h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
lcall lcd4_init

EPB/SLK-51 User Manual

;LCD initialization routine

66

again: mov 70h,#80h


lcall lcd4_cmd
lcall ssadc_read

;ADC read

mov a,5eh
anl a,#0f0h
swap a
mov dptr,#table
movc a,@a+dptr
mov 70h,a
lcall lcd4_dat
mov a,5eh
anl a,#0fh
movc a,@a+dptr
mov 70h,a
lcall lcd4_dat
mov a,5fh
anl a,#0fh
movc a,@a+dptr
mov 70h,a
lcall lcd4_dat
ljmp again
table:
db 30h;0
db 31h;1
db 32h;2
db 33h;3
db 34h;4
db 35h;5
db 36h;6
db 37h;7
db 38h;8
db 39h;9
db 41h;a
db 42h;b
db 43h;c
db 44h;d
db 45h;e
db 46h;f
EPB/SLK-51 User Manual

67

14. SERIAL ADC (as per ASK):


The description for this routine is per the previous one. However this driver
routine is provided to make ASK card compatible with embedded routines.
Location for Serial ADC read:
Location name:
Data location:

949fh
sadc_read
5eh, 5fh

NOTE:
To use this Embedded Routine, the following interface connection
must be carried out between the Controller and the EEPROM chip,
while using ASK:
8051 Port Pins
P0.0
P0.1
P0.2

SERIAL ADC(ADS 1286)


CS of SERIAL ADC
SDA of SERIAL ADC
SCLD of SERIAL ADC

Let us make clear how to use this routine by writing a program to display
digital data from serial ADC.
Test Program
include embedded.h
include location.h
org 00h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
lcall lcd4_init

EPB/SLK-51 User Manual

;LCD initialization routine

68

again: mov 70h,#80h


lcall lcd4_cmd
lcall sadc_read

;ADC read

mov a,5eh
anl a,#0f0h
swap a
mov dptr,#table
movc a,@a+dptr
mov 70h,a
lcall lcd4_dat
mov a,5eh
anl a,#0fh
movc a,@a+dptr
mov 70h,a
lcall lcd4_dat
mov a,5fh
anl a,#0fh
movc a,@a+dptr
mov 70h,a
lcall lcd4_dat
ljmp again
table:
db 30h;0
db 31h;1
db 32h;2
db 33h;3
db 34h;4
db 35h;5
db 36h;6
db 37h;7
db 38h;8
db 39h;9
db 41h;a
db 42h;b
db 43h;c
db 44h;d
db 45h;e
db 46h;f

EPB/SLK-51 User Manual

69

15. GRAPHIC LCD


This driver routine consists of 11 subroutines. Since Graphic LCD is
basically divided into two sections, these routines are made so flexible
such that they make it possible for the user to use either one or both chip
sections to work with. The details of these routines is as follows:
Graphic LCD Initialization: This routine is used to initialize the Graphic
LCD.
Program location:
Location name:

8a7ah
glcd_init

Graphic LCD Display On routine: This routine can be used to make the
Graphic LCD screen on.
Program location:
Location name:

8ae6h
glcd_dispon

Graphic LCD Display Off routine: This routine can be used to turn off the
Graphic LCD screen.
Program location:
Location name:

8b43h
glcd_dispoff

Graphic LCD Startline routine for Chip Section 1:This routine can be
used to assign the startline value in chip section 1 of the Graphic LCD.
Program location: 8ba0h
Location name:
glcd_srtlin1
Startline command location: 73h
Graphic LCD Page Address routine for Chip Section 1:This routine can
be used to assign the starting page adddress value for chip section 1 of
the Graphic LCD.
Program location: 8c34h
Location name:
glcd_page1
Page Address command location: 74h

EPB/SLK-51 User Manual

70

Graphic LCD Y-Address routine for Chip Section 1: This routine can be
used to assign the Y-address value for chip section 1 of the Graphic LCD.
Hence the starting column where the first data is to written, can be defined
by using this routine.
Program location: 8c7eh
Location name:
glcd_yadd1
Y-Address command location: 75h
Graphic LCD Clear screen routine for Chip Section 1:This routine can
be used to clear the chip section 1 of the Graphic LCD.
Program location:
Location name:

95f5h
glcd_clr1

Graphic LCD Data routine for Chip Section 1:This routine can be used
to send data at the defined location in chip section 1 of the Graphic LCD.
Program location:
Location name:
Data location:

8d5ch
glcd_send1
72h

Graphic LCD Startline routine for Chip Section 2:This routine can be
used to assign the startline value in chip section 2 of the Graphic LCD.
Program location: 8beah
Location name:
glcd_srtlin2
Startline command location: 76h
Graphic LCD Page Address routine for Chip Section 2:This routine can
be used to assign the starting page adddress value for chip section 2 of
the Graphic LCD.
Program location: 8cc8h
Location name:
glcd_page2
Page Address command location: 77h

EPB/SLK-51 User Manual

71

Graphic LCD Y-Address routine for Chip Section 2: This routine can be
used to assign the Y-address value for chip section 2 of the Graphic LCD.
Hence the starting column where the first data is to written, can be defined
by using this routine.
Program location: 8d12h
Location name:
glcd_yadd2
Y-Address command location: 78h
Graphic LCD Clear screen routine for Chip Section 2:This routine can
be used to clear the chip section 2 of the Graphic LCD.
Program location:
Location name:

9629h
glcd_clr2

Graphic LCD Data routine for Chip Section 2:This routine can be used
to send data at the defined location in chip section 2 of the Graphic LCD.
Program location: 8da0h
Location name:
glcd_send2
Startline command location: 72h
To make all this stuff clear, let us look at a sample program. Suppose the
Graphic LCD is connected as per following connections
8051 Port Pins
P0
P2.0

Graphic LCD
GLCD Data Lines
GLCD D/I pin

P2.1

GLCD EN pin

P2.2

GLCD CS1 pin

P2.3

GLCD CS2 pin

P2.4

GLCD RST pin

P2.6

GLCD RW pin

EPB/SLK-51 User Manual

72

The following statements must be incorporated in your program to make


the above connections working:
mov r0, #glcddat
mov @r0, #00h
mov r0, #glcddi
mov @r0, #20h
mov r0, #glcden
mov @r0, #21h
mov r0, #glcdcs1
mov @r0, #22h
mov r0, #glcdcs2
mov @r0, #23h
mov r0, #glcdrst
mov @r0, #24h
mov r0, #glcdrw
mov @r0, #26h
Let us write a program to display the logo of "EDUTECH SYSTEMS" on
Graphic LCD.
Test Program
include embedded.h
include location.h
eom equ 0fdh
org 00h
mov sp, #7fh
mov r0, #glcddat
mov @r0, #00h
mov r0, #glcddi
mov @r0, #20h
mov r0, #glcden
mov @r0, #21h
mov r0, #glcdcs1
mov @r0, #22h
mov r0, #glcdcs2
mov @r0, #23h
mov r0, #glcdrst
mov @r0, #24h
mov r0, #glcdrw
mov @r0, #26h

EPB/SLK-51 User Manual

73

lcall glcd_init
lcall glcd_dispon

;glcd initialization
;glcd display on

lcall glcd_clr1
lcall glcd_clr2
sec1:
mov 73h, #00h
lcall glcd_srtlin1

;cs1 startline

mov 75h,#00h
lcall glcd_yadd1

;cs1 yadr

mov dptr, #msg


mov r0, #00h
nxt1: mov r1, #00h
mov 74h, r0
lcall glcd_page1
;cs1 page
agn1: clr a
movc a, @a+dptr
inc dptr
cjne a, #eom, cont1
sjmp nxt
cont1: mov 72h, a
lcall glcd_send1
;cs1 data
inc r1
cjne r1, #64, agn1
inc r0
cjne r0, #03h, nxt1
sjmp agn1
nxt:

mov 75h,#14
lcall glcd_yadd1

;cs1 yadr

mov 74h, #03h


lcall glcd_page1

;cs1 page

mov dptr, #msg1

agn2: clr a
EPB/SLK-51 User Manual

74

movc a, @a+dptr
inc dptr
cjne a, #eom, cont2
sjmp $
cont2: mov 72h, a
lcall glcd_send1
sjmp agn2
msg: db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,80h,80h,c0h
db c0h,e0h,f0h,f0h,f8h,f8h,f8h,fch,fch,feh,feh,feh,feh,ffh,ffh,ffh,ffh,ffh,ffh,ffh,ffh
db ffh,ffh,ffh,ffh,ffh,ffh,ffh,ffh,feh,feh,feh,fch,fch,fch,f8h,f0h,e0h,80h,00h,00h,00h
db 00h,00h
db 00h,00h,00h,00h,00h,00h,00h,80h,c0h,e0h,f0h,f0h,f0h,04h,06h,e7h,e7h,e7h,e7h,e7h,e7h
db 67h,67h,e7h,e7h,e7h,e7h,e7h,e7h,e7h,e7h,cfh,8fh,1fh,1fh,7fh,f7h,07h,07h,f7h,ffh,ffh
db ffh,ffh,ffh,f7h,07h,07h,f7h,ffh,ffh,ffh,ffh,ffh,ffh,ffh,ffh,3fh,1fh,00h,00h,00h,00h
db 00h
db 40h,60h,70h,78h,7ch,7eh,7fh,7fh,7fh,7fh,7fh,7fh,3fh,00h,00h,1fh,1ch,1ch,1ch,1ch,1ch
db 18h,18h,1fh,1fh,1fh,1fh,1fh,1fh,1fh,1fh,0fh,47h,40h,40h,70h,78h,40h,00h,3fh,7fh,7fh
db 7fh,7fh,7fh,3fh,00h,00h,3fh,1fh,0fh,07h,07h,07h,03h,01h,00h,00h,00h,00h,00h,00h,00h
db 00h,eom
msg1:db 01h,01h,ffh,01h,01h
db ffh,99h,99h,81h,81h
db 7eh,81h,81h,81h,42h
db ffh,18h,18h,18h,ffh,eom

EPB/SLK-51 User Manual

75

16. PRINTER
This routine can be used to interface the printer to the microcontroller.
There are two routines viz. (i) printer initialization and (ii) print routine. In
the printer initialization routine necessary communication protocol is being
set. By using the second driver routine i.e. print routine, you can print the
message on paper without engaging your PC for printing purpose. The
data is stored to a fixed location and the printer routine is called.
Location for printer initialization:
Location Name for printer initialization:
Location for print routine:
Location Name for printer initialization:
Data location (Write):

8051 Port Pins


P0
P2.4

8e8fh
pri_init
8eaah
print
6fh

PRINTER
Printer data port
Printer strobe pin

P2.6

Printer initialization pin

P2.7

Printer busy pin

The following must be incorporated in your program to make the above


connections working:
mov r0, #prdat
mov @r0, #00h
mov r0, #pbusy
mov @r0, #27h
mov r0, #pinit
mov @r0, #26h
mov r0, #pstrob
mov @r0, #24h
Lets now see an example program for printer.

EPB/SLK-51 User Manual

76

Test Program:
include location.h
include embedded.h
eom equ 0ffh
org 00h
mov r0, #prdat
mov @r0, #00h
mov r0, #pbusy
mov @r0, #27h
mov r0, #pinit
mov @r0, #26h
mov r0, #pstrob
mov @r0, #24h
lcall pri_init
mov dptr, #msg
agn: mov a, #00h
movc a, @a+dptr
inc dptr
cjne a, #eom, go
sjmp exit
go:
mov 6fh, a
lcall print
sjmp agn
exit: sjmp $
msg:db
db

;;;;;data to print

'Dear Students,',0ah,0ah,09h,' Welcome to Microcontroller


Seminar. ',0ah
'For more details log on to www.edutechonline.com ',0ah

EPB/SLK-51 User Manual

77

17. SERIAL COMMUNICATION USING MODE 1


This routine can be used to communicate controllers in mode 1. There are
three routines viz. (i) Serial communication initialization, (ii) Transmission
routine and (iii) Reception routine. In the Serial communication
initialization routine necessary communication protocol is being set. By
using the second driver routine i.e. Transmission routine, you can transmit
the data to another controller. By using the third driver routine i.e.
Reception routine, you can receive data, which is transmitted by another
controller. To transmit, the data is first stored to a fixed location and then
serial transmission routine is called. Similarly the received data is stored
data is stored in the same location from where the user can read the
received value. Here internally timer 1 is being used in auto reload mode
to set the baud rate, so be careful not to use timer 1 for other uses, when
using this embedded driver routine.
Location for Serial Communication Initialization:
Location Name for Serial Communication Initialization:
Location for Transmission routine:
Location Name for Transmission initialization:
Location for Reception routine:
Location Name for Reception initialization:

8f08h
ser1_init
8f19h
transmit1
8f23h
receive1

Data location (Write/Read):

5bh

Lets now see a simple example program for Serial communication in


mode 1.
Test Program:
include embedded.h
include location.h
org 0000h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
lcall ser1_init
lcall lcd4_init
EPB/SLK-51 User Manual

78

mov 70h,#01h
lcall lcd4_cmd
again:
mov 5bh, #x
lcall transmit1
lcall receive1
mov 70h,#80h
lcall lcd4_cmd
mov a,5bh
mov 70h,a
lcall lcd4_dat
sjmp again
18. SERIAL COMMUNICATION USING MODE 2
This routine can be used to communicate controllers in mode 2. Here also
there are three routines viz. (i) Serial communication initialization, (ii)
Transmission routine and (iii) Reception routine. All the concepts are then
as per the previous one. The only benefit is that you need not to engage
your timer to set baud rate for serial communication.
Location for Serial Communication Initialization:
Location Name for Serial Communication Initialization:
Location for Transmission routine:
Location Name for Transmission initialization:
Location for Reception routine:
Location Name for Reception initialization:

8f2eh
ser2_init
8f3fh
transmit2
8f42h
receive2

Data location (Write):

5bh

Lets now see an example program for Serial communication in mode 2.

EPB/SLK-51 User Manual

79

Test Program:
include embedded.h
include location.h
org 0000h
mov sp, #7fh
mov r0, #lcd4d
mov @r0, #02h
mov r0, #lcd4en
mov @r0, #24h
mov r0, #lcd4rs
mov @r0, #25h
lcall ser2_init
lcall lcd4_init
mov 70h,#01h
lcall lcd4_cmd
again:
mov 5bh, #x
lcall transmit2
lcall receive2
mov 70h,#80h
lcall lcd4_cmd
mov a,5bh
mov 70h,a
lcall lcd4_dat
sjmp again

EPB/SLK-51 User Manual

80

Chapter 10
FAQ
1) What is SLK-51?
The SLK-51 is a self-learning card specially designed for students who are
studying 8051 as their curricular subject. This card is designed to make
you confident enough to learn, test & apply 8051.
2) What is the difference between EPB & SLK-51?
Both the cards are same. Only the difference is the bread-board which is
available with the EPB. Also it is in a kit from packed in a wooden box. The
EPB is generally designed for institute labs where the components are
required to be inserted & not soldered so as to reuse them. However, SLC
is having a general-purpose area, where soldering of components is
possible and user can do project related activities.
3) Does the EPB/SLC loose its program when powered off?
No, the program does not loose even if the power is OFF. The program is
stored in the flash program memory and not in the RAM.
4) How many times can I write and erase program using the
EPB/SLC board?
The CPU chip manufacturer specifies that the Write/Erase operations can
be carried out for about 10,000 times which can be considered as pretty
high.
5) What precaution should I take while using the EPB/SLK-51?
First of all, try to read the user manual thoroughly before starting the kit.
Also do not remove the chip from the socket if possible. It is likely that the
static charge might damage the chip. Also make the power supply OFF
while change from program and Run mode.

EPB/SLK-51 User Manual

81

6) What is the Program & Run mode?


The chip provided on board has the facility of in-circuit programming.
Hence it can be programmed and erased without removing from the
socket and without using any external programmer. So to erase or load the
program, we have the program mode and to run the loaded program, we
have to RUN option. A program mode switch provided on board can select
these options.
7) What is WINISP?
WINISP is a virtual programmer utility provided by the chip manufacture.
This utility can be installed and program can be transferred to the chip and
erased while the chip is in circuit.
8) What items do I need to get started with the EPB/SLK-51?
The items you need are:
1)
2)
3)
4)

The programming software


The programming cable
The manual
The EPB/SLK-51 Module itself and optionally the available additional
interfacing kits.

You also need same basic components like the LEDs, Resistors, hook up
wires, Keys etc, to interface to the CPU. If you are interested to use the
SLK-51 in your project and you need more interfacing devices, you can
purchase different available options separately. It is best to purchase
various other available self learning cards (which include manual, software
and cables) that suit your requirements.
We however, recommended to purchase the LCD/key SLC-02 interface kit
along with the SLK-51, so that you can do lot of practice exercise, learn
how LCD is interface & do almost any project assignment.

EPB/SLK-51 User Manual

82

9) What are the different optional SLC modules available?


The basic module i.e., the EPB/SLK-51 can be interfaced with number of
modules. There exist two different types of modules for institutes &
individual user. However, there is no much differ in this construction.
As an individual user, you can select from the following module.
1.
2.
3.
4.
5.

SLC-02
SLC-03
SLC-04
SLC-05
SLC-06

LCD/4-key interface module


LCD/4-key e2prom interface module
LCD/4-key RTC module
LCD/4 key e2prom, rtc module
LCD/4 key/e2prom/adc module

10) Is the EPB/SLK-51 module sensitive to static electricity?


While many electronic devices, including the EPB/SLK-51 can be
damaged by static electricity; the SLK-51 is less sensitive to static
electricity.
But we do, however recommend that the CPU chip should not be removed
from the socket since it is likely to get damaged by static electricity.
11) How many I/O pins does the EPB/SLK-51 have?
The EPB/SLK-51 has 32 i/o lines. All the ports pins are made available to
the user.
12) How does EPB/SLK-51 differ from a conventional kit?
The EPB/SLK-51 is totally different from the conventional kit. It is a true
single chip design, which is develop to provide you a real feel of working
with microcontroller. All the routines, interfaces are to be done by you and
nothing is made available ready made. However the document provide
with the EPB/SLK-51 will help you to build you own system that
demonstrate application developed by you.

EPB/SLK-51 User Manual

83

13) Why should I go for EPB/SLK-51?


The 8051 controller comes as a subject in the University curriculum. As
you know that 8051 controller can be applied to large variety of interfaces
to develop application.
These days, the use of controller has increased a lot and they are applied
in different consumer item, industrial equipments and even toys. Also
these days, industry is also not doing well. Hence if you are really through
in the concepts you have learnt in your curriculum and if you can apply
those concepts learnt, you will survive. Also if you plan to start on your
own and develop applications that are required by the society or try to
have some maintenance related job that involves controllers (areas like
consumer electronics, Medical electronics, Automobile etc) you need to be
through in the concept.
SLK-51 is the product designed for you to make you a complete engineer
who can interface and apply controller to solve problems.
We are sure that with this faith & dedication, you should be successful in
your life. SLK-51 is meant for that.
14) What can I use I/O pins for?
The EPB/SLK-51 pins are perfectly suited for digital input and output with
TTL/CMOS level (0 to 5 V) signals. You can use it to generate PWM
signals and apply them. More details of applications can be studied by
referring the data sheet of the CPU.
15) Can I use the I/O pins to control relays, solenoids and other
similar devices?
Yes, however, due to the demanding current and voltage requirements of
some of these components, driver circuits will need to be used to properly
isolate the i/o pin from harmful effect.

EPB/SLK-51 User Manual

84

16) Can I control LEDs with the I/O pin?


Yes, simply use a 470 ohm resistor in series with the LED to limit the
current drawn through the i/o pin. Also keep in mind that most LED,
require a lot of current in relation to what the EPB/SLK-51 can provide. If
you attach more LEDs at one time from and power the i/o pins of
EPB/SLK-51, you all likely to see flaky and unpredictable results caused
by voltage sag, i/o pin damage and/or hardware resets. Either driver
circuitry or low current LEDs will need to be used if you require such an
application.
17) How do I program the EPB/SLK-51?
You can use the WINISP, a virtual programmer provided with the package
to program the EPB/SLK-51.
18) How do I connect the EPB/SLK-51 to my computer for
programming?
You need to serially connect the EPB/SLK-51 to the serial port of PC. The
programming cable is provided to do the interface.
19) What other tools can be used to develop program for EPB/SLC01?
A part from assembler provided with the package, you can even write
program in C-language or both C and assembly language and use tools
like C-Cross Compiler. You can also use utilities like simulator to check
your program.
20) From where do I get the different development tools? How?
There are numbers of developer who provide these development tools.
But these tools are little costly for individuals. However, you can get these
tools on RENT by paying fraction of the actual cost and take up an
experience to work on World class development tools. We at Edutech
System, provide these tools on RENT basis to facilitate student community
to learn and apply controller in most professional way.

EPB/SLK-51 User Manual

85

21) What are embedded drivers?


Embedded drivers are standard subroutine programs that are prewritten
and stored in the flash memory by the manufacturer. These drivers have
unique address. They can be easily referred to from the main program.
22) What are the advantages of these embedded drivers?
The embedded driver routines can be used to test the program logic.
These drivers can be called when require & their output can be checked.
Thus the routines are useful to test the program as well as to develop
application easily.
23) Do I have to always use these in-built driver to develop my
programs?
No. You can use these embedded drivers if you wish. You can write your
own routines and use the first 32kb flash memory. The last 32kb memory
is reserved for embedded routines.
24) How can these embedded drivers be best used in developing
curriculum projects?
There exists different driver embedded into the card. These drivers are
designed for interfacing LCD, keyboard, ADC, RTC, E 2PROM etc. also
delay, counter, routines are available. You can also use the serial
transmission and reception routines. All these routines can be combined
as per the requirements & used to develop project.
25) How to use these embedded drivers?
Every driver embedded into the card has own unique address. You can
therefore call these routines from your main program. The embedded
routines return you certain values at particular location, which can be
checked in the main program.
For more details you can contact us by email: info@edutechonline.com
You can also refer to our Website at: www.edutechonline.com or call us on
91-0265-2438317.

EPB/SLK-51 User Manual

86

Вам также может понравиться