0% found this document useful (0 votes)
22 views

ESLab File

Uploaded by

Dhruv Chawla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

ESLab File

Uploaded by

Dhruv Chawla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

EMBEDDED SYSTEMS

Submitted By:

ECE- 1, 7thSemester

Enrollment No. -

Class Serial No. -

Submitted To:

Ms. Deepshika Yadav

MAHARAJA SURAJMAL INSTITUTE OF TECHNOLOGY

Affiliated to Guru Gobind Singh Indraprastha University, Delhi

C-4, Janakpuri, New Delhi-58


INDEX

S.No. Name of Experiment Date Page No. Signature


EXPERIMENT-1

Objective - Introduction to 8051 Microcontroller board

Introduction:

Easy8051B development system is a full - featured development board for Atmel 8051
microcontroller. It is designed to allow students and engineers to easily test and explore the
capabilities of the 8051 microcontroller. It allows 8051 microcontroller to be interfaced with
external circuits and a broad range of peripheral d ices, making it possible for the user to
concentrate on software development.

Figurel illustrates the development board. There are identification marks beside each
component on a silkscreen. These marks describe connections to the microcontroller, operation
modes and provide additional information. Since all relevant information is provided on the
board there is almost no need for additional schematics.

1
Key Features:
1. External power supply 8-16 V AC/DC.
2. Choice between external and USB power supply.
3. Very fast and flexible USB programmer on board. The key feature is expandability.
4. DS 1820 temperature sensor allows to measure temperature with 0.50C accuracy.
5. One - RS232 port for communication with PC or another microcontroller.
6. 4-channel 12-Bit ADC (Analog to Digital Converter) with SPI interface.
7. 12-Bit DAC (Digital to Analog Convertor) with SPI interface.
8. By setting jumper in the upper position the pins of the appropriate port are set to logical
one (pull-up). By setting the jumper in the lower position, the pins are set to logical zero (pull
-down). Select pull up to provide logical zero on pin's input. Select pull down to provide
logical one on pin's input.
9. LCD connector allows easy connection of LCD in 4-bit mode.
10. Graphic LCD connector allows easy connection of GLCD or LCD in 8-bit mode.
11. Easy8051B supports microcontroller in DIP14, DIP16, DIP20, DIP40, PLCC44 and
PLCC32 package.
12. 32 buttons allow control of every pin on the microcontroller.
13. By pressing the button select high/low state of the pin.
14. See all the signals - each pin has an LED.
15. 4.096V voltage reference is used for working with A/D and D/A converter.
16. Upper four switches on the SW2 turns on/off the LEDs on PORTO, PORT l, PORT 2
and PORT 3. Select port to connect the LEDs to it. By using lower four switches select which
digit on the seven segment display are to be turned on.
17. Set LCD contrast accordingly to display characteristics.
18. Set GLCS contrast accordingly to display characteristics.
19. On-Board peripherals are connected to the microcontroller via switches on the SWI.
20. Seven segment displays multiplex mode for displaying values.
21. Reset circuit - if the reset button is pressed MCU will start executing from the beginning.
22. On-Board oscillator circuit for generating microcontrollers clock input.

2
8051 Pin Diagram:

8051 Block Diagram:

3
Experiment-02

A. Write a program to show the addition of two numbers.


Program:
MOV A, #10H
MOV B, #20H
ADD A,B
MOV P3,A

Output:
A = 30H (0b00110000)

B. Write a program to subtract two numbers.


Program:
MOV A, #20H
MOV B, #10H
SUBB A,B
MOV P3,A

Output:
A = 10H(Ob00010000)

C. Write a program to divide two numbers.


Program:
MOV A, #95H
MOV B, #10H
DIV A,B
MOV P3,A

Output:
A = 09H(0b0000l001) (Quotient)
B = 05H(0b00000l0l) (Remainder)

4
D. Write a program to multiply two numbers.
Program:
MOV A, #25H
MOV B, #65H
MUL A,B
MOV P3,A

Output:
A = 99H(0b10011001)
B = 0EH(0b0000l110)

5
Experiment-03

A. Write a program to perform multiplication without using MUL instruction.


Program:
MOV A, #00H ;
MOV B, #02H ;
AGAIN: ADD A, #03H;
DJNZ B, AGAIN;
END

Output:
A = 06H(0b00000l10)

B. Write a program to perform division without using DIV instruction.


Program:
LOOP l: MOV A, #09H
MOV R0, #09H
MOV R1, #00H
SUBB A, R0
JC LOOPI
INC R1
SJMP LOOP2
LOOP2: CPL A
INC A
MOV R2,
END

Output:
R1 = 04H(0b00000l00)
R2 = 01H(0b0000000l)

C. Write a program to add first ten natural numbers.


Program:

6
MOV A, #00H ;
MOV R2, #10H
MOV R0, #00H
AGAIN: INC R0
ADD A, R0
DJNZ R2, AGAIN
MOV P3, A
END

SOURCE FILE NAME: ASM

0000 7400 MOV A, #00H


0002 7AOA MOV R2, #10H
0004 7800 MOV R0, #00H
0006 0800 AGAIN: INC R0
0007 2800 ADD A, R0
0008 DAFC DJNZ R2, AGAIN
000A F5B0 MOV P3, A

SYSTEM TABLE
L1 0006

Output:
37 H

7
Experiment-04

A. Write a program to show alternate LED ON/OFF.


Program:
LOOP1: MOV A, #55H
MOV P0, A
ACALL DELAY
MOV A, #AAH
MOV P0, A
SJMP LOOP1
DELAY: MOV R0, #255
LOOP2: MOV R1, #13H
LOOP3: DJNZ R1, LOOP3
DJNZ R2, LOOP2
RET

