You are on page 1of 22

INDEX

S no.

TOPIC

1.

Program to toggle LEDs alternatively


interfaced
to
Port
1
of
8051
Microcontroller.
Program to display a string on a set
of Seven Segment Displays interfaced
to 8051 microcontroller.
Program to print a string on a set
of Seven Segment Displays interfaced
to PIC 16F84A Microcontroller.
Program to print a string on LCD
interfaced to PIC 16F84A
Microcontroller.
Program to blink 8 LEDs ON and OFF
interfaced to Port 1(16-23) of
LPC2148 ARM7 Microcontroller.
Program to toggle LEDs alternatively
interfaced
to
Port
1(16-23)
of
LPC2148 ARM7 Microcontroller.
Program to print HELLO on Seven
Segment
Display
interfaced
to
LPC2148 ARM7 Microcontroller
Program to print 12345 on Seven
Segment Display interface to LPC2148
ARM7 Microcontroller.

2.
3.
4.
5.
6.
7.
8.

Done On

Teachers
Sign

EXPERIMENT NO. 1
Aim: Program to toggle LEDs alternatively interfaced to Port 1
of 8051 Microcontroller.
Software Used: C51 V1.20.01
Theory:
The Intel MCS-51 (commonly referred to as 8051) is a Harvard
architecture, CISC instruction set, single chip microcontroller
(C) series which was developed by Intel in 1980 for use in
embedded systems.
The 8051 architecture provides many functions (CPU, RAM, ROM,
I/O, interrupt logic, timer, etc.) in a single package 8-bit
ALU and Accumulator, 8-bit Registers (one 16-bit register with
special move instructions), 8-bit data bus and 2x16-bit
address bus/program counter/data pointer and related 8/11/16bit operations; hence it is mainly an 8-bit microcontroller
Boolean processor with 17 instructions, 1-bit accumulator, 32
registers (4 bit-addressable 8-bit) and up to 144 special 1
bit-addressable RAM variables (18 bit-addressable 8-bit)
Multiply, divide and compare instructions
fast switchable register banks with 8 registers each (memory
mapped)
Fast interrupt with optional register bank switching
Interrupts and threads with selectable priority
Dual 16-bit address bus It can access 2 x 216 memory
locations 64 kB (65536 locations) each of RAM and ROM
128 bytes of on-chip RAM (IRAM)
4 KiB of on-chip ROM, with a 16-bit (64 KiB) address space
(PMEM). Not included on 803X variants
Four 8-bit bi-directional input/output port
UART (serial port)
Two 16-bit Counter/timers
Power saving mode (on some derivatives)
In order to toggle LEDs using 8051, the PORT is first set as
output port by setting the bits(0xff).
The PORT is then alternatively given a Hexadecimal value of 0x55
and 0xAA with a small delay for glowing the LEDs alternatively.

Program Code:
#include <stdio.h>
#include <reg51.h>
//Program to Blink LED Alternatively
void delay(void);
void main(void)
{
//Initialize port as output
P1 = 0xff;
P1 = 0xaa;
while(1)
{
P1 = 0x55;
delay();
P1 = 0xaa;
delay();
}
}
void delay()
{ int i=0,j=0;
for(i=0;i<200;i++)
{
for(j=0;j<200;j++);
}
}

//Delay Function

Hex Code:
:20000000020023227DC87FC8DFFEDDFA227590FF7590AA800C7590551200047
590AA1200C7
:1E0020000480F2E5A8C2AF549075811FA881760018B81FFAC0E0120003D0A80
2000D91
:00000001FF

Result: The string LEDs are alternatively toggled.

