Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

MPMC Sample File

Download as pdf or txt
Download as pdf or txt
You are on page 1of 64

MAHARAJA SURAJMAL INSTITUTE OF

TECHNOLOGY

Microprocessors and Microcontrollers Lab

(ETEE 358)

6th Semester

2017 - 2021

Submitted By: Submitted To:


Ankit Satyawali Dr. Meena Rao
Enroll. No: 00915002717 Assosciate Professor
Class: CSE – 1(A) CSE Department
Serial No: 05
INDEX

S No. Experiment Name


1 Introduction to 8085 microprocessor kit and write a program to add and subtract
two 8 bit numbers with and without carry.
2 Write a program to
a) Find largest/smallest number in a given string.
b) Find even/odd number in a given string.
c) Find the number of positive/negative number in a given string.

3 Introduction to 8086 microcontroller kit and write a program to perform following


arithmetic operation(using 8086)
a) Addition of two 16 bit numbers.
b) Addition of two numbers with carry
c) Subtraction of two numbers.
4 Write a program for Multiplication of two 8 bit numbers in 8086.
5 Write a program to generate factorial of a number
6 Write a program to generate Fibonacci series
7 Introduction to 8051 microcontroller kit and write a program to perform following
arithmetic operation(using 8051)
a) Addition of two numbers.
b) Subtraction of two numbers.
c) Division of two numbers.
d) Multiplication of two numbers.
8 Write a program to toggle pins on the board(using timer)
a) Write a program to toggle P1.5.
b) To toggle whole Port.
c) To show alternate LED ON/OFF in rotation.
d) To show running pattern on LEDs.
9 Write a program to implement Interrupt INT0, INT1. Glow all LEDs of P0 when
INT0 is activated & glow all LEDs of P2 when INT1 is activated.
Experiment No. 7
Aim: Introduction to 8051 microcontroller kit and write a program to perform following
arithmetic operation(using 8051)
e) Addition of two numbers.
f) Subtraction of two numbers.
g) Division of two numbers.
h) Multiplication of two numbers.
Apparatus Used: 8051 microcontroller kit.

INTRODUCTION:
Easy8051B development system is a full-featured development board for Atmel 8051
microcontrollers. It is designed to allow students and engineers to easily test and explore the
capabilities of the 8051 microcontrollers. It also allows 8051 microcontrollers to be interfaced
with external circuits and a broad range of peripheral devices, making it possible for the user to
concentrate on software development.
Figure 1 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.

Development Board Dimensions

Width 228 mm 8.98 Inches

Height 188 mm 7.40 Inches


Fig.1: 8051 Development Board.

KEY FEATURES
1. External power supply 8-16 V AC/DC.
2. Choose between external and USB power supply.
3. Very fast and flexible USB programmer on board. The key feature is expandability. By
downloading new software, you will be able to program new MCUs in coming years.
4. DS1820 temperature sensor allows to measure temperature with 0.5°C accuracy.
5. One RS232 port for communication with PC or another microcontroller.
6. 4-channel 12-Bit ADC (Analog-to-Digital Converter) with SPI interfaces.
7. 12-Bit DAC (Digital-to-Analog Converter) 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 jumper in the lower postion, the pins are set to logical zero (pull-down).
Select pull up to provide logical zero on pin’s inputs. Select pull down to provide logical one on
pin’s inputs
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 microcontrollers 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 pins.
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 Converters.
16. Upper four switches on the SW2 turns on/off the LEDs on PORT0, PORT1, PORT2 and PORT3.
Select port to connect LEDs to. By using lower four switches select which digit on seven
segment display are to be turned on.
17. Set LCD contrast according to display characteristics
18. Set GLCD contrast according to display characteristics.
19. On-Board peripherals are connected to the microcontroller via switches on the SW1.
20. Seven segment displays in 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 microcontroller’s clock input.

SWITCHES
The Easy8051B development board features a number of peripheral devices. In order to enable
them before programming, the appropriate jumpers or switches have to be properly set. Switches
are devices that have two positions - ON and OFF, which have a role to establish or break
connection between two contacts. The Easy8051B development board has two groups of
switches.
The first group, SW1, is used to enable SPI communication for interfacing with A/D and D/A
Converters and for connecting ADC CS (Chip Select) and DAC CS to the microcontroller pins.
It is also used for RS-232 communication.
Fig.2: Group of 8 Switches.
The upper four switches (1, 2, 3, 4) on the SW2 are used to enable LEDs connected to PORT0,
PORT1, PORT2 and PORT3/PORT4. For example, if the switch enabling PORT1 is OFF, all
PORT1 LEDs will be turned off. The lower four switches on the SW2 are used to enable the 7-
segment displays. If there is no need to use the 7-segment displays in a project, these switches
should be turned off.

