Sunteți pe pagina 1din 86

EPB/SLK-51

(Low cost 8051 embedded kit with in-circuit


programming facility)

User’s 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 2


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 & 38


Example Programs

Chapter 10 FAQ 81

EPB/SLK-51 User Manual 3


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, it’s 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 4


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 5


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 6


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 7


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 8


P O .0 JP1 P O .1
1 2 1 2
P O .2 3 4 3 4 P O .3
P O .4 5 6 5 6 P O .5
P O .6 7 8 7 8 P O .7

S U P P LY
x 9 10 9 10 P O .0
S W IT C H P 2 .1 11 12 11 12 P 2 .2
P 2 .3 13 14 13 14 P 2 .4
P 2 .5 P 2 .6
15 16 15 16
P 2 .7 ALE
Chapter 4
17 18 17 18
5V 19 20 19 20 GND
PRO G

C P U

EPB/SLK-51 User Manual


O R ED LED

P89051R D 24B P
O G R EEN LED P 1 .0 JP2 P 1 .1
1 2 1 2

The Block Diagram


R UN P 1 .2 3 4 3 4 P 1 .3
P 1 .4 P 1 .5
5 6 5 6
P 1 .6 7 8 7 8 P 1 .7
x 9 10 9 10 P 3 .0
P 3 .1 P 3 .2
11 12 11 12
P 3 .3 13 14 13 14 P 3 .4

PC
P 3 .5 15 16 15 16 P 3 .6
P 3 .7 X
17 18 17 18

IN T E R F A C E
+5V 19 20 19 20 GND

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

9
Understanding the EPB/SLK-51
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 IBM-
PC. 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 General Purpose Area G


N N
D D

General Purpose Area

+ General Purpose Area 5V


+5 V

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 JP1 P O .1
1 2 1 2
P O .2 P O .3
3 4 3 4
P O .4 5 6 5 6 P O .5
P O .6 7 8 7 8 P O .7
x 9 1 0 9 1 0 P O .0
P 2 .1 11 1 2 11 1 2 P 2 .2
P 2 .3 P 2 .4
13 1 4 13 1 4
P 2 .5 P 2 .6
15 1 6 15 1 6
P 2 .7 ALE
17 1 8 17 1 8
5V GN D
19 2 0 19 2 0

P 1 .0 JP2 P 1 .1
1 2 1 2
P 1 .2 3 4 3 4 P 1 .3
P 1 .4 P 1 .5
5 6 5 6
P 1 .6 7 8 7 8 P 1 .7
x P 3 .0
9 1 0 9 1 0
P 3 .1 P 3 .2
11 1 2 11 1 2
P 3 .3 P 3 .4
13 1 4 13 1 4
P 3 .5 15 1 6 15 1 6 P 3 .6
P 3 .7 17 1 8 17 1 8 X
+5V 19 2 0 19 2 0 GN D

We provide different cards like LCD/keyboard interface, 7-


segment/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
org 0000h
sjmp main
org 0060h
main: 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/SLK-
51 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:

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 Variable Used Program


Routine Location

Delay Delay in millisecond delay_ms 80ffh

LCD LCD Initialization lcd4_init 812ch


(4 bit data bus) LCD command lcd4_cmd 81b0h
LCD data lcd4_dat 8217h

LCD LCD Initialization lcd8_init 8289h


(8 bit data bus) LCD command lcd8_cmd 82eeh
LCD data lcd8_dat0 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 seg_init 86b9h


7 segment interrupt seg_int 86e9h

RTC (connected at p3.6 RTC write rtc_write 87a0h


& p3.7) RTC read rtc_read 8727h

EEPROM (connected at EEPROM write write_srom 8669h


p3.6 & p3.7) EEPROM read read_srom 88b0h

Parallel ADC (8 bit) ADC read adc_read 8980h

Serial ADC (connected Serial ADC read ssadc_read 8a3bh


at p3.6 & p3.7)

EPB/SLK-51 User Manual 26