EXPERIMENT NO. 2
Aim: Program to display a string on a set of Seven Segment
Displays interfaced to 8051 microcontroller.
Software Used: C51 V1.20.01
Theory:
One universal requirement for most of the digital devices is an
image numeric display. A seven segment
display, which is also
known as seven segment indicator is an electronic device that is
used to display decimal values. Seven segment displays are often
used when the embedded product needs to display only a few
digits.
A seven segment LED display is an special arrangement of 7 LED
elements to form a rectangular shape using two vertical segments
on each side with one horizontal segment on the top, middle, and
bottom. By individually turning the segments on or off, numbers
from 0 to 9 and some letters can be displayed.
The segments are marked with non-capital letters: a, b, c, d, e,
f, g and dp, where dp is the decimal point.
The 8 LEDs inside the display can be arranged with a common
cathode or common anode configuration.
With a common cathode display, the cathodes of all the segment
LEDs are tied together and this common point must be connected
to the ground. A required LED segment is then turned on by
applying a logic 1 to its anode.
In common anode displays, all Individual segments are turned on
by applying logic 0 to their cathodes. The anodes are tied
together and the common anode is connected to the supply voltage
Vcc.

Program Code:
#include <stdio.h>
#include <reg51.h>
near uchar C;
void main(void)
{
P0 = 0XFF;
P2 = 0XFF;
for(;;)
{ P0 = 0XF9;
P2 = 0XF8;
DELAY1();

//DISPLAY I

P0 = 0X92;
P2 = 0XF9;
DELAY1();

//DISPLAY S

P0 = 0X8C;
P2 = 0XFA;
DELAY1();

// DISPLAY P

P0 = 0X87;
P2 = 0XFB;
DELAY1();

// DISPLAY t

P0 = 0XAF;
P2 = 0XFC;
DELAY1();

// DISPLAY r

P0 = 0XAB;
P2 = 0XFD;
DELAY1();
}
}

// DISPLAY n

DELAY1()
{ for(C=0;C<255;C++);
}

Hex Code:
:2000000002005122E4F52005207DFFAF20C3EF9D40F5227580FF75A0FF7580F975A0F81247
:20002000000475809275A0F912000475808C75A0FA12000475808775A0FB1200047580AF25
:2000400075A0FC1200047580AB75A0FD12000480C8E5A8C2AF5490758120A881760018B802
:0C0060001FFAC0E0120003D0A802001339
:00000001FF

Result: The string is thus displayed on the seven segment


display.

EXPERIMENT NO. 3
Aim: Program to print a string on a set of Seven Segment Displays
interfaced to PIC 16F84A Microcontroller.
Software Used: MPLAB IDE
Theory:
PIC is a family of modified Harvard architecture controllers
made by Microchip Technology. The name PIC initially referred to
"Peripheral Interface Controller"
PICs are popular with both industrial developers and hobbyists
alike due to their low cost, wide availability, large user base,
extensive collection of application notes, availability of low
cost or free development tools, and serial programming (and reprogramming with flash memory) capability.
The
PIC
architecture
is
characterized
by
its
multiple
attributes:
Separate code and data spaces (Harvard architecture).
A small number of fixed length instructions
Most instructions are single cycle execution (2 clock cycles,
or 4 clock cycles in 8-bit models), with one delay cycle on
branches and skips
One accumulator (W0), the use of which (as source operand) is
implied (i.e. is not encoded in the opcode)
All RAM locations function as registers as both source and/or
destination of math and other functions.
A hardware stack for storing return addresses
A small amount of addressable data space (32, 128, or 256
bytes, depending on the family), extended through banking
Data space mapped CPU, port, and peripheral registers
ALU status flags are mapped into the data space
The program counter is also mapped into the data space and
writable (this is used to implement indirect jumps).
There is no distinction between memory space and register space
because the RAM serves the job of both memory and registers, and
the RAM is usually just referred to as the register file or
simply as the registers.
PIC16F84A 18-pin Enhanced FLASH/EEPROM 8-Bit Microcontroller
All instructions single-cycle except for program branches
which are two-cycle
Operating speed: DC - 20 MHz clock input DC - 200 ns
instruction cycle
1024 words of program memory
68 bytes of Data RAM

64 bytes of Data EEPROM


14-bit wide instruction words
8-bit wide data bytes
15 Special Function Hardware registers
Eight-level deep hardware stack
Direct, indirect and relative addressing modes
Four interrupt sources:
External RB0/INT pin
TMR0 timer overflow
PORTB<7:4> interrupt-on-change
Data EEPROM write complete