B. Write a program to generate a pulse of width 5 ms.


Program:
LOOP3: MOV P3, #00H
LCALL DELAY
MOV P3, #FFH
LCALL DELAY
SJMP LOOP3
DELAY: MOV R0, #255
LOOP2: MOV R1, #13H
LOOP1: DJNZ R1, LOOP1
DJNZ R2, LOOP2
RET

C. Write a program to toggle all the bits of Pl, P2 every 1/4 of a second.
Program:
BACK: MOV A, #55H
MOV PO, A

8
MOV P1, A
MOV P2, A
LCALL DELAY
MOV A, #AAH
MOV P0, A
MOV P1, A
MOV P2, A
LCALL DELAY
SJMP BACK
DELAY: MOV R1, #255
LOOP3: MOV R2, #255
LOOP2: MOV R3, #255
LOOP1: DJNZ R3, LOOP1
DJNZ R2, LOOP2
DJNZ RI, LOOP3
RET

9
Experiment-05

A. Write a program to display data 0-9 on seven segment display.


Program:
START: MOV P0, #C0H
ACALL DELAY
MOV P0, #F9H
ACALL DELAY
MOV P0, #A4H
ACALL DELAY
MOV P0, #B0H
ACALL DELAY
MOV P0, #99H
ACALL DELAY
MOV PO, #92H
ACALL DELAY
MOV PO, #82H
ACALL DELAY
MOV PO, #F8H
ACALL DELAY
MOV PO, #80H
ACALL DELAY
MOV PO, #98H
ACALL DELAY
SJMP START
DELAY: MOV R7, #10
LOOP3: MOV R5, #255
LOOP2: MOV R6, #255
LOOP1: DJNZ R6, LOOPI
DJNZ R5, LOOP2
DJNZ RI, LOOP3
RET

10
B. Write a program to display data 0-99 on seven segment display.
Program:
ORG 0100H
MOV A, #OOH
MOV P1, A
LOOP4: CLR A
MOV DPTR, 1000H
LOOP3: MOV R1, #10
LOOP2: MOV R2, #255
LOOP l: CLR P1.1
SETB PI.0
MOV A, R1
MOVC A, @A+DPTR
MOV PO,A
ACALL DELAY
CLR P1.0
SETB P1.1
MOV A, R0
MOVC A, @A+DPTR
MOV P0,A
ACALL DELAY
DJNZ R2, LOOP1
DJNZ RI, LOOP2
DJNZ RO, LOOP3
SJMP LOOP4
DELAY: MOV R3, #255
HERE: NOP
DJNZ R3, HERE
RET
ORG 1001H
DB 098H, 080H, 0F8H, 092H, 099H, 0B0H, 0A4H, 0F9H, 0C0H

11
Experiment-06

Objective - Introduction to PIC Microcontroller Board

PIC is the name for the microchip microcontroller (MCU) family, consisting of a
microprocessor, I/O ports, timer and other internal, integrated hardware. The main advantages
of using the PIC are low external part count, a wide range of chip sizes (now from 5-pin up)
available, nice choice of compilers (assembly, C, Basic, etc) good wealth of example/tutorial
source code and easy programming. Once bought, the PIC's program memory is empty, and
needs to be programmed with code (usually HEX files) to be usuable in a circuit. For the
purpose, a wide range of simple programmer hardware docs and software
is downloadable from the net.

PIC is a family of Harvard architecture microcontrollers made by Microchip Technology,


derived from the PIC originally developed by General Instrument's Microelectronics Division.
PICS are popular with developers and hobbyists alike due to their low cost, wide availability,
large user base, extensive collection of applications notes, availability of low cost or free
development tools, and derial programming (and re-programming with flash
memory)capability.

If you are a beginner with pics, a pic 16F628 or 16F877 device is a good choice to start with.
The PIC microcontroller development platform Nvis 5002 is a very useful kit for the student.
It can be used as a teaching tool as well as a learning tool. Nvis 5002 is a single board
microcontroller training development platform configured around the most popular microchip
PIC16F877A; 8 bit single chip microcontroller. Nvis 5002 is about the architecture, instruction
set and capabilities of PIC16F877A. PIC 16F877A provides up to 8k * 14 words of flash
program memory, up to 368*8 bytes of data memory(RAM), up to 256*8 bytes of
EEPROM data memory.

The input/output structure of Nvis 5002 provides 33 I/O lines. It has 16 bit timer/counter. The
kit has onboard PIC JDM programmer to burn hex file into controller.

12
The development platform is used with different modules of interfacing given with this kit and
also used for own applications

Features:

• PIC16F877A MCIJ clocked at 4 MHz


• Expansion connectors for plug in modules and prototyping area
• On board programmer
• USB interface to PC for programming
• Every pin is marked in order to make work easier
• Master Reset/Restart Key for hardware reset
• Input/ Output & test points provided on board
• On board breadboard for connecting external components
• Self contained development platform with On board DC power supply
•CD with sample project code, Learning Material
• Programmer software & useful documents

13
Technical Specifications

• Communication : USB Port


•MCU : PIC16F877A
• Crystal Frequency : 4 MHz
• Size of Breadboard : 175 x 67 x 8 mm
• On board DC Supply : 12V and 5V
• Interconnections : FRC Cables & ICSP Connector Cable
• Programmer Unit : Ready to run programmer will program PIC Devices
• Power Supply : 230V AC 50Hz
• Dimensions : W 340 X D 260 X H 55
• Weight : 1.5 Kg (Approx)

Pin Configuration and Description PIC16F877A

14
The first pin is the master clear pin of this IC. It resets the microcontroller and is active low,
meaning that it should constantly be given a voltage of 5 V and if 0 V are given then the
controller is reset. Resetting the controller will bring it back to the first line of the program
that has been burned into the IC.