Component / Description Of Embedded Variable Used Program
Function Routine Location
Graphic LCD Graphic LCD initialization glcd_init 8a7ah
Graphic LCD display on glcd_dispon 8ae6h
Graphic LCD display off glcd_dispoff 8b43h
Graphic LCD start line (cs1) glcd_srtlin1 8ba0h
Graphic LCD start line (cs2) glcd_srtlin2 8beah
Graphic LCD page (cs1) glcd_page1 8c34h
Graphic LCD y-Address (cs1) glcd_yadd1 8c7eh
Graphic LCD page (cs2) glcd_page2 8cc8h
Graphic LCD y-address (cs2) glcd_yadd2 8d12h
Graphic LCD Data (cs1) glcd_send1 8d5ch
Graphic LCD Data (cs2) glcd_send2 8da0h
Graphic LCD clear screen (cs1) glcd_clr1 95f5h
Graphic LCD clear screen (cs2) glcd_clr2 9629h

Printer Printer initialization pri_init 8e8fh


Print character print 8eaah
Counter Counter initialization counter 8ee1h
Serial Serial communication initialization ser1_init 8f08h
Communication Transmit character transmit1 8f19h
(Mode 1) Receive character receive1 8f23h
Serial Serial communication initialization ser2_init 8f2eh
Communication Transmit character transmit2 8f3fh
(Mode 2) Receive character receive2 8f42h
Serial ADC Serial ADC read sadc_read 949fh
(connected at p0.1
& p0.2)
EEPROM EEPROM write write_rom 94deh
(connected at p0.6 EEPROM read read_rom 9525h
& p0.7)

EPB/SLK-51 User Manual 27


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 Related Register / Parameter


Location
LCD 70h Command / Data write

Keyboard (All types) 71h Returns key code

7 Segment 60h Data for Digit 1


61h Data for Digit 2
62h Data for Digit 3
63h Data for Digit 4
64h Data for Digit 5
65h Data for Digit 6
66h Data for Digit 7
67h Data for Digit 8

RTC 68h Second (write/read)


69h Minute (write/read)
6ah Hour (write/read)
6bh Day (write/read)
6ch Date (write/read)
6dh Month(write/read)
6eh Year (write/read)

EEPROM 7bh Data 1


(All types) 7ch Data 2
7dh Data 3
7eh Data 4

Parallel ADC 79h Channel selection


7ah Data (read)

Serial ADC 5eh Data(lower byte)


(All types) 5fh Data(higher byte)

EPB/SLK-51 User Manual 28


Component / Function Related Register / Parameter
Location
Graphic LCD 72h Data (CS1/CS2)
73h Startline (CS1)
74h Page (CS1)
75h Y-address (CS1)
76h Startline (CS2)
77h Page (CS2)
78h Y-address (CS2)

Printer 6fh Data (write)

Counter 5ch Lower byte


5dh Higher byte
Serial Communication 5bh Transmit/Receive
(All types)

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 Description


Used
LCD Lcd4d lcd4 data(port) first four pins will get configured
(4 bit data bus) Lcd4en lcd4 enable(port pin)
Lcd4rs lcd4 register select(port pin)

LCD Lcd8d lcd8 data(port)


(8 bit data bus) Lcd8en lcd8 enable(port pin)
Lcd8rs lcd8 register select(port pin)

Matrix Keyboard kbrd5c1 keyboard column 1(port pin)


(5x5) kbrd5c2 keyboard column 2(port pin)
kbrd5c3 keyboard column 3(port pin)
kbrd5c4 keyboard column 4(port pin)
kbrd5c5 keyboard column 5(port pin)
kbrd5r1 keyboard row 1(port pin)
kbrd5r2 keyboard row 2(port pin)
kbrd5r3 keyboard row 3(port pin)
kbrd5r4 keyboard row 4(port pin)
kbrd5r5 keyboard row 5(port pin)

Matrix Keyboard kbrd4c1 keyboard column 1(port pin)


(4x4) kbrd4c2 keyboard column 2(port pin)
kbrd4c3 keyboard column 3(port pin)
kbrd4c4 keyboard column 4(port pin)
kbrd4r1 keyboard row 1(port pin)
kbrd4r2 keyboard row 2(port pin)
kbrd4r3 keyboard row 3(port pin)
kbrd4r4 keyboard row 4(port pin)

EPB/SLK-51 User Manual 30


Component Variable Description
Used

kbrd3c1 keyboard column 1(port pin)


Matrix Keyboard kbrd3c2 keyboard column 2(port pin)
(3x3) kbrd3c3 keyboard column 3(port pin)
kbrd3r1 keyboard row 1(port pin)
kbrd3r2 keyboard row 2(port pin)
kbrd3r3 keyboard row 3(port pin)