A seven segment LED display is an special arrangement of 7 LED


elements to form a rectangular shape using two vertical segments
on each side with one horizontal segment on the top, middle, and
bottom. By individually turning the segments on or off, numbers
from 0 to 9 and some letters can be displayed.
The segments are marked with non-capital letters: a, b, c, d, e,
f, g and dp, where dp is the decimal point.

Program Code:
#include <system.h>
void main()
{
int i;
trisa=0x00;
trisb=0x00;
porta=0x00;
portb=0x89;
for(i=0;i<20;i++);

//For setting PORT A in output mode


//For setting PORT B in output mode
//For selecting 1st FNc
//For Printing H on FNc
//Delay

porta=0x01;
portb=0x86;
for(i=0;i<12;i++);

//For selecting 2nc FNc


//For Printing E on FNc

porta=0x02;
portb=0xc7;
for(i=0;i<12;i++);

//For selecting 3rc FNc


//For Printing L on FNc

porta=0x03;
portb=0xc7;
for(i=0;i<12;i++);

//For selecting 4th FNc


//For Printing L on FNc

porta=0x04;
portb=0xc0;
for(i=0;i<12;i++);

//For selecting 5th FNc


//For Printing O on FNc

porta=0x04;
portb=0xff;
for(i=0;i<12;i++);

//For selecting 6th FNc


//For Printing None

Hex File:
:020000007A285C
:0A000600831603138501860183129F
:10001000850189308600A101A20114302102220845
:100020000318142803191628A21F1A28A10A031955
:10003000A20A0D280130850086308600A101A201A8
:100040000C30210222080318272803192928A21F8F
:100050002D28A10A0319A20A202802308500C730E2
:100060008600A101A2010C302102220803183A28BF
:1000700003193C28A21F4028A10A0319A20A332809
:1000800003308500C7308600A101A2010C30210297
:10009000220803184D2803194F28A21F5328A10A2C
:1000A0000319A20A462804308500C0308600A10149
:1000B000A2010C30210222080318602803196228CB
:1000C000A21F6628A10A0319A20A59280430850034
:1000D000FF308600A101A2010C3021022208031882
:1000E000732803197528A21F0800A10A0319A20A80
:1000F0006C280800831203132010A0108A110A1222
:020100000328D2
:00000001FF

Result: The string is thus displayed on the seven segment display.

EXPERIMENT NO. 4
Aim: Program to print a string on LCD interfaced to PIC 16F84A
Microcontroller.
Software Used: MPLAB IDE
Theory:
Liquid Crystal Display (LCD-Displaytech 162A)
LCD Displaytech 162A consists of an LCD pane, a controller IC
(KS0070B) and a back light LED.
The LCD module consists of total 16 pins in which, 2 are for
power suplly, 2 pins for backlight LED, one for contrast
adjustment, 3 pins are for control signals and 8 pins are data
pins. In order to display any data, we need to do certain
initiations. The following are the main three steps in
displaying any data in the LCD display:
i)
Initialising LCD by sequence of instructions
ii) Executing commands depending on our settings in the LCD
iii) Writing data into the DRAM locations of LCD in the Standard
Character Pattern of LCD

Program Code:
#include <system.h>
#define RW porta.0
#define RS porta.1
#define EN porta.2
void lcd_write()
//Function to enable writing on LCD
{
int i;
RW=0;
RS=0;
EN=0;
EN=1;
for(i=0;i<1024;i++);
EN=0;
for(i=0;i<10;i++);
RW=1;
for(i=0;i<10;i++);
RW=0;
}