PIC 16F877A reset

A push button and a resistor is connected to the pin. The pin is already being supplied by
constant 5V. When we want to reset the IC we just have to push the button which will bring
the MCLR pin to 0 potential thereby resetting the controller.

PIN 2: RAO/ANO

PORTA consists of 6 pins, from pin 2 to pin 7, all of these are bidirectional input/output pins.
Pin 2 is the first pin of this port. This pin can also be used as an analog pin ANO. It is built in
analog to digital converter.

PIN 3: RAI/ANI

This can be the analog input 1.

PIN 4: RA2/AN2/Vref-

It can also act as the analog input2. Or negative analog reference voltage can be given to it.

PIN 5: RA3/AN3/Vref+

It can act as the analog input 3. Or can act as the analog positive reference voltage.

PIN 6: RAO/TOCKI

To timer0 this pin can act as the clock input pin, the type of output is open drain.

15
PIN 7: RA5/SS/AN4

This can be the analog input 4. There is synchronous serial port in the controller also and this
pin can be used as the slave select for that port.

PIN 8: REO/RD/AN5

PORTE starts from pin 8 to pin 10 and this is also a bidirectional input output port. It can be
the analog input 5 or for parallel slave port it can act as a 'read control' pin which will be
active low.

PIN 9: REI/WR/AN6

It can be the analog input 6. And for the parallel slave port it can act as the 'write control'
which will be active low.

PIN 10: RE2/CS/A7

It can be the analog input 7, or for the parallel slave port it can act as the 'control select' which
will also be active low just like read and write control pins.

PIN 11 and 32: VDD

These two pins are the positive supply for the input/output and logic pins. Both of them
should be connected to 5V.

PIN 12 and 31: VSS

These pins are the ground reference for input/output and logic pins. They should be
connected to 0 potential.

PIN 13: OSCI/CLKIN

16
This is the oscillator input or the external clock input bin.

PIN 14: OSC2/CLKOUT

This is the oscillator output pin. A crystal resonator is connected between pin 13 and 14 to
provide external clock to the microcontroller. 1/4 of the frequency of OSCI is outputted by
OSC2 in case of RC mode. This indicates the instruction cycle rate, crystal interfacing with
PIC 16F877A

PIN 15: RCO/TIOCO/TICKI

PORTC consists of 8 pins. It is also a bidirectional input output port. Of them, pin 15 is the
first.

It can be the clock input of timer I or the oscillator output of timer 2.

PIN 16: RC1/TIOS1/CCP2

It can be the oscillator input of timer I or the capture 2 input/compare 2 output/ PW M 2


output.

PIN 17: RC2/CCP1

It can be the capture 1 input/ compare 1 output/ PWM 1 output.

PIN 18: RC3/SCWSCL

It can be the output for SPI or 12C modes and' can be the input/output for synchronous serial
clock.

PIN 23: RC4/SD1/SD4

It can be the SPI data in pin. Or in 12C mode it can be data input/output pin.

17
PIN 24: RC5/SDO

It can be the data out of SPI in the SPI mode.

PIN 25: RC6/TX/CK

It can be the synchronous clock or USART Asynchronous transmit pin.

PIN 26: RC7/RX/DT

It can be the synchronous data pin or the USAR T receive pin.

PIN 19, 20, 21, 22, 27, 28, 29, 30.

All of these pins belong to PORTD which is again a bidirectional input and output port.
When the microprocessor bus is to be interfaced, it can act as the parallel slave port.

PIN 33-40: PORT B

All these pins belong to PORT B. Out of which RBO can be used as the external interrupt pin
and RB6 and RB7 can be used as in-circuit debugger pins.

18
Experiment-07

Objective - Write a program to interfacing of LED Bar Graph with PIC


Microcontroller

Program:

#include <PIC.h>
// CONFIG(WDTDIS & LVPDIS & PWRTEN & XT);
CONFIG(FOSC HS & PWRTE ON & WDTE OFF & CP_OFF & LVP_OFF);
/ * LED Bar Graph data and clock pin define at PORT C*/
#define ROW data RC0
#define ROW Clock RCO
#define COL data RC2
#define COL Clock RC3
#define Enable RC4

/***************************FUNCTION PROTOTYPE*********************/

void row_Clock();
void col_Clock();
void out_enable();
void N_data();
void DelayMs(unsigned int count);

/***************************MAIN PROGRAM***************************/

void main ( )
{
unsigned int k;
TRISC = 0X00;
PORTC = 0X00;

19
Enable = 0;
while(l)
{
N_data();
}
}

/****************************SUBROUTINES***************************/

/***************************N Character Display********************/