Matrix Keyboard kbrd2c1 keyboard column 1(port pin)


(2x2) kbrd2c2 keyboard column 2(port pin)
kbrd2r1 keyboard row 1(port pin)
kbrd2r2 keyboard row 2(port pin)

7 segment segdat 7 segment data


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

Parallel ADC (8 bit) padcadr ADC address line(port) first three pins will get configured
padcsoc ADC start of conversion line(port pin)
padceoc ADC end of conversion line(port pin)
padcale ADC ALE line(port pin)
padcdat ADC data(port)

Graphic LCD Glcddat Graphic lcd data(port)


Glcddi Graphic lcd D/I(port pin)
glcden Graphic lcd enable pin(port pin)
glcdcs1 Graphic lcd cs1 pin(port pin)
glcdcs2 Graphic lcd cs2 pin(port pin)
glcdrst Graphic lcd rst pin(port pin)
glcdrw Graphic lcd rw pin(port pin)

Printer prdat Printer data(port)


pbusy Printer busy(port pin)
pinit Printer initialization(port pin)
pstrob Printer strobe(port pin)

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 equ 812ch


lcd4_cmd equ 81b0h
lcd4_dat equ 8217h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; LCD8

lcd8_init equ 8289h


lcd8_cmd equ 82eeh
lcd8_dat 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 85feh

EPB/SLK-51 User Manual 32


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 7-SEGMENT

seg_init equ 86b9h


seg_int equ 86e9h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RTC

rtc_write equ 87a0h


rtc_read equ 8727h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EEPROM SAME LINE

write_srom equ 8669h


read_srom equ 88b0h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; P_ADC

adc_read equ 8980h

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

ssadc_read equ 8a3bh

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

glcd_init equ 8a7ah


glcd_dispon equ 8ae6h
glcd_dispoff equ 8b43h
glcd_srtlin1 equ 8ba0h
glcd_srtlin2 equ 8beah
glcd_page1 equ 8c34h
glcd_yadd1 equ 8c7eh
glcd_page2 equ 8cc8h
glcd_yadd2 equ 8d12h
glcd_send1 equ 8d5ch
glcd_send2 equ 8da0h
glcd_clr1 equ 95f5h
glcd_clr2 equ 9629h

EPB/SLK-51 User Manual 33


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PRINTER

pri_init equ 8e8fh


print equ 8eaah

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; COUNTER

counter equ 8ee1h

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

ser1_init equ 8F08h


transmit1 equ 8F19h
receive1 equ 8F23h

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

ser2_init equ 8F2Eh


transmit2 equ 8F3Fh
receive2 equ 8F42h

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; S_ADC

sadc_read equ 949fh

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EEPROM

write_rom equ 94deh


read_rom equ 9525h

EPB/SLK-51 User Manual 34


Embedded.h:

;;;;;;;;;;;;;;;;;;;LCD 4 bit;;;;;;;;;;;;;;;;;

lcd4d equ a0h ;lcd4 data(port) first four pins will get configured
lcd4en equ a1h ;lcd4 enable(port pin)
lcd4rs equ a2h ;lcd4 register select(port pin)

;;;;;;;;;;;;;;;;;;;LCD 8 bit;;;;;;;;;;;;;;;;;

lcd8d equ a3h ;lcd8 data(port)


lcd8en equ a4h ;lcd8 enable(port pin)
lcd8rs equ a5h ;lcd8 register select(port pin)

;;;;;;;;;;;;;;;;;;;Keyboard 5x5;;;;;;;;;;;;;;;;;

kbrd5c1 equ a6h ;keyboard column 1(port pin)


kbrd5c2 equ a7h ;keyboard column 2(port pin)
kbrd5c3 equ a8h ;keyboard column 3(port pin)
kbrd5c4 equ a9h ;keyboard column 4(port pin)
kbrd5c5 equ aah ;keyboard column 5(port pin)
kbrd5r1 equ abh ;keyboard row 1(port pin)
kbrd5r2 equ ach ;keyboard row 2(port pin)
kbrd5r3 equ adh ;keyboard row 3(port pin)
kbrd5r4 equ aeh ;keyboard row 4(port pin)
kbrd5r5 equ afh ;keyboard row 5(port pin)