void int_lcd()
// Function to send initialization commands to LCD
{
RW=0;
RS=0;
EN=0;
portb=0x30;
lcd_write();
portb=0x30;
lcd_write();
portb=0x38;
lcd_write();
portb=0x08;
lcd_write();
portb=0x01;
lcd_write();
portb=0x06;
lcd_write();
portb=0x0c;
lcd_write();
}
void display1(char *c)
{
int i;
portb =0x80;
lcd_write();
RW=0;
while(*c!='\0')
{
portb=*c;
RS=1;
EN=1;
for(i=0;i<1024;i++);
//Delay
EN=0;
RW=0;
RS=0;
EN=0;
c=c+1;
}
}
void display2(char *c)
{
int i;
portb =0xC0;
lcd_write();
RW=0;
while(*c!='\0')
{
portb=*c;
RS=1;
EN=1;
for(i=0;i<1024;i++);
EN=0;
RW=0;
RS=0;
EN=0;
c=c+1;
}
}

void main(void)
{
trisa=0x00;
Output
trisb=0x00;
Output

//To set direction of Port A as


//To set direction of Port B as

int_lcd();
//call Initialize LCD function
while (1)
{
display1("EMBEDDED LAB");
//call Display1 function
display2("------ PIC --------");
//call Display2 function
}
}

Hex File:
:02000000FC28DA
:0800080083120510851005119B
:100010000515A401A50104302502031D1128003097
:100020002402031C1528A51F1928A40A0319A50AD0
:100030000B280511A401A5010A3024022508031884
:10004000232803192528A51F2928A40A0319A50A6E
:100050001C280514A401A5010A3024022508031850
:10006000332803193528A51F3928A40A0319A50A1E
:100070002C2805100800831205108510051130305A
:1000800086000420303086000420383086000420AA
:1000900008308600042001308600042006308600E7
:1000A00004200C30860004200800C03086000420A4
:1000B00005100C0884008008031908000C0884004F
:1000C0000008860085140515A101A2010430220252
:1000D000031D6C2800302102031C7028A21F742805
:1000E000A10A0319A20A6628051105108510051139
:1000F00001300C07A3000D08A4000318A40A23086C
:100100008C0024088D0059288030860004200510BA
:100110000C0884008008031908000C0884000008FB
:10012000860085140515A201A30104302302031DD6
:100130009B2800302202031C9F28A31FA328A20A89
:100140000319A30A95280511051085100511013022
:100150000C07A4000D08A5000318A50A24088C00AC
:1001600025088D0088288316850186013B202030D4
:1001700096009D0041309F0042309000A000443026
:1001800092009300950045308E00910094009B00F2
:100190004C309E004D308F009C00533097009900EA
:1001A00054309A0059309800A1010030A2000E305E
:1001B0008C0022088D0084202030940098002D307F
:1001C0008E008F00900091009200930099009A0099
:1001D0009B009C009D009E009F004330970049308B
:1001E000960050309500A0010030A1000E308C0028
:0E01F00021088D005520B7288A110A12B32865
:00000001FF

Result: The LCD is thus interfaced with PIC16F84A.

EXPERIMENT NO. 5
Aim: Program to blink 8 LEDs ON and OFF interfaced to Port 1(1623) of LPC2148 ARM7 Microcontroller.
Software Used: Keil vision
Theory:
ARM(Acorn RISC Machine) is a family of instruction set
architectures for computer processors based on a reduced
instruction set computing (RISC) architecture developed by
British company ARM Holdings.
A RISC-based computer design approach means ARM processors
require significantly fewer transistors than typical CISC x86
processors in most personal computers. This approach reduces
costs, heat and power use. These are desirable traits for light,
portable,
battery-powered
devicesincluding
smartphones,
laptops, tablet and notepad computers, and other embedded
systems. A simpler design facilitates more efficient multi-core
CPUs and higher core counts at lower cost, providing improved
energy efficiency for servers.
Current cores from ARM Holdings support a 32-bit address space
and 32-bit arithmetic; the ARMv8-A architecture, announced in
October 2011, adds support for a 64-bit address space and 64-bit
arithmetic. Instructions for ARM Holdings' cores have 32-bitwide fixed-length instructions, but later versions of the
architecture also support a variable-length instruction set that
provides both 32-bit and 16-bit-wide instructions for improved
code density. Some cores can also provide hardware execution of
Java bytecodes.
Program Code:
//Program To blink LED ON and OFF
#include<LPC214x.h>
#include"timer.h"
#define led IOPIN1
#define tled IO1DIR
void delay(int x);
void main()
{
PINSEL2 = 0x00000000;
tled = 0x00FF0000;
led = 0x00000000;

// Define LPC2148 Header File


// Define LED to Port1
// Define Port1 as output

// Define port lines as GPIO


// Define P1.16 P1.23 as O/P
// Define P1.16 P1.23 as zero

while(1)
{

// Loop forever
led = 0x00FF0000;
delay(2000);
led = 0x00000000;
delay(2000);

// Turn ON P1.16 P1.23


// Turn OFF P1.16 P1.23

}
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}

