Vous êtes sur la page 1sur 15

Shree Swami Atmanand Saraswati

Institute of Technology
(Managed by Shree Tapi Brahmcharyashram Sabha)

Electronics & Communication Department

Microprocessor & Microcontroller Interfacing


(Sub. Code : 2150907)
Practical Manual- BE-SEM-V (III YEAR)

Name:____________________________________________
Branch: __________________________________________
EnrolmentNo:_____________________________________
Exam No:__________________ Year__________________
Microcontroller

Practical No :- 1(A)
Date:-__________

Aim: - Introduction to 8051 Assembler, Simulator (Keil) and Assembler Directives.

-: KEIL Programming Tools :-

The KEIL programming tools consists of various software utilities required to


write, compile, and simulate 8051 program. Basically we divide these tool sets
into two parts.

1. KEIL-Integrated Development Environment (IDE)


2. Flash Magic utility

• KEIL-Integrated Development Environment (IDE) :-


KEIL-IDE is basically a programming tool with the help of this tool you can write
and compile your program and also generate the hex file.

• Flash Magic utility :-


Flash magic utility is used to program the internal flash of the chip.

» How to create a project in KEIL-IDE..? «

• To open “Keil uVision4” find the below icon on your PC Desktop and double
click on it.

SSASIT, SURAT EC DEPARTMENT Page 2


Microcontroller

• Click on “Project menu” then click on “New uVision Project” to create new
project.

It will show a new window. Set a “Project Name” in a new empty folder and click
on save.

SSASIT, SURAT EC DEPARTMENT Page 3


Microcontroller

• Device Target :-
From given list of device name under Data base, select NXP (founded by
Philips) ->P89V51RD2. Press OK.

Click on “NO” when asked in new window.

SSASIT, SURAT EC DEPARTMENT Page 4


Microcontroller

SSASIT, SURAT EC DEPARTMENT Page 5


Microcontroller

• Use “.c” extension


when using C
language for
programming.
• To add program
code file to the
project, right click
on “Source
Group” in “Project
window” and click
on “Add file to
Group ‘source
group” then select
specific “.a51”
code file.

SSASIT, SURAT EC DEPARTMENT Page 6


Microcontroller

• Now, write the code in newly created “.a51” or “.c” file.


• Once done, Click on Build, it will show “0 Errors, 0 warning” if code has no
logical errors.

• Then, Click on Debug option then Start debug session.

How to create Hex file:

• Select“Flash” option from Menu bar.


• Then select “Configure Flash Tools”.

SSASIT, SURAT EC DEPARTMENT Page 7


Microcontroller

• Select output option.


• Then tick in checkbox of “Create HEX File”.
• So this will generate Hex File each time we compile the program.

» Steps for Downloading HEX file to NI-51 kit «

1. Write the program code in KEIL IDE and create a Hex File.
2. Power on the kit.
3. Connect the NI-51 kit to the PC via DB9 or USB connector.
4. Open Flash Magic software. And set the option as mention below.

 COM Port : According to connecting Port


 Baud Rate : 9600
 Device : P89V51RD2
 Interface : None(ISP)
 Oscillator freq. : 12MHz

5. Give the path to flash magic for Hex File.


6. Reset the NI-51 kit once by pressing the reset key.
7. Click on “Start Program” button to start the programming.
8. Once the programming is done, Flash magic shows “Finished” message at
the left bottom corner of flash magic window.
9. Operate NI-51 kit in “Program Run mode” by pressing RESET switch.

SSASIT, SURAT EC DEPARTMENT Page 8


Microcontroller

» NI Kit-51 Practice Board «

SSASIT, SURAT EC DEPARTMENT Page 9


Microcontroller

• Introduction to NI KIT-51:-
The NI KIT-51 Microcontroller Starter Kit consists of:

• Philips flash microcontroller P89V51RD2


• A serial cable to connect a PC to The NI KIT-51
• On board power supply and mains cable
• Evaluation version of the 8051 Development tools which includes a C
cross compiler, Assembler, Debugger and off-line manual
• Philip’s Flash Magic In-System Programming tool(ISP)
• Getting Started user’s guide

• NI KIT-51 Description:
• Connect the serial cable to the 9-pin ‘D’ connector on the target board
cabinet.
• Connect the power supply cable to the 230V AC mains.
• Make sure that the DPDT switch next to keyboard is switched to PROG for
programming and RUN for execution.
• Connect the other end of the serial cable to a serial port on your PC.
• Switch on the mains. The green LED indicates that the target board is
running.

• Features :-
• Philips flash microcontroller P89V51RD2
• On chip 64KB flash memory and 1KB RAM
• ISP/IAP programming mode
• 12 clock/6 clock per machine cycle operating mode
• Crystal 11.0592 MHz
• 16 x 2 Alpha-numeric LCD Display Module
• 5 nos. of user programmable keys
• 8 nos.of LEDs on Port-1
SSASIT, SURAT EC DEPARTMENT Page 10
Microcontroller