;;;;;;;;;;;;;;;;;;;Keyboard 4x4;;;;;;;;;;;;;;;;;

kbrd4c1 equ b0h ;keyboard column 1(port pin)


kbrd4c2 equ b1h ;keyboard column 2(port pin)
kbrd4c3 equ b2h ;keyboard column 3(port pin)
kbrd4c4 equ b3h ;keyboard column 4(port pin)
kbrd4r1 equ b4h ;keyboard row 1(port pin)
kbrd4r2 equ b5h ;keyboard row 2(port pin)
kbrd4r3 equ b6h ;keyboard row 3(port pin)
kbrd4r4 equ b7h ;keyboard row 4(port pin)

EPB/SLK-51 User Manual 35


;;;;;;;;;;;;;;;;;;;Keyboard 3x3;;;;;;;;;;;;;;;;;

kbrd3c1 equ b8h ;keyboard column 1(port pin)


kbrd3c2 equ b9h ;keyboard column 2(port pin)
kbrd3c3 equ bah ;keyboard column 3(port pin)
kbrd3r1 equ bbh ;keyboard row 1(port pin)
kbrd3r2 equ bch ;keyboard row 2(port pin)
kbrd3r3 equ bdh ;keyboard row 3(port pin)

;;;;;;;;;;;;;;;;;;;Keyboard 2x2;;;;;;;;;;;;;;;;;

kbrd2c1 equ beh ;keyboard column 1(port pin)


kbrd2c2 equ bfh ;keyboard column 2(port pin)
kbrd2r1 equ c0h ;keyboard row 1(port pin)
kbrd2r2 equ c1h ;keyboard row 2(port pin)

;;;;;;;;;;;;;;;;;;;7segment;;;;;;;;;;;;;;;;;

segdat equ c2h ;7 segment data


seldig equ c3h ;Selects Digit in which data is to be
;displayed(port)

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

padcadr equ c4h ;ADC address line(port) first three pins


;will get configured
padcsoc equ c5h ;ADC start of conversion line(port pin)
padceoc equ c6h ;ADC end of conversion line(port pin)
padcale equ c7h ;ADC ALE line(port pin)
padcdat equ c8h ;ADC data(port)

;;;;;;;;;;;;;;;;;;;Graphic LCD;;;;;;;;;;;;;;;;;

glcddat equ c9h ;Graphic lcd data(port)


glcddi equ cah ;Graphic lcd D/I(port pin)
glcden equ cbh ;Graphic lcd enable pin(port pin)
glcdcs1 equ cch ;Graphic lcd cs1 pin(port pin)
glcdcs2 equ cdh ;Graphic lcd cs2 pin(port pin)
glcdrst equ ceh ;Graphic lcd rst pin(port pin)
glcdrw equ cfh ;Graphic lcd rw pin(port pin)

EPB/SLK-51 User Manual 36


;;;;;;;;;;;;;;;;;;;Printer;;;;;;;;;;;;;;;;;

prdat equ d0h ;Printer data(port)


pbusy equ d1h ;Printer busy(port pin)
pinit equ d2h ;Printer initialization(port pin)
pstrob equ d3h ;Printer strobe(port pin)

;;;;;;;;;;;;;;;;;;;I2C RTC;;;;;;;;;;;;;;;;;

irtcdat equ d4h ;i2c RTC data(port pin)


irtcscl equ d5h ;i2c RTC clock(port pin)

;;;;;;;;;;;;;;;;;;;I2C ADC;;;;;;;;;;;;;;;;;

iadcadr equ d6h ;i2c ADC address line(port) first three


;pins must be configured
iadcdat equ d7h ;i2c ADC data(port pin)
iadcscl equ d8h ;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: 812ch


Location name: 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 LCD Module (16 X 2)


P2.0 D4 LCD Data Pin
P2.1 D5 LCD Data Pin
P2.2 D6 LCD Data Pin
P2.3 D7 LCD Data Pin
P2.4 EN Enable LCD
P2.5 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 ;LCD initialization routine

mov 70h,#'A' ;31h is LCD data location


lcall lcd4_dat ;LCD data display routine
sjmp $

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: 8289h


Location name: lcd8_init

EPB/SLK-51 User Manual 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 LCD Module (16 X 2)