Hex Code:
:020000040000FA
:1000000018F09FE518F09FE518F09FE518F09FE5C0
:1000100018F09FE50000A0E1F0FF1FE518F09FE554
:1000200040000000D4010000D0010000CC0100001D
:10003000C801000000000000C4010000C001000071
:10004000B0009FE5AA10A0E35520A0E32430A0E370
:10005000043080E50130A0E3003080E50C1080E53D
:100060000C2080E5083090E5013B13E2FCFFFF0A1D
:100070000330A0E3003080E50C1080E50C2080E523
:1000800074009FE50410A0E3041080E50210A0E3D3
:10009000001080E564009FE5DBF021E300D0A0E1E3
:1000A000040040E2D7F021E300D0A0E1040040E2E8
:1000B000D1F021E300D0A0E1040040E2D2F021E33E
:1000C00000D0A0E1800040E2D3F021E300D0A0E125
:1000D000040040E210F021E300D0A0E120009FE501
:1000E000010010E31CE09F051CE09F1510FF2FE1AD
:1000F000FEFFFFEAFEE7C04680C01FE000C01FE031
:100100009004004041010000F0000000F5000000F4
:1001100000000000000000000000000000000000DF
:1001200010B4011C07E0002200E00132041C131C83
:10013000A342FAD301390A1C002AF4D810BC704734
:10014000184806C80B1C134305D000230B70491C2C
:100150009142FBD1F5E71448C01C0323984306C81D
:100160000B1C134306D00378401C0B70491C9142B2
:10017000F9D1F1E700B500210C4801600C4A0D48A7
:1001800002600D4801600A490B4801600B48FFF707
:10019000C7FF0021084801600848FFF7C1FFF2E7E8
:1001A00000BDC046100100001801000014C002E0AC
:1001B0000000FF00188002E0108002E0D00700007D
:1001C000FEFFFFEAFEFFFFEAFEFFFFEAFEFFFFEA97
:0801D000FEFFFFEAFEFFFFEA5B
:00000001FF

Result: The string LEDs are blinked On & Off.

EXPERIMENT NO. 6
Aim: Program to toggle LEDs alternatively interfaced to Port
1(16-23) of LPC2148 ARM7 Microcontroller.
Software Used: Keil vision
Theory:
Interfacing LED with LPC2148
Flash a LED using LPC2148 Primer Board by turning ON a LED &
then turning it OFF & then looping back to START. However the
operating speed of microcontroller is very high so the flashing
frequency will also be very fast to be detected by human eye.
The ARM7 LPC2148 Primer board has eight numbers of point LEDs,
connected with I/O Port lines (P1.16 P1.23) to make port pins
high.

Circuit Diagram to Interface LED with LPC2148

Program Code:
//To blink LED Alternatively
//Here P1 is used as output port

#include<LPC214x.h>
// Define LPC2148 Header File
#define led IOPIN1
// Define LED to Port1
#define tled IO1DIR
// Define Port1 as output
void delay(int x);
void main()
{
PINSEL2 = 0x00000000; // Define port lines as GPIO
tled = 0x00FF0000;
// Define P1.16 P1.23 as O/P
led = 0x00550000;
// Define P1.16 P1.23 as zero
while(1)
// Loop forever
{
led = 0x00550000;
// Turn ON P1.16 P1.23
delay(2000);
led = 0x00AA0000;
// Turn OFF P1.16 P1.23
delay(2000);
}
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}