void N_data()
{
//first column
COL_data = 1;Clock(); COL_data=1;col_Clock; COL_data=1;
Col_Clock(); COL_data=1; Col_Clock(); COL_data=0; col_Clock();
ROW_data = 0; row_Clock(); ROW_data = l; row_Clock();
ROW_data = l; row_Clock(); ROW_data = l; row_Clock();
ROW data = l; row _ Clock(); ROW_data = l; row_Clock();
ROW_data = 0; row _ Clock();
out_enable();
//second column
COL data = 1; l; col_Clock();COL_data = l;col_Clock(); COL_data = 1;
col_Clock(); COL_data 0; col_Clock(); COL_data = 1 ; col_Clock();
ROW_data = 0; row_Clock();ROW_data = 0; row_Clock();
ROW_data = 0; row_Clock(); ROW_data = 0; row _ Clock();
ROW data = l; ROW_data = 0; ROW_data = 0; row_Clock();
ROW_data = 0; row_Clock();
out_enable();
//third column
COL_data = 1;col_Clock();COL_data = 1;col_Clock();COL_data=0;
col_Clock();COL_data = 1;col_Clock();COL_data = 1;col_Clock();
ROW data = 0; row Clock();ROW data = l; row Clock();
ROW_data = l; row_Clock(); ROW data = l; row Clock();
20
ROW_data = l; row_Clock(); ROW data = l; row Clock();
ROW_data = 0; row_Clock();
out_enable();
//fourth column
COL_data = l; col_Clock(); COL_data = 0; col_Clock(); COL_data 1 ;
col_Clock(); COL_data = l;col_Clock();COL_data 1 ; col_Clock();
ROW data = 0; row Clock(); ROW data = 0; row _ Clock();
ROW data = l; row Clock(); ROW data = 0; row _ Clock();
ROW data = 0; row Clock(); ROW data = 0; row _ Clock();
ROW data = 0; row Clock();
out_enable();
//fifth column
COL _ data = 1; col_Clock(); COL_data = l; col_Clock();COL_data = l;
col_Clock(); COL _ data = 1; col_Clock(); COL_data = l; col_Clock();
ROW_data = 0; row _ Clock(); ROW data = l; row _ Clock();
ROW_data = l; row _ Clock(); ROW data = l; row _ Clock();
ROW_data = l; row _ Clock(); ROW data = l; row _ Clock();
ROW_data = 0; row _ Clock();
out_enable();

/******************************Row Clock******************************/

void row_Clock()
{
ROW_Clock = 0;
ROW_Clock = l;
}

/******************************Column Clock******************************/

void col_Clock()
{

21
COL Clock = 0;
COL Clock = l;
}

/******************************Enable Pin******************************/

void out_enable()
{
Enable = 0;
DelayMs( l);
Enable = l;
DelayMs(35):
}

/ *****This function generates delay for (count X t millisecond)******/

void DelayMs(unsigned int count)


{
unsigned int Del;
while(count)
{
for(Del = O; Del++);
count--;
}
}

/******************************End******************************/

Result Analysis:

Step l:-
• Switch ON Nvis 5002
• Burn program LED Bar Graph Interface.hex file in PIC 16F877A

22
Microcontroller using Nvis 5002

Step 2:- Connections


Connect FRC cable Nvis 5002 C to LED Bar Graph Interface Block
Socket (MC04).

Step 3:-
• Place Microcontroller on ZIF Socket.
• Switch on the power supply.
Press Reset Switch.

Step 4:-
Output:
"N" will display on LED Bar Graph.

23
Experiment-08

Objective - Write a program to interfacing of 16*2 LCD with PIC Microcontroller

Program:
#include<pic.h>
_CONFIG(FOSC & PWRTE_ON & WDTE OFF & cp OFF & LVP_OFF);
#define LCD Port PORTD /*LCD data pin(DO-D7 to PortD*/
#define LCD rs RB5 /*LCD RS(Register select) pin RB5*/
#define LCD RB6 /*LCD R/.W(Read/Write) pin RB6*/
#define LCD en RB7 /*LCD Enable pin RB7*/

/******************************FUNCTION
PROTOTYPE*************************/
void LCD init();
void LCD Cmd(unsigned char);
void LCD Data(unSigned char ASCII);
void LCD Disp(unsigned char Loc, unsigned char *string);

/*****************************COMPANY
NAME********************************/

void Display_CompanyName()
{
LCD_Disp(0x80, “ Nvis”);
LCD_Disp(0x0C, “ Technologies”);
}

/*****************************DELAY********************************/

void Delay(unsigned int rTime)


{

24
unsigned int x,y;
for(x = 0; x<=rTime; x44);
for(y = 0;y+=500; y++);
}

/*****************************MAIN FUNCTION*************************/

void main()
{
TRISB = 0x00; /*PORTB initialised as output Port*/
TRISD = 0x00; /*PORTD initialised as Output Port*/
LCD_Init(); /* LCD Control command initialized*/
LCD_Cmd(0x01); /* Clear Display*/
Display_CompanyName(); /* Display Company Name*/
while(l);
}

/*****************************SUBROUTINES*************************/

/***********************Initialise LCD Subroutine*************************/

void LCD_Init()
{
LCD_Cmd(0x38); /*Function Set 8bit:2 Line 5*7 Dots*/
Delay(2);
LCD Cmd(0x0E); /*Display On Cursor Off*/
Delay(2);
LCD Cmd(0x01); /*Clear Display*/
Delay(2);
LCD Cmd(0x06); /*Entry Mode*/
Delay(2);
}

/*****************************LCD Cmds Routine*************************/


25
void LCD Cmd(unsigned char Cmd)
{
LCD_Port = Cmd; /*Write Command to LCD*/
LCD_rs = 0; /*Clear Bit P3.5*/
LCD_rw = 0, /*Clear Bit P3.6*/
LCD_en = l; /*Set Bit P3.7*/
Delay(5);
LCD_en = 0; /*Clear Bit P3.7*/
}

/*************************Write Characters to LCD***********************/

void LCD data(unsigned char ASCII)


{
LCD_Port = ASCII; /*Write Data to LCD*/
LCD_rs = l; /*Set Bit P3.5*/
LCD_rw = 0, /*Clear Bit P3.6*/
LCD_en = l; /*Set Bit P3.7*/
Delay(5);
LCD_en = 0; /*Clear Bit P3.7*/
}

/*************************Write Strings to LCD***********************/

void LCD_Disp(unsigned char Loc, unsigned char *String)


{
LCD_Cmd(Loc)
while(*String)
{
LCD_Data(*String++); /*Write Data to LCD*/
}
}

26
/*********************************End********************************/

Result Analysis:

Step l:-
• Switch ON Nvis 5002
• Burn program LED Bar Graph Interface.hex file in PIC16F877A Microcontroller
using Nvis 5002
Step 2:- Connections
• Connect FRC cable Nvis 5002 Port RD to LCD Data(MC04).
• Connect FRC cable Nvis 5002 Port RB to LCD Control(MC04).

Step 3:-
• Place Microcontroller on ZIF Socket.
• Switch on the power supply.
• Press Reset Switch.

Step 4:-
Output:
A message "Nvis Technologies" will display on LCD Screen.

27
Experiment-09

Objective - Write a program to interface seven segment display with PIC Microcontroller

Program:
#include <pic.h>
void DELAY ms(unsigned int ms_Count)
{
unsigned int i,j;
for(i=0;i<ms_Count;i4+)
{
for(j=0;j<1000;j++);
}
}

int main()
{
char seg_code[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
int i;

/* Configure the ports as output */


TRISD = 0x00;

while (l)
{
for (i = 0; i <= 9; i++) // loop to display 0-9
{
PORTD = seg_code[i];
_delay_ms(1000);
}
}
}

28
Output Analysis:

Step l: Switch ON N Vis 5002 and burn program Seven Segment Interface, hex file in PIC
16F877A microcontroller.

Step 2: Connect an FRC cable from N Vis 5002 Port RC to data pins of segment (MC04).
Also connect FRC cable from N Vis 5002 Port RD to the transistor input of the Segments
(MC04).

Step 3: Place Microcontroller on ZIF Socket, switch on the Power Supply and press Reset
button

Output: Segment will display 0 to 9 digits sequentially.

29
Experiment-10

Objective - Write a program to interfacing of hex keypad with PIC Microcontroller and
Output display on LCD

Program:

#include<pic.h>
#define _XTAL FREQUENCY 4000000

/**************Global Functions and variable Declaration*****************/


unsigned char KeyVal;
#define LCD_Port PORTD
#define LCD_rs RC5
#define LCD_RC6
#define LCD_en RC7
#define buzzer RCO
#define led RC1

#define COLO RB0


#define COLI RB1
#define COL2 RB2
#define COL3 RB3
#define ROW3 RB4
#define ROW2 RB5
#define ROWI RB6
#define ROWO RB7

/************************LCD Commands Routine**************************/


void LCD Cmd(unsigned char Cmd)
{
LCD_Port = cmd; //Write Command to LCD
LCD_rs = 0; //Clear bit P 3.6

30
LCD_rw = 0; //Clear bit P 3.7
LCD_en = 1; //Set bit P3.7
delay(2);
LCD en = 0;
}

/********************Initialize LCD Routine********************/

void LCD_Init()
{
LCD_Cmd(0x38); //Functions set 8bit: 2 lines 5X7 Dots
delay(5);
LCD Cmd(0x0C); //Display ON Cursor OFF
delay(5);
LCD Cmd(0x0l); //Clear Display
delay(5);
LCD Cmd(0x06); //Entry Mode
delay(5);

/****************Write string to LCD****************/

void LCD Display(unsigned char Loc, unsigned char *string)


{
LCD_CMD(Loc);
delay(2);
while(*string)
{
LCD data(*string++); // Write data to LCD
delay(1);
}
}

31
/**************Write character to LCD****************/

void LCD_data(unsigned char ASCII)


{
LCD_Port = ASCII; //Write data to LCD in ascii value
LCD_rs = 1, //Set bit 1)3.5
LCD_rw = 0; //Clear bit P3.6
LCD_en = l; //Set bit P3.7
delay(2);
LCD_en = 0;
}

/*******************Keypad subroutine******************/

unsigned char Scan _ Keypad(void)


{
PORTB = 0xFF;
while(l)
{
//Row0 Scan
ROW0= l;
if(COL0 != l)
{
KeyVal = ‘1’;
return KeyVal;
}
if(COLl != l)
{
KeyVal = ‘2’;
return KeyVal;
}
if(COL2 != l)
{
KeyVal = ‘3’;
32
return KeyVal;
}
if(COL3 != l)
{
KeyVal = ‘F’;
return KeyVal;
}
ROW0 = 0;

//Row1 scan
ROW1 = l;

if(COL0 != l)
{
KeyVal = ‘0’;
return KeyVal;
}
if(COLl != l)
{
KeyVal = ‘A’;
return KeyVal•,
}
if(COL2 != 1)
{
KeyVal = 'B’;
return KeyVal;
}
if(COL3 != l)
{
KeyVa1 = ‘C’;
return KeyVal;
}
ROW1 = 0;

33
//Row2 scan
ROW2 = l;
if(COL0 != l)
{
KeyVal = ‘7’;
return Key Val;
}
if(COL1 != 1)
{
KeyVal = ‘8’;
return KeyVal;
}
if(COL2 != 1)
{
KeyVal = ‘9’;
return KeyVal;
}
if(COL3 1)
{
KeyVal = ‘D’;
return KeyVal;
}
ROW2 = 0;

//Row3 scan
ROW3 = l;
if(COL0 != 1)
{
KeyVal = ‘4’;
return KeyVal;
}
if(COLl != l)
{

34
KeyVal = '5';
return KeyVal;
}
if(COL2 != l)
{
KeyVal = ‘6’;
retum KeyVal;
}
if(COL3 != l)
{
KeyVal = ‘E’;
return KeyVal;
}
ROW3 = 0;
}
return KeyVal;
}

void main()
{
OPTION REG = 0x00;
TRISC = 0x00;
TRISB = 0x0F;
TRISD = 0x00;
ADCONI = 0x06;
buzzer = 0;
led = 0;

LCD_Init(); //Initialize LCD


delay(20);
LCD_Cmd(0x01); //Clear Display
delay(20);
LCD_Display(0x83, "Key Pressed");

35
while(l)
{
scan_keypad(); //Keypad Sense
LCD_Cmd(0xC8); //if Key is presses select LCD Location
LCD_data(KeyVal); //Display Key value
}
}

Output Analysis:

Step 1: Switch ON N Vis 5002 and bum program Seven Segment Interface,hex file in
6F877A microcontroller.

step 2: Connect FRC cable from NVis 5002 Port RC with "LCD_Control" Connector of
MCIO.
Connect FRC cable from NVis 5002 Port RD with "LCD _ Data" Connector of MC10.
Connect FRC cable from NVis 5002 Port RB with "Keypad" Connector of MC10.

Output:

Initially on LCD "Key pressed" is showing. Now whenever you will press any key the same
character will display on LCD second row.

36
Experiment-11

Objective - Introduction to ARM7 Development Board

Nvis Technologies ARM 7 Development Board (Nvis 5004A) serves as a 32 bit development
platform and provides means for code development. This trainer designed for students to
explore ARM architecture and on board supporting peripherals provide an ideal platform for
extensive embedded development. The trainer provides serial and USB connection both that
can be used to download and run code on any standard IDE. This trainer allows users to
evaluate, prototype and create application specific designs.

Features:

• LPC2148 ( ARM 7 TDMI 32 Bit ) MCV clocked at 12MHz


• Expansion connectors for plug in modules and prototyping area
• 8 KB to 40 KB of on-chip static RAM and 32 KB to 512 KB of on-chip flash memory;
• 128-bit wide interface/accelerator enables high-speed 60 MHz operation
• On board Flash download utility (programmer) for Philips microcontrollers
• USB interface given for programming

37
• USB 2.0 Full-speed compliant device controller with 2 KB of endpoint RAM. In addition,
the LPC2146/48 provides 8 KB of on-chip RAM accessible to USB by DMA
• Every pin is marked in order to make work easier
• Master Reset/Restart Key for hardware reset
• On board UART I Interface
• On board ADC (10 Bit ) Interface
• On board 10-bit DAC provides variable analog output
• On board P WM Interface
• On board facility to connect J TAG debugger
• On board GPIO Connectors
• 60MHz maximum CPU clock available from programmable on-chip P LL with settling
time of loops
• On-chip integrated oscillator operates with an external crystal from I MHz to 25 MHz
• Power saving modes include Idle and Power-down
• Input/ Output & test points provided on board
• On board four external interrupts interface
• Self contained trainer with On board DC Power Supply
• CD with sample project code, Programmer software & useful documents
• Learning Material

Technical Specifications:

• MCU : LPC2148
• Crystal Frequency : 12 MHz
• LED's : 8
• ADC : Two Internal 10 bit C(14 Channel)
• DAC : Single 10 Bit Internal DAC
• Interrupts : Four External interrupts on Board
• RTC : 3.3 Volt CMOS Battery
• PWM : Three No's on Board
• GPIOs : All GPIO Pins on Board
• Communication Interfaces : USB 2.0 Full speed device control

38
• Serial Communication : RS 232 Port
• Programmer : USB
• Programmer Mode Selection : Run/ISP Switch
• Baud Rate : 9600 bps (for both USB/Serial Ports)
• Interconnections : 2 mm Patch Chords & FRC Cables
• Main Supply : 230 V ±10%, 50Hz

Block Diagram:

Pin out and description:

39
General procedure to operate ARM7 Controller Board
Equipments needed:
1. SMPS supply
2. USB cable
3. Mains Cord

Procedure:

l. Connect the USB cable (supplied along with the board) to any functional USB port of your
PC and ISP (USB) port provided on the right side of the board (in PC interface & ISP
section).
2. Change the position of Run/ISP switch placed in "PC Interface & ISP Section" block on
the ISP mode.

40
3. Turn ON switch no l, 2 placed in "PC Interface & ISP Section" block.
4. Connect the SMPS Supply to the trainer and switch 'ON' the supply.
5. Start the Philips flash utility (available in the all programs on the Start menu of Windows
OS: Start menu/A11 programs/Philips semiconductor/Flash utility/ Launch LPC210x
ISP.exe.) & select the appropriate port settings (use baud rate 9600).
6. Program LED Interface.hex files (CD-drive\On Board Experiments\LED
Interface\LED_lntarfc hex).
7. Switch 'OFF' the power supply and change the position of Run/ISP switch placed in "PC
Interface & ISP Section" block on the RUN mode.
8. Put all the switches provided in the "LED Interface" block in the ON position.
9. Switch 'On' the supply and then press reset switch.
10. Observe the result/ blinking of LED's according to program.

41
Experiment-12

Objective - Study and analysis of interfacing of LED's with ARM7 Controller

Program:

/*LED Bar Graph data and clock pin define at port B*/
#define ROW_data_Clr IO1CLR = 0x000l0000;
#define ROW_Clock_Clr IO1CLR = 0x00020000;
#define COL_data_Clr IO1CLR = 0x00040000;
#define COL_Clock_Clr IO1CLR = 0x00080000;
#define ROW_data_Set IO1SET = 0x000l0000;
#define Row_Clock_Set IO1SET = 0x00020000;
#define COL_data_Set IO1SET = 0x00040000;
#define COL_Clock_Set IO1SET = 0x00080000;
#define Enable_Clr IO1CLR = 0x00l00000;
#define Enable_Set IO1SET = 0x00l00000;

/*************************FUNCTION PROTOTYPE************************/
void row_Clock();
void col_Clock();
void out_enable();
void Display_Char N();
void DelayMs(unsigned int count);

/*************************MAIN PROGRAM************************/
int main()
{
I01DIR = 0x001F0000;
I01SET = 0x00100000;
while(l) // Loop will work for Infinite times
{
Display_Char_N();

42
}
}
/**************************SUBROUTINES***************************/
/**************************N character display***************************/

void Display_Char N()


{
//first Column
COL_data_Set; col_Clock();COL_data_Set;col_Clock();COL_data_Set;
col_Clock();COL_data_Set;col_Clock();COL_data_Clr;col_Clock();
ROW_data_Clr;row_Clock();ROW data_Set;row_CIock();
ROW_data_Set;row_Clock();ROW data_Set;row_CIock();
ROW_data_Set;row_Clock();ROW_data_Set;row_Clock();
ROW_data_Clr;row_Clock();
out_enable();
// second column
COL_data_Set;col_Clock();Col_data_Set;col_Clock();COL data Set;col_Clock();
COL_data_Clr;col_Clock();Col_data_Set;col Clock();
ROW_data_Clr;row Clock();row_data_Set;row_Clock();
ROW_data_Clr;row_Clock();row_data_Set;row_Clock();
ROW_
data_Clr;row_Clock();row_data Set;row Clock();ROW data_Clr;row_Clock();
out_enable();
//third column
COL data_Set;col_Clock();COL data_Set;col_Clock();COL data_Clr;
col_Clock();COL data_Set;col_Clock();COL_data_Set;col_Clock();
ROW_data_Clr;row_Clock();row_data_Clr;row_Clock();
ROW_data_Clr;row_Clock();row_data_Set; row_Clock();
ROW_data_Clr;row_Clock();row_data_Clr;row_Clock();ROW_data_Clr;
row_Clock();
out enable();
//fouth column
COL_data_Set;col_Clock();COL_data_Clr;col_Clock();
COL_data_Set;col_Clock();COL_data_Set;col_Clock();COL_ data_Set;col_Clock();
43
ROW_data_Clr;row_Clock();ROW_data_Clr;row_Clock();
ROW_data_Set;row_Clock();ROW_data_Clr;row_Clock();
ROW_data_Set;row_Clock();ROW_data_Clr;row_Clock(); ROW_data_Set;row_Clock();
out_enable();
//fifth column
COL data_Clr;col_Clock();COL_data_Set;col_Clock();Col_data_Set;col_Clock();
COL_data_Set;col_Clock();Col_data_Set;col_Clock();
ROW_data_Clr;row_Clock();Row_data_Set;row_Clock();ROW_data_Set;
row Clock(); ROW_data_Set; row_Clock(); ROW data_Set;row_Clock();
Row_data_Set; row_Clock(); ROW_data Clr;row_Clock();
out_enable;
}

/******************Row Clock*******************/
Void row_Clock()
{
ROW_Clock_Clr;
Row_Clock_Set;
}

/******************Column Clock*******************/
void col_Clock()
{
COL_Clock_Clr;
COL_Clock_Set;
}

/******************Enable pin*******************/
Void out_enable()
{
Enable_Clr;
DelayMs(200);
Enable_Set;

44
DelayMs(50);
}

/*********This Function generated delay for(count X 1millisecond)*********/


Void DelayMs(unsigned int count)
{
unsigned char Del;
while(count)
{
for(Del=0;Del<=10;Del++);
count--;
}
/**************************END************************/

Result Analysis:
Step 1:-
• Switch ON Nvis 5004A
• Turn the toggle switch in ISP Mode
• Bum program LED Bar Graph Interface.hex file in LPC2148 Microcontroller
• Turn the toggle switch in RUN Mode

Step 2:-
Connections:
Connect FRC cable Nvis 5004A Pl.16-PI.l.23 LED Bar Graph Interface
Block Socket(MC04)

Step 3:-
Turn on the supply
Press Reset Switch

step 4:-
OUTPUT
"N" will display on LED Bar Graph

45
Experiment-13

Objective - Study and analysis of interfacing of LCD with ARM7 Controller

Program:

#include<lpc214x.h>

/********************FUNCTION PROTOTYPES************************/

void LCD_Init(void); /*LCD Init Function*/


void LCD_Delay(unsigned int); /*LCD LCD_Delay Function*/
void LCD_Cmd(unsigned long); /*LCD Command Function*/
void LCD_Data(unsigned long); /*LCD Data Function*/
void LCD_Disp(unsigned char,unsigned char,unsigned char *);
/*LCD Display Function*/

/********************LCD PIN OUT DESCRIPTION************************/

#define RS_Set IO1SET = 0x20000000;


#define RS_Clr Io1CLR = 0x20000000;
#define EN_Set IO1SET = 0X80000000;
#define EN_Clr IO1CLR = 0x80000000;

/*******************************DELAY*******************************/

LCD Delay(unsigned int Time)


{
unsigned int i,j;
for(i=0;i<=Time;i++)
for(j=0;j<1275;j++);
}

46
/********************************************************************
*LCD initialization
*Description: This function initialises the LCD module by the following steps:
* l. Set 8BIT: 2 Line 5x7 Dots (0x38)
* 2. Display On curser Off (0x0C)
* 3. Clear Display (0x0l)
* 4. Entry Mode (0x06)
*Note: This function should be called once before any of the other functions
********************************************************************/

void LCD_Init(void)
{
LCD_Cmd(0x38); /*Function Set 8bit: 2 Line 5x7 Dots*/
LCD_Cmd(0x0C); /*Display On curser Off*/
LCD_Cmd(0x0l); /*Clear Display*/
LCD_Cmd(0x06); /*Entry Mode*/
}

/********************************************************************
*LCD Command (Shifting is done here)
*Description: This function initialises the LCD Module by the following steps:
*Note: Here we have selected Pin P1.16 to P1.23 as LCD data line,
*that's why we need to shift data by 16
********************************************************************/

void LCD_Cmd(unsigned long Cmd)


{
Unsigned long Shifted_ed_Cmd;
Shifted_Cmd = Cmd << 16; /*We have selected Pl.16 to P1.23 as LCD data
line */
RS_Clr; /*RS Pin Clear*/
LCD_Delay(10); /*LCD_Delay for Clock*/
EN_Set; /*Enable Pin SET*/

47
LCD_Delay(10);
IO1SET = Shifted_Cmd; /*Write Command Value to LCD Data Pin*/
LCD_Delay(20); /*LCD_Delay for enable Clock*/
EN_Clr; /*Enable Pin Clear*/
LCD_Delay(10);
IO1CLR = 0x00FF0000; /*Clear All pins of LCD*/
}

/********************************************************************
*
*LCD Data
*
*Description: This function initialises the LCD module by the following steps:
* 1.Set Register select (RS) to high
* 2.Set enable pin high to low
* 3.Send data to LCD data pin
*Note: Here we have selected Port 1 Pin P1.16 to P1.23 as LCD data line
********************************************************************/

void LCD_Data(unsigned long Data)


{
RS_Set; /*RS Pin Clear*/
LCD_Delay(10); /*LCD_Delay for Clock*/
EN_Set; /*Enable Pin SET*/
LCD_Delay(10);
IO1SET = Data << 16; /*Write Command Value to LCD Data Pin*/
LCD_Delay(20); /*LCD Delay for enable Clock*/
EN_Clr; /*Enäble Pin Clear*/
LCD_Delay(10);
IO1CLR = 0x00FF0000; /*Clear All pins of LCD*/
}

/********************************************************************

48
***LCD Display
*Description: This function initialises the LCD module by the following steps:
* l. Send Loc from where data needs to write
* 2. Display string on LCD
********************************************************************/

void LCD_Disp(unsigned char Loc, unsigned char *String)


{
LCD_Cmd(Loc); /*Send Command to LCD*/
while(*String) /*Wait until Null char come*/
{
LCD_Data(*String++); /*Write data to LCD*/
IO1CLR = 0x00FF0000; /*Clear All pins of LCD*/
}
}

/*****************************MAIN ROUTINE******************************/

int main(void)
{
IO1DIR = 0xFFFF0000; /*Set LCD pin as output*/
LCD_Init(); /*Initialise LCD*/
while(l)
{
LCD_Disp(0x80,‘ Nvis ‘); /*Display "NVIS"*/
LCD_Disp(0xC0, ‘ Technologies ‘ ); /*Display "Technologies’’*/
}
}

/************************************END*********************************/

49
Result Analysis:
Step l:-
• Switch ON Nvis 5004a
• Turn the toggle switch in ISP Mode
• Burn Program "LCD Interface.hex" file in LPC2148 Microcontroller
using Nvis 5004A
• Turn the toggle switch in RUN Mode

Step 2:-
Connection:
• Connect P1,24-P1.31 of " Nvis 5004A board" to "LCD_Control"
connector present on the board "MC04 Display Module" Module.
• Connect Pl.16-Pl.23 of "Nvis 5004A board" to "LCD_Data"-connector
present on the board "MC04 Display Module" Module.

step 3:-
OUTPUT:
"Nvis Technologies" Display on 16x2 LCD Display.

50
Experiment-14

Objective- Study and analysis of Seven Segment Display Interface with ARM 7
Controller.

Program:

#include<lpc214x.h>

/*********Delay Description: This function provide Delay in Milliseconds*********/


void MSdelay(unsigned int rtime)
{
unsigned int i,j;
for(i=0;i<=rtime;i++)
for(j=0;j<1275;j++);
}

/*****************************Main Function*****************************/
int main(void)
{
IO0DIR = 0x00000FFF; /*Define Port as Output*/
IO0SET = 0x00000F00; /*Set all Control Pins*/
while(l)
{
IO0SET = 0x3F; /*Display '0' on Seven Segment*/
MSdelay(2000); /*Delay — A small pause to display*/
IO0CLR = 0x3F; /*Clear '0' on Seven Segment*/
IO0SET = 0x06;
MSdelay(2000);
IO0CLR = 0x06;
IO0SET = 0x5B;
MSdelay(2000);
IO0CLR = 0x5B;

51
IO0SET = 0x4F;
MSdelay(2000);
IO0CLR = 0x4F;
IO0SET = 0x66;
MSdelay(2000);
IO0CLR = 0x66;
IO0SET = 0x6D; /*Display '5' on Seven Segment*/
MSdelay(2000); /*Delay — A small pause to display*/
IO0CLR = 0x6D; /*Clear '5' on Seven Segment*/
IO0SET = 0x7D;
MSdelay(2000);
IO0CLR = 0x7D;
IO0SET = 0x07;
MSdelay(2000);
IO0CLR = 0x07;
IO0SET = 0x7F;
MSdelay(2000);
IO0CLR = 0x7F;
IO0SET = 0x6F;
MSdelay(2000);
IO0CLR = 0x6F;
}
}

/***********************************End*********************************/

Result Analysis:
Step l:-
Switch ON Nvis 5004A
Turn the toggle switch in ISP Mode
Burn Program "LCD Interface.hex" file in LPC2148 Microcontroller
using Flash Utility
Turn the toggle switch in RUN Mode

52
Step 2:-
Connection:
Connect an FRC cable from Nvis 5004A port P0.0-P0.7 to (7-Seg_Data)
MC04
Connect another FRC cable from Nvis 5004A port P0.8-P0.15 to (7-
Seg_Control) MC04

Step 3:-
OUTPUT: 0000 to 9999 all four seven segment display.

53

You might also like