P0 LCD Data Pin
P2.1 EN Enable LCD
P2.0 RS Register Select
P2.6 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 ;LCD initialization for 8-bit mode

mov 70h, #85h


lcall lcd8_cmd ;LCD command for 8-bit mode
mov 70h, #'V'
lcall lcd8_dat ;LCD data for 8-bit mode
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 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 5 X 5 Matrix Keyboard


P1.0 Column1 of Keyboard
P1.1 Column2 of Keyboard
P1.2 Column3 of Keyboard
P1.3 Column4 of Keyboard
P1.4 Column5 of Keyboard
P1.5 Row 1 of Keyboard
P1.6 Row 2 of Keyboard
P1.7 Row 3 of Keyboard
P3.6 Row 4of Keyboard
P3.7 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 ;LCD initialization routine

again: mov 70h,#80h


lcall lcd4_cmd ;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 4 X 4 Matrix Keyboard


P0.0 Column1 of Keyboard
P0.1 Column2 of Keyboard
P0.2 Column3 of Keyboard
P0.3 Column4 of Keyboard
P0.5 Row 1 of Keyboard
P0.6 Row 2 of Keyboard
P0.7 Row 3 of Keyboard
P2.6 Row 4 of Keyboard

EPB/SLK-51 User Manual 46


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

mov r0, #kbrd4c1


mov @r0, #00h ;p0.0
mov r0, #kbrd4c2
mov @r0, #01h ;p0.1
mov r0, #kbrd4c3
mov @r0, #02h ;p0.2
mov r0, #kbrd4c4
mov @r0, #03h ;p0.3
mov r0, #kbrd4r1
mov @r0, #05h ;p0.5
mov r0, #kbrd4r2
mov @r0, #06h ;p0.6
mov r0, #kbrd4r3
mov @r0, #07h ;p0.7
mov r0, #kbrd4r4
mov @r0, #26h ;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 ;p0.0
mov r0, #kbrd4c2
mov @r0, #01h ;p0.1
mov r0, #kbrd4c3
mov @r0, #02h ;p0.2
mov r0, #kbrd4c4
mov @r0, #03h ;p0.3

mov r0, #kbrd4r1


mov @r0, #05h ;p0.5
mov r0, #kbrd4r2
mov @r0, #06h ;p0.6
mov r0, #kbrd4r3
mov @r0, #07h ;p0.7
mov r0, #kbrd4r4
mov @r0, #26h ;p2.6

lcall lcd4_init

agn:
lcall keybrd_4
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

EPB/SLK-51 User Manual 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 3 X 3 Matrix Keyboard


P0.0 Column1 of Keyboard
P0.1 Column2 of Keyboard
P0.2 Column3 of Keyboard
P0.5 Row 1 of Keyboard
P0.6 Row 2 of Keyboard
P0.7 Row 3 of Keyboard

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


connections working:

mov r0, #kbrd3c1


mov @r0, #00h ;p0.0
mov r0, #kbrd3c2
mov @r0, #01h ;p0.1
mov r0, #kbrd3c3
mov @r0, #02h ;p0.2
mov r0, #kbrd3r1
mov @r0, #05h ;p0.5
mov r0, #kbrd3r2
mov @r0, #06h ;p0.6
mov r0, #kbrd3r3
mov @r0, #07h ;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 ;p0.0
mov r0, #kbrd3c2
mov @r0, #01h ;p0.1
mov r0, #kbrd3c3
mov @r0, #02h ;p0.2

mov r0, #kbrd3r1


mov @r0, #05h ;p0.5
mov r0, #kbrd3r2
mov @r0, #06h ;p0.6
mov r0, #kbrd3r3
mov @r0, #07h ;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 2 X 2 Matrix Keyboard


P0.0 Column1 of Keyboard
P0.1 Column2 of Keyboard
P0.5 Row 1 of Keyboard
P0.6 Row 2 of Keyboard

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


connections working:

mov r0, #kbrd2c1


mov @r0, #00h ;p0.0
mov r0, #kbrd2c2
mov @r0, #01h ;p0.1
mov r0, #kbrd2r1
mov @r0, #05h ;p0.5
mov r0, #kbrd2r2
mov @r0, #06h ;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 ;p0.0
mov r0, #kbrd2c2
mov @r0, #01h ;p0.1