Hex Code:
:020000040000FA
:1000000018F09FE518F09FE518F09FE518F09FE5C0
:1000100018F09FE50000A0E1F0FF1FE518F09FE554
:1000200040000000DC010000D8010000D401000005
:10003000D001000000000000CC010000C801000059
:10004000B0009FE5AA10A0E35520A0E32430A0E370
:10005000043080E50130A0E3003080E50C1080E53D
:100060000C2080E5083090E5013B13E2FCFFFF0A1D
:100070000330A0E3003080E50C1080E50C2080E523
:1000800074009FE50410A0E3041080E50210A0E3D3
:10009000001080E564009FE5DBF021E300D0A0E1E3
:1000A000040040E2D7F021E300D0A0E1040040E2E8
:1000B000D1F021E300D0A0E1040040E2D2F021E33E
:1000C00000D0A0E1800040E2D3F021E300D0A0E125

:1000D000040040E210F021E300D0A0E120009FE501
:1000E000010010E31CE09F051CE09F1510FF2FE1AD
:1000F000FEFFFFEAFEE7C04680C01FE000C01FE031
:100100009004004041010000F0000000F5000000F4
:1001100000000000000000000000000000000000DF
:1001200010B4011C07E0002200E00132041C131C83
:10013000A342FAD301390A1C002AF4D810BC704734
:10014000184806C80B1C134305D000230B70491C2C
:100150009142FBD1F5E71448C01C0323984306C81D
:100160000B1C134306D00378401C0B70491C9142B2
:10017000F9D1F1E700B500210C4801600C4A0D48A7
:1001800002600D4801600D490B4801600C48FFF703
:10019000C7FF0C49084801600948FFF7C1FFF2E7B3
:1001A00000BDC046100100001801000014C002E0AC
:1001B0000000FF00188002E0108002E000005500FF
:1001C000D00700000000AA00FEFFFFEAFEFFFFEAE2
:1001D000FEFFFFEAFEFFFFEAFEFFFFEAFEFFFFEA87
:00000001FF

Result: The string LEDs are alternatively toggled.

EXPERIMENT NO. 7
Aim: Program to print HELLO on Seven Segment Display interfaced
to LPC2148 ARM7 Microcontroller.
Software Used: Kiel vision
Theory:
Pin Assignment with LPC2138

7-SEG
Display

7-SEG Driver

LPC2148
LINES

P1.16

B
C
D
E
F
G
DP
CL1
CL2
CL3
CL4

P1.17
P1.18
P1.19
P1.20
P1.21
P1.22
P1.23
P0.10
P0.11
P0.12
P0.13

7-SEG PWR Selection

Program Code:
/*============================================================
Program to show HELLO on Seven Segment Display
Here P1 is used as output port
P0.17-P0.19 is used to control the seven segment selection
============================================================== */

#include<LPC214x.h>
//
#define SEVEN_SEG_DISP IOPIN1
//
#define SEVEN_SEG_DISP_DIR IO1DIR //
#define SEVEN_SEG_DEV_SEL IOPIN0 //
#define SEVEN_SEG_DEV_SEL_DIR IO0DIR
void delay(int x);
void main()
{

Define LPC2148 Header File


Define LED to Port1
Define Port1 as output
Define LED to Port1
// Define Port1 as output

PINSEL2 = 0x00000000;
as GPIO
PINSEL1 = 0x00000000;
as GPIO

// Define P1.16 P1.31 port lines


// Define P0.16- P0.31

SEVEN_SEG_DISP_DIR = 0x00FF0000;
as O/P
SEVEN_SEG_DISP = 0x00000000;

port lines

//Define P1.16 P1.23


//Set P1.16-P1.31 as 0

SEVEN_SEG_DEV_SEL_DIR = 0x00FF0000; //Define P0.16 P0.23


as O/P
SEVEN_SEG_DEV_SEL = 0x00000000;
//Set P0.16-P0.31 as 0
while(1)
{

// Loop forever
//Display H on 1st segment
SEVEN_SEG_DEV_SEL = 0x00000000;
SEVEN_SEG_DISP = 0x00890000;
delay(2000);
//Display E on 2nd Segment
SEVEN_SEG_DEV_SEL = 0x00020000;
SEVEN_SEG_DISP = 0x00860000;
delay(2000);
//Display L on 3rd Segment
SEVEN_SEG_DEV_SEL = 0x00040000;
SEVEN_SEG_DISP = 0x00C70000;
delay(2000);
//Display L on 4th Segment
SEVEN_SEG_DEV_SEL = 0x00060000;
SEVEN_SEG_DISP = 0x00C70000;
delay(2000);
//Display O on 5th Segment
SEVEN_SEG_DEV_SEL = 0x00080000;
SEVEN_SEG_DISP = 0x00C00000;
delay(2000);

}
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}