JUMPERS
Jumpers, like switches, can break or establish connection between two points. Under the plastic
cover of a jumper there is a conductive contact which establishes connection when the jumper is
placed over two pins.
Jumpers are commonly used as selectors between two possible connections via three pin
connector. As illustrated in Figure 4, the connector in the middle can be connected to the left or
right pin, depending on the jumper’s position.
Fig.3: Jumpers as Multiplexers.

MCU SOCKETS
Easy8051B is delivered with the AT89S8253 40-pin microcontroller. The users can remove this
one and fit a different microcontroller in DIP40, DIP20, DIP16, DIP14, PLCC44 or PLCC32
packages of an adequate pinout.
Fig.4: MCU Socket.
Note: Since all packages have parallel connections, there must not be more than one
microcontroller on the board at a time.
Microcontroller’s pins are routed to various peripherals as illustrated in Figure 6. All ports are
directly connected to Direct Port Access connectors. Such connectors are normally used for
connecting external peripherals to the board as well as for connecting digital logic probes for
testing and measuring.
All ports are connected to LEDs; push buttons switches and pull-up/down resistors, which allow
easy monitoring and testing of digital pin state.
Some pins are connected to other peripherals such as DS1820 temperature sensor, RS-232
communication, 7-segment displays, LCD, etc.
Fig.5: System Connection.

POWER SUPPLY
Easy8051B has two kinds of power supply- regulated supply from the USB cable (by default)
and external power supply. In case of the USB power supply, the system should be connected to
a PC using the USB programming cable, while the jumper J11 should be set in the right-hand
position.
In case of the external power supply, the Easy8051B board produces +5V using an LM7805
voltage regulator. The external power supply can be AC or DC. Power supply voltage can be in
the range of 8-16V and the jumper J11 should be set in the left-hand position. Figure 8 illustrates
USB and external power supply connectors.

Fig.6: Power Supply Schematic.

ON-BOARD USB 2.0 PROGRAMMER


There is no need to use external equipment during programming because the Easy8051B
development system has its own on-board USB 2.0 programmer.
All you need to do is to connect the system to PC using the USB cable. Then, load your program
into the microcontroller via the 8051Flashprogramming software supplied with the board.
Fig.7: On-Board USB Programmer.
Note: There is no need for manually resetting MCU after programming. The programmer will
reset the MCU automatically.

Fig.8: Programmer Schematic.


mikroICD (IN CICUIT DEBUGGER)
mikroICD is a highly effective tool for Real-Time debugging on hardware level. The mikroICD
debugger enables you to execute a program on the 8051 microcontroller and view variable
values, Special Function Registers (SFRs) and EEPROM while the program is running.
mikroICD can be used with any of MikroElektronika’s compilers for 8051 (mikroC, mikroBasic
or mikroPascal). You just have to select the appropriate build type (Release or ICD Debug),build
the project, program the MCU, select the appropriate debugger (mikroICD Debugger) and that’s
all.
The mikroICD debugger uses the 8051Flash programmer to communicate with the compiler and
supports common debugger commands:

Start Debugger [F9]


Run/ Pause Debugger [F6]
Toggle Breakpoints [F5]
Run to cursor [F4]
Step Into [F7]
Step Over [F8]
Flush RAM [F2]
Stop Debugger [Ctrl+F2]

Fig.9: microICD.
OSCILLATOR
The Easy8051B development board has on-board oscillator circuit for generating
microcontroller’s clock input. Within the 8051Flash programmer, either internal RC oscillator or
external clock can be selected. External oscillator is connected to the XTAL1 pin on the
microcontroller.

Fig.10: Oscillator.
LEDs
Light Emitting Diodes (LEDs) are the most commonly used components, usually for displaying
pin’s digital state. Easy8051B has 38 LEDs connected to the microcontroller’s PORT0, PORT1,
PORT2, PORT3 and PORT4.

Fig.11: light Emitting Diodes.


Each group of eight LEDs can be enabled or disabled by using the SW2. Figure 15 illustrates the
connection between LEDs and PORT0 on the microcontroller. A resistor is used in series with
LED to limit the LED's current. In this case the resistor's value is 1K.
The LEDs are enabled when the corresponding switch on the SW2 is on. When enabled, LEDs
will display the state of the corresponding microcontroller pin; otherwise the LEDs are always
off, no matter what the port state is, as no current can flow through them.
Fig.12: LED Schematic.
PUSHBUTTON SWITCHES
Easy 8051B has 32 push buttons, which can be used to change states of digital inputs on the
microcontroller's ports. There is also one switch that acts as a RESET. Its schematic is shown in
Figure 13.
Fig.13: RESET switch.

Fig.14: Reset Switch Schematic.