• System reset key on board


• Toggling between PROG/RUN modes with a press of a single SPDT switch
eliminating the need for any complex changes in the hardware.
• RS232 out port for programming/pc serial communication.
• All Port pins on expansion connectors [buffer option for port pins].
• All ICs on round pin IC-SOCKETS.
• Powder coated metallic enclosure.
• Re-settable Fuse for short circuit protection and over voltage protection.
• A variety of Philips Microcontroller ICs (8051 family, DIP40 pin with flash
memory) are supported by the kit.

• Pin Diagram of P89v51RD2 :-

SSASIT, SURAT EC DEPARTMENT Page 11


Microcontroller

Connector JP1(10x2 Header)


1 VCC 2 VCC
3 P1.0 4 P1.0(B)
5 P1.1 6 P1.1(B)
7 P1.2 8 P1.2(B)
9 P1.3 10 P1.3(B)
11 P1.4 12 P1.4(B)
13 P1.5 14 P1.5(B)
15 P1.6 16 P1.6(B)
17 P1.7 18 P1.7(B)
19 GND 20 GND

Connector JP2(10x2 Header)


1 VCC 2 VCC
3 N.C. 4 N.C.
5 N.C. 6 N.C.
7 P3.2 8 P3.2(B)
9 P3.3 10 P3.3(B)
11 P3.4 12 P3.4(B)
13 P3.5 14 P3.5(B)
15 P3.6 16 P3.6(B)
17 P3.7 18 P3.7(B)
19 GND 20 GND

Connector J5(10 pin SIP) KEYBOARD AND RESET KEY


1 VCC PRESSED CONDITION GIVES 0
2 P0.0 VOLT (GND)
3 P0.1 S1 KEY0 P2.2
4 P0.2 S2 KEY1 P2.1
5 P0.3 S3 KEY2 P2.0
6 P0.4 S4 KEY3 P2.3
7 P0.5 S5 KEY4 P2.4
8 P0.6 S6 RESET
9 P0.7
10 GND
SSASIT, SURAT EC DEPARTMENT Page 12
Microcontroller

JUMPER J3(2 pin SIP) ENABLE/DISABLE LEDs


(LOGIC HIGH=LED OFF, LOGIC LOW=LED ON)
OPEN TO BYPASS THE CONNECTION OF LEDs ON PORT 1
CLOSE TO USE LEDs ON PORT 1

Connector J1(16 pin SIP )LCD connector


1 GND 9 P0.2
2 VCC 10 P0.3
3 POT 11 P0.4
4 RS(P2.7) 12 P0.5
5 R/W(P2.6) 13 P0.6
6 EN(P2.5) 14 P0.7
7 P0.0 15 A(anode)
8 P0.1 16 K(cathode)

Connector J1(16 pin SIP )7-SEGMENT DISPLAY connector


1 GND 9 P0.2
2 VCC 10 P0.3
3 POT 11 P0.4
4 SEGMENT ADDRESS-2 12 P0.5
5 SEGMENT ADDRESS-1 13 P0.6
6 SEGMENT ADDRESS-0 14 P0.7
7 P0.0 15 VCC
8 P0.1 16 GND

SSASIT, SURAT EC DEPARTMENT Page 13


Microcontroller

Practical 1(B) Date:-

AIM: Introduction to the concept of Flag Bits, Stack, RAM and ROM.

Program:
ORG 00H

//Observe Flags
//==================
// Mnemonics Comment
//1. Carry Flag after addition E1h + E2h = 1C3h
MOV A,#0E1H
ADD A,#0E2H

CLR C //CLEARING ALL BEFORE NEXT OPERATION


CLR A

//2. Aux Carry Flag after addition Ch + 5h = 11h


MOV A,#0CH
ADD A,#5H

CLR AC //clearing all before next operation


CLR A

//3. Observe Parity Flag after each instruction


// (calculate no. of 1's in different values)
MOV A,#0
MOV A,#1
MOV A,#3
MOV A,#2
MOV A,#0

//4. OV flag when multiplication is too large to fit into


register
MOV A,#0FH
MOV B,#1FH
MUL AB
//Observe Stack
//==================

SSASIT, SURAT EC DEPARTMENT Page 14


Microcontroller

//Observe RAM address 08h onwards and SP


MOV A,#10H
MOV 30H,#45H

PUSH ACC //push value of acc to stack


PUSH 30H //push value of RAM address 30h to stack

POP ACC //take top value


POP 31H

//Observe Memory
//==============

//RAM: in debug mode in Memory window, write "i:0" (without


quotes)
// to observe RAM content

//ROM: in debug mode in Memory window, write "c:0" (without


quotes)
// to observe internal ROM content / Code memory

//XROM: in debug mode in Memory window, write "x:0" (without


quotes)
// to observe external ROM content / External Code memory

End

Results:-

//attach the print out of the results over here//

Conclusion:

Signature & Remarks

SSASIT, SURAT EC DEPARTMENT Page 15

Vous aimerez peut-être aussi