Hex Code:
:020000040000FA
:1000000018F09FE518F09FE518F09FE518F09FE5C0
:1000100018F09FE50000A0E1F0FF1FE518F09FE554
:10002000400000004C0200004802000044020000B2
:1000300040020000000000003C0200003802000006
:10004000B0009FE5AA10A0E35520A0E32430A0E370
:10005000043080E50130A0E3003080E50C1080E53D
:100060000C2080E5083090E5013B13E2FCFFFF0A1D
:100070000330A0E3003080E50C1080E50C2080E523
:1000800074009FE50410A0E3041080E50210A0E3D3
:10009000001080E564009FE5DBF021E300D0A0E1E3
:1000A000040040E2D7F021E300D0A0E1040040E2E8
:1000B000D1F021E300D0A0E1040040E2D2F021E33E
:1000C00000D0A0E1800040E2D3F021E300D0A0E125
:1000D000040040E210F021E300D0A0E120009FE501
:1000E000010010E31CE09F051CE09F1510FF2FE1AD
:1000F000FEFFFFEAFEE7C04680C01FE000C01FE031
:100100009004004041010000F0000000F5000000F4
:1001100000000000000000000000000000000000DF
:1001200010B4011C07E0002200E00132041C131C83
:10013000A342FAD301390A1C002AF4D810BC704734
:100140002B4806C80B1C134305D000230B70491C19
:100150009142FBD1F5E72748C01C0323984306C80A
:100160000B1C134306D00378401C0B70491C9142B2
:10017000F9D1F1E700B500211F4801601F48016077
:100180001F4A204802602048016020480260204841
:10019000016000211E4801601E491B4801601E4885
:1001A000FFF7BEFF1D491A4801601D49164801604E
:1001B0001948FFF7B5FF1B49154801601A49124855
:1001C00001601548FFF7ACFF184911480160164956
:1001D0000D4801601048FFF7A3FF15490C48016066
:1001E0001449094801600C48FFF79AFFD1E700BDA8
:1001F000100100001801000014C002E004C002E079
:100200000000FF00188002E0108002E0088002E099
:10021000008002E000008900D0070000000002001A
:1002200000008600000004000000C7000000060077
:10023000000008000000C000FEFFFFEAFEFFFFEA2A
:10024000FEFFFFEAFEFFFFEAFEFFFFEAFEFFFFEA16
:00000001FF

Result: The Seven Segment display is thus interfaced with LPC2148


ARM7 Microcontroller.

EXPERIMENT NO. 8
Aim: Program to ptint 12345 on Seven Segment Display interface to
LPC2148 ARM7 Microcontroller.
Software Used: Kiel vision
Program Code:
/*============================================================
Program to show 12345 on Seven Segment Display
Here P1 is used as output port
============================================================== */