Fig.15: Pushbutton Switches.
The connection between buttons and PORT0, PORT1, PORT2 and PORT3 is shown in Figure.
16. The jumper J6 determines whether a button press will bring logical zero or logical one to the
appropriate pin.
When the button is not pressed, pin state is determined by the pull-up or pull-down port jumpers.
In Figure, J6 is connected to +5V, therefore a button press will bring logical one to the
appropriate pins.
Fig.16: Button Schematic.
In Figure 17 the J1 jumper is set to pull-up. Therefore, when the button is released, pull-up
resistor pulls the microcontroller’s P0.2 pin to +5V.
By pressing the button, the port pin is connected to ground (J6 is in the lower position).
Thus, only when the button is pressed the pin state is logical zero. Otherwise, the pin state is
always logical one.
In Figure 18 the J1 jumper is set to pull-down. Therefore, when the button is released, pull-down
resistor pulls the microcontroller’s P0.2 pin to 0V.
By pressing button, the port pin is connected to +5V (J6 is in the higher position).
Thus, only when the button is pressed the pin state is a logical one. Otherwise, the pin state is
always logical zero.

Fig.17: Button with Pull up resistors.


Fig.18: Button with Pull down resistor.
7-SEGMENT DISPLAYS
Easy8051B has four 7-segment displays in multiplex mode. Data lines are connected to PORT0,
while each display is enabled through the lower four bits of PORT1.

Fig.19: 7 Segment Segment display Schematic.


GRAPHIC LCD
The graphic LCD (GLCD) allows advanced visual messages to be displayed. While a character
LCD can display only alphanumeric characters, a GLCD can be used to display messages in the
form of drawings and bitmaps. The most commonly used graphic LCD has the screen resolution
of 128x64 pixels. The GLCD’s contrast can be adjusted using the potentiometer P1placed on the
right of the GLCD.

Fig.20: GLCD Schematic.


Note: Do not connect LCD and GLCD at the same time because they are sharing the same data
and control pins.
LCD 2X16
A standard character LCD is probably the most widely used data visualization component.
Normally, it can display two lines of 16 alphanumeric characters, each made up of 5x8 pix-2els.
The character LCD communicates with the microcontroller via 4-bit data bus. The connection to
the microcontroller is shown in Figure 27 where there are only four data lines. It is important to
know that the LCD should be placed or removed from Easy8051B only when the power is off.

Fig.21: LCD2×16 in 4 bit mode.


Note: Do not connect LCD and GLCD at the same time because they are sharing the same data
and control pins.
RS-232 COMMUNICATION
RS-232 communication enables point-to-point data transfer. It is commonly used in data
acquisition applications, for the transfer of data between the microcontroller and PC. Since the
voltage levels of the microcontroller and PC are not directly compatible with each other, a level
transition buffer such as the MAX232 must be used.
Fig.22: RS-232 Connections.
In order to provide a more flexible system, the microcontroller is connected to the MAX232
through switches 6 and 7 on the SW1. These switches must be enabled.
Connection between microcontroller and a PC

Fig.23: 8051 development Board


DS1820 DIGITAL THERMOMETER
DS1820 digital thermometer is convenient for environmental temperature measurement, having
the temperature in the range of -55°C to 125°C with +/-0.5°C accuracy. It must be placed
correctly in the 3-pin socket provided on Easy8051B, with its rounded side to the right edge of
the board (see Fig. 33) otherwise the DS1820 could be permanently damaged. DS1820’s data pin
can be connected to either P3.3 or P1.2 pin, which is determined by the jumper J7.

Fig.24: DS-1820 Schematic.

A/D CONVERTER
The Easy8051B development system has a 4-channel 12-Bit A/D Converter (Analog-to-Digital
Converter) with SPI serial interface (MCP3204).
In order to use it, switches 1,2,3 and 4 on the SW1 must be enabled. In order to simulate an
analog input, potentiometer P3 should be connected to one of four analog inputs through the
jumper group J9. MCP1541 is used as a 4.096V voltage reference for ADC.
Fig.25: A/D Converter.

Fig.26: 4.096 reference voltage schematic.


The jumper J10 selects VREF voltage for analog to digital converter (ADC) and digital to analog
converter (DAC). It can be 4.096 or VCC.
Fig.27: A/D converter Schematic
.
D/A CONVERTER
The Easy8051B development system has a 12-Bit D/A Converter (Digital-to-Analog Converter)
with SPI serial interface (MCP4921). In order to use it, switches 1, 3 and 5 on the SW1 must be
enabled. Analog voltage output from DAC chip is connected to the CN10 connector and it is in
the range of 0V to Vref. MCP1541 is used as a 4.096V voltage reference for DAC.
Fig.28: D/A converter schematic.

DIRECT PORT ACCESS