mov r0, #kbrd2r1


mov @r0, #05h ;p0.5
mov r0, #kbrd2r2
mov @r0, #06h ;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: 86b9h


Location name for initialization: seg_init
Program location for interrupt: 86e9h
Location name for interrupt routine: seg_int
Location for data in respective digit: 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 4 nos. of 7-segment LED


P0.0 Segment a
P0.1 Segment b
P0.2 Segment c
P0.3 Segment d
P0.4 Segment e
P0.5 Segment f
P0.6 Segment g
P0.7 Segment dp
P3.0 Digit 1
P3.1 Digit 2
P3.2 Digit 3
P3.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 ;interrupt routine
reti

main: mov sp, #7fh


mov r0, #segdat
mov @r0, #00h
mov r0, #seldig
mov @r0, #03h
lcall seg_init ;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
push 03h
push 06h
push 07h
mov r3,#9
d3: mov r6,#0ffh
d2: mov r7,#0ffh
d1: 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 RTC (DS 1307)


P3.6 SDA of RTC
P3.7 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 ;sec data


mov 69h,#60h ;minute data
mov 6ah,#11h ;hour data
mov 6bh,#07h ;day
mov 6ch,#15h ;date
mov 6dh,#06h ;month
lcall rtc_write ;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 Serial EEPROM (24C16)


P3.6 SDA of E2PROM
P3.7 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 Serial EEPROM (24C16)


P0.6 SDA of E2PROM
P0.7 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 8-bit ADC – 0809
P0.0 A0 Address lines of ADC
P0.1 A1 Address lines of ADC
P0.2 A2 Address lines of ADC
P0.3 Start Address lines of ADC
P0.4 ALE Address lines of ADC
P0.5 EOC Address lines of ADC
P1.1 D1
P1.2 D2
P1.3 D3
P1.4 D4
P1.5 D5
P1.6 D6
P1.7 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: 8a3bh


Location name: ssadc_read
Data location: 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 SERIAL ADC(ADS 1286)


P0.0 CS of SERIAL ADC
P3.6 SDA of SERIAL ADC
P3.7 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 ;LCD initialization routine

EPB/SLK-51 User Manual 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: 949fh


Location name: sadc_read
Data location: 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 SERIAL ADC(ADS 1286)


P0.0 CS of SERIAL ADC
P0.1 SDA of SERIAL ADC
P0.2 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 ;LCD initialization routine

EPB/SLK-51 User Manual 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: 8a7ah


Location name: glcd_init

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

Program location: 8ae6h


Location name: glcd_dispon

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

Program location: 8b43h


Location name: 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: 95f5h


Location name: 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: 8d5ch


Location name: glcd_send1
Data location: 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: 9629h


Location name: 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 Graphic LCD


P0 GLCD Data Lines
P2.0 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 ;glcd initialization
lcall glcd_dispon ;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: 8e8fh


Location Name for printer initialization: pri_init
Location for print routine: 8eaah
Location Name for printer initialization: print
Data location (Write): 6fh

8051 Port Pins PRINTER


P0 Printer data port
P2.4 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

Let’s 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 ;;;;;data to print
lcall print
sjmp agn
exit: sjmp $

msg:db 'Dear Students,',0ah,0ah,09h,' Welcome to Microcontroller


Seminar. ',0ah
db '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: 8f08h


Location Name for Serial Communication Initialization: ser1_init
Location for Transmission routine: 8f19h
Location Name for Transmission initialization: transmit1
Location for Reception routine: 8f23h
Location Name for Reception initialization: receive1

Data location (Write/Read): 5bh

Let’s 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: 8f2eh


Location Name for Serial Communication Initialization: ser2_init
Location for Transmission routine: 8f3fh
Location Name for Transmission initialization: transmit2
Location for Reception routine: 8f42h
Location Name for Reception initialization: receive2

Data location (Write): 5bh

Let’s 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) The programming software


2) The programming cable
3) The manual
4) 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. SLC-02 LCD/4-key interface module


2. SLC-03 LCD/4-key e2prom interface module
3. SLC-04 LCD/4-key RTC module
4. SLC-05 LCD/4 – key e2prom, rtc module
5. SLC-06 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/SLC-
01?

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

S-ar putea să vă placă și