#include<LPC214x.h>
// Define LPC2148 Header File
#define SEVEN_SEG_DISP IOPIN1
// Define LED to Port1
#define SEVEN_SEG_DISP_DIR IO1DIR
// Define Port1 as output
#define SEVEN_SEG_DEV_SEL IOPIN0
// Define LED to Port1
#define SEVEN_SEG_DEV_SEL_DIR IO0DIR // Define Port1 as output
void delay(int x);
void main()
{
// Define P1.16 P1.31 port lines as GPIO
PINSEL2 = 0x00000000;
// Define P0.16- P0.31
PINSEL1 = 0x00000000;

port lines as GPIO

SEVEN_SEG_DISP_DIR = 0x00FF0000
SEVEN_SEG_DISP = 0x00000000;

//Define P1.16 P1.23 as O/P


//Set P1.16-P1.31 as 0

SEVEN_SEG_DEV_SEL_DIR = 0x00FF0000; //Define P0.16 P0.23 as O/P


SEVEN_SEG_DEV_SEL = 0x00000000;
//Set P0.16-P0.31 as 0
while(1)
{

// Loop forever
//Display 1 on 1st segment
SEVEN_SEG_DEV_SEL = 0x00000000;
SEVEN_SEG_DISP = 0x00F90000;
delay(2000);
//Display 2 on 2nd Segment
SEVEN_SEG_DEV_SEL = 0x00020000;
SEVEN_SEG_DISP = 0x00A40000;
delay(2000);
//Display 3 on 3rd Segment
SEVEN_SEG_DEV_SEL = 0x00040000;
SEVEN_SEG_DISP = 0x00B00000;
delay(2000);

//Display 4 on 4th Segment


SEVEN_SEG_DEV_SEL = 0x00060000;
SEVEN_SEG_DISP = 0x00990000;
delay(2000);
//Display 5 on 5th Segment
SEVEN_SEG_DEV_SEL = 0x00080000;
SEVEN_SEG_DISP = 0x00920000;
delay(2000);
}
}
void delay(int x)
{
unsigned int k,l;
for(k = x;k > 0;k--)
for(l = 0;l < x;l++);
}

Hex Code:
:020000040000FA
:1000000018F09FE518F09FE518F09FE518F09FE5C0
:1000100018F09FE50000A0E1F0FF1FE518F09FE554
:1000200040000000500200004C02000048020000A6
:100030004402000000000000400200003C020000FA
:10004000B0009FE5AA10A0E35520A0E32430A0E370
:10005000043080E50130A0E3003080E50C1080E53D
:100060000C2080E5083090E5013B13E2FCFFFF0A1D
:100070000330A0E3003080E50C1080E50C2080E523
:1000800074009FE50410A0E3041080E50210A0E3D3
:10009000001080E564009FE5DBF021E300D0A0E1E3
:1000A000040040E2D7F021E300D0A0E1040040E2E8
:1000B000D1F021E300D0A0E1040040E2D2F021E33E
:1000C00000D0A0E1800040E2D3F021E300D0A0E125
:1000D000040040E210F021E300D0A0E120009FE501
:1000E000010010E31CE09F051CE09F1510FF2FE1AD
:1000F000FEFFFFEAFEE7C04680C01FE000C01FE031
:100100009004004041010000F0000000F5000000F4
:1001100000000000000000000000000000000000DF
:1001200010B4011C07E0002200E00132041C131C83
:10013000A342FAD301390A1C002AF4D810BC704734
:100140002B4806C80B1C134305D000230B70491C19
:100150009142FBD1F5E72748C01C0323984306C80A
:100160000B1C134306D00378401C0B70491C9142B2

:10017000F9D1F1E700B500211F4801601F48016077
:100180001F4A204802602048016020480260204841
:10019000016000211E4801601E491B4801601E4885
:1001A000FFF7BEFF1D491A4801601D49164801604E
:1001B0001948FFF7B5FF1B49154801601A49124855
:1001C00001601548FFF7ACFF184911480160184954
:1001D0000D4801601048FFF7A3FF16490C48016065
:1001E0001549094801600C48FFF79AFFD1E700BDA7
:1001F000100100001801000014C002E004C002E079
:100200000000FF00188002E0108002E0088002E099
:10021000008002E00000F900D007000000000200AA
:100220000000A400000004000000B0000000060070
:10023000000099000000080000009200FEFFFFEAA5
:10024000FEFFFFEAFEFFFFEAFEFFFFEAFEFFFFEA16
:04025000FEFFFFEAC4
:00000001FF

Result: 1234 is displayed on seven segment display.

You might also like