All microcontroller input/output pins can be accessed via connectors placed along the right side
of the board. For each of PORT0, PORT1, PORT2, PORT3 and PORT4 there is one 10-pin
connector providing VCC, GND and eight port pins.
Fig.29: Direct port access connectors.
These connectors can be used for system expansion with external boards such as Serial Ethernet,
Compact Flash, MMC/SD, ADC, DAC, CAN, RTC, RS-485, etc. Ensure that the on-board
peripherals are disconnected from the microcontroller by setting the appropriate jumpers and
switches, while external peripherals are using the same pins. The connectors can also be used for
attaching logic probes or other test equipment.

Fig.30: Example: How to connect external peripheral.


Fig.31: Port 2 Connection.

a. Write a program to add two numbers.


Assembly Code:-
0000 7407 mov a,#07h
0002 75F006 mov b,#06h
0005 25F0 add a,b
0007 F580 mov p0,a

b. Write a program to subtract two numbers.

Assembly Code:-
0000 7407 mov a,#07h
0002 75F006 mov b,#06h
0005 25F0 subb a,b
0007 F580 mov p0,a
c. Write a program to divide two numbers
Assembly Code:-
0000 7407 mov a,#07h
0002 75F006 mov b,#06h
0005 84 div ab
0006 F580 mov p0,a
0008 85F090 mov p1,b

d. Write a program to multiply two numbers


Assembly Code:-
0000 7407 mov a,#07h
0002 75F006 mov b,#06h
0005 84 mul ab
0006 F580 mov p0,a
0008 85F090 mov p1,b
Experiment No. 8
Aim: Write a program to toggle pins on the board(using timer)
a) Write a program to toggle P1.5.
b) To toggle whole Port.
c) To show alternate LED ON/OFF in rotation.
d) To show running pattern on LEDs.

a). Write a program to toggle a single bit.

Assembly Code:-
0000 758901 mov tmod, #01H
0003 D293 setb p1.3
0005 758C00 l1: mov th0,#00h
0008 758A00 mov tl0, #00h
000B D28C setb tcon.4
000D 308DFD again: jnb tcon.5,again
0010 C28C clr tcon.4
0012 C28D clr tcon.5
0014 B293 cpl p1.3
0016 80ED sjmp l1

b). Write a program to toggle whole port

Assembly Code:-
0000 758901 mov tmod, #01H
0003 7400 mov a,#00h
0005 758C00 l1:mov th0, #00h
0008 758A00 mov tl0,#00h
000B F590 mov p1, a
000D D28C setb tcon.4
000F 308DFD again: jnb tcon.5,again
0012 C28C clr tcon.4
0014 C28D clr tcon.5
0016 F4 cpl a
0017 80EC sjmp l1

c). Write a program to show alternate LED ON/OFF in Rotation.

Assembly Code:-
0000 758901 mov tmod, #01H
0003 74FE mov a, #0feh
0005 758C00 l1: mov th0, #00h
0008 758A00 mov tl0, #00h
000B 23 rl a
000C F590 mov p1, a
000E D28C setb tcon.4
0010 308DFD again:jnb tcon.5,again 0013
C28C clr tcon.4
0015 C28D clr tcon.5
0017 80EC sjmp l1

d). WAP to show running pattern on LED’s.

Assembly Code:-
0000 758901 MOV TMOD,#01H
0003 C290 BACK: CLR P1.0
0005 1135 ACALL L1
0007 D290 SETB P1.0
0009 C291 CLR P1.1
000B 1135 ACALL L1
000D D291 SETB P1.1
000F C292 CLR P1.2
0011 1135 ACALL L1
0013 D292 SETB P1.2
0015 C293 CLR P1.3
0017 1135 ACALL L1
0019 D293 SETB P1.3
001B C294 CLR P1.4
001D 1135 ACALL L1
001F D294 SETB P1.4
0021 C295 CLR P1.5
0023 1135 ACALL L1
0025 D295 SETB P1.5
0027 C296 CLR P1.6
0029 1135 ACALL L1
002B D296 SETB P1.6
002D C297 CLR P1.7
002F 1135 ACALL L1
0031 D297 SETB P1.7
0033 80CE SJMP BACK
0035 758C12 L1: MOV TH0,#12H
0038 758A55 MOV TL0,#55H
003B D28C SETB TCON.4
003D 308DFD HERE: JNB TCON.5,HERE
0040 C28C CLR TCON.4
0042 C28D CLR TCON.5
0044 22 RET
Experiment No. 9
Aim: Write a program to implement Interrupt INT0, INT1. Glow all LEDs of P0 when INT0 is activated
& glow all LEDs of P2 when INT1 is activated.

Assembly Code:-
ORG 00H
LJMP main ORG
0003H MOV P0,
#00H RETI
ORG 0013H MOV
P2, #00H RETI
main: ORG 30H MOV
IE, #85H
Here: SJMP Here

You might also like