Microcontroller and Embedded System Designs (EE-328-F) : Lab Manual Vi Semester
Microcontroller and Embedded System Designs (EE-328-F) : Lab Manual Vi Semester
Microcontroller and Embedded System Designs (EE-328-F) : Lab Manual Vi Semester
VI SEMESTER
LIST OF EXPERIMENTS
SR.
NAME OF EXPERIMENT PAGENO
NO.
10-13
Write an ALP to generate square of 10Khz using Timer 0.
2
Write an ALP to interface seven segment with 8051 and display 0-9 on it.
4 19-21
EXPERIMENT 1
AIM: To study development tools/environment for ATMEL/PIC microcontroller programs and
architecture.
THEORITICAL CONCEPT:
• Create a New folder on the desktop for saving the contents of the program.
• Double click on the icon of Keil.
• Select the device for the target (Select Atmel → Select 89C52 →Ok →No)
• Go in the project menu and click on μVision Project after this an edit window will
appear on desktop.
• Write the desired program in the editing window up to end.
• Right click on source group and select remove start up in project workspace.
• Go in the file menu and click on save as and save the program with the extinction .asm on
desktop in the new folder.
• Right click on source group → Select add file to group → All file → Select file .asm →
Select Add.
• Now go in the project menu and click on options for the target “Target1”.
• Update the frequency value (eg. 11.0592) and click on output and enable the following.
• ®Create Executable
• √ or Ok –Debug info
• Select Create Hex file
• Select Browse info
Now click on Ok
• Go in the project menu and click on built target.
• Go in the project menu and click on Rebuild target.
4 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
A microcontroller is a single chip microcomputer with on board program ROM and I/O that can
be programmed for various control functions. Unlike a general purpose computer, which also
includes all of these components, a microcontroller is designed for a very specific task to control
a particular system.
The AT89C52 is a low power, high performance CMOS 8
bit microcomputer with 8K bytes of Flash Programmable and Erasable Read Only Memory. The
on chip flash allows the program memory to be reprogrammed in system or by a conventional
non-volatile memory programmer. The AT89C52 provides 256 Bytes of RAM, 32 I/O lines,
three 16 bit timer/counters, and six vector two levels interrupt.
with code (usually HEX files) to be usable 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 PIC1650 originally developed by General Instrument's Microelectronics
Division.
The PIC architecture is distinctively minimalist. It is characterized by the following features:
• Separate code and data spaces (Harvard architecture)
• A small number of fixed length instructions
• Most instructions are single cycle execution (4 clock cycles), with single delay cycles
upon branches and skips A single accumulator (W), 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 fairly small amount of addressable data space (typically 256 bytes), extended through
banking
• Data space mapped CPU, port, and peripheral registers
• The program counter is also mapped into the data space and writable (this is used to
synthesize indirect jumps).
Unlike most other CPUs, there is no distinction between "memory" 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.
PIC16F877A Specifications and Architecture:
High-Performance RISC CPU:
• Only 35 single-word instructions to learn
• All single-cycle instructions except for program Branches, which are two-cycle
• Operating speed : DC–20 MHz clock input DC–200 ns instruction cycle
• Up to 8K x 14 words of Flash Program Memory, Up to 368 x 8 bytes of Data Memory
(RAM), Up to 256 x 8 bytes of EEPROM Data Memory
• Pin out compatible to other 28-pin or 40/44-pin PIC16CXXX and PIC16FXXX
microcontrollers.
8 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
Peripheral Features:
• Timer0: 8-bit timer/counter with 8-bit prescaler
• Timer1: 16-bit timer/counter with prescaler, can be incremented during Sleep via external
crystal/clock
• Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
• Two Capture, Compare, PWM modules
• Capture is 16-bit, max. Resolution is 12.5 ns
• Compare is 16-bit, max. Resolution is 200 ns
• PWM max. Resolution is 10-bit
• Synchronous Serial Port (SSP) with SPI™ (Master mode) and I2C™ (Master/Slave)
• Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit
address detection
• Parallel Slave Port (PSP)–8 bits wide with external RD, WR and CS controls (40/44-pin
only)
• Brown-out detection circuitry for Brown-out Reset (BOR)
Analog Features:
• 10-bit, up to 8-channel Analog-to-Digital Converter (A/D)
• Brown-out Reset (BOR)
• Analog Comparator module with:
• Two analog comparators
• Programmable on-chip voltage reference (VREF) module
• Programmable input multiplexing from device inputs and internal voltage
reference
• Comparator outputs are externally accessible
Block Diagram of PIC 16F877A Controller
9 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
10 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
EXPERIMENT 2
AIM: Write an ALP to generate square of 10 Khz using Timer 0
THEORITICAL CONCEPT:
; we are displaying output at Port 1.1
0000 2 ORG 0
12 END
NAME T Y P E V A L U E ATTRIBUTES
A1 . . . . . . . . C ADDR 0000H A
P1 . . . . . . . . D ADDR 0090H A
EXPERIMENTAL SETUP
PROCEDURE:
• Create a New folder on the desktop for saving the contents of the program.
• Double click on the icon of Keil.
• Select the device for the target (Select Atmel → Select 89C52 →Ok →No)
• Go in the project menu and click on μVision Project after this an edit window will
appear on desktop.
• Write the desired program in the editing window up to end.
• Right click on source group and select remove start up in project workspace.
12 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
• Go in the file menu and click on save as and save the program with the extinction .asm
on desktop in the new folder.
• Right click on source group → Select add file to group → All file → Select file .asm →
Select Add.
• Now go in the project menu and click on options for the target “Target1”.
• Update the frequency value (eg. 11.0592) and click on output and enable the following.
• ®Create Executable
• √ or Ok –Debug info
• Select Create Hex file
• Select Browse info
• Now click on Ok
• Go in the project menu and click on built target.
• Go in the project menu and click on Rebuild target.
• Go in the project menu and click on Run (or Ctrl +F5).
• After this Hex file will be created in the New Folder
PRECAUTIONS:
Make sure correct power supply is given to the kit/Equipment. Wrong power supplies may cause
damage to your equipments.
HEX FIILE:
:10000000758A18758CFF7589CED28CB291308DF9B6 :06001000C28DC28C80EAE3
:00000001FF
14 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
EXPERIMENT 3
RS= P2.0
R/W=P2.1
E=P2.2
0000 1 ORG 0
001D E4 17 AGAIN:CLR A
0034 22 30 RET
0041 22 37 RET
004A 22 42 RET
0304 57454C43
0308 4F4D4553
16 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
NAME T Y P E V A L U E ATTRIBUTES
A1 . . . . . . . . C ADDR 0000H A
P1 . . . . . . . . D ADDR 0090H A
P2 . . . . . . . . D ADDR 00A0H A
EXPERIMENTAL SETUP:-
PROCEDURE:
• Create a New folder on the desktop for saving the contents of the program.
• Double click on the icon of Keil.
• Select the device for the target (Select Atmel → Select 89C52 →Ok →No)
• Go in the project menu and click on μVision Project after this an edit window will
appear on desktop.
• Write the desired program in the editing window up to end.
• Right click on source group and select remove start up in project workspace.
• Go in the file menu and click on save as and save the program with the extinction .asm
on desktop in the new folder.
• Right click on source group → Select add file to group → All file → Select file .asm →
Select Add.
• Now go in the project menu and click on options for the target “Target1”.
• Update the frequency value (eg. 11.0592) and click on output and enable the following.
• ®Create Executable
• √ or Ok –Debug info
• Select Create Hex file
• Select Browse info
Now click on Ok
• Go in the project menu and click on built target.
• Go in the project menu and click on Rebuild target.
• Go in the project menu and click on Run (or Ctrl +F5).
• After this Hex file will be created in the New Folder.
• After selecting component ,click anywhere in the design area to select it and then click
again to place it.
• Place all the required components.
• connect the desired node by clicking at starting and ending point.
• Double click the 8051 component to open its properties.
• Browse for the HEX file.
• The controls at the left-bottom corner will help you simulate the circuit in real time.
PRECAUTIONS:
Make sure correct power supply is given to the kit/Equipment. Wrong power supplies may cause
damage to your equipments
HEX FILE:
:10000000743811281142748011281142740C11287F:100010001142740111281142781E90030
0E49311DB
:10002000351142A3D8F780D8F590C2A0C2A1D2A2C0:100030001142C2A222F590D2A0C
2A1D2A21142C204
:0B004000A22279FF7A64DAFED9FA22CE:100300005250532057454C434F4D455320594F
555C:00000001FF
19 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
EXPERIMENT 4
AIM: An ALP to interface seven segment with 8051 and display 0-9 on it
THEORITICAL CONCEPT:
Crystal Frequency =12Mhz
0000 1 ORG 0
0005 E4 4 AGAIN:CLR A
001C 22 17 RET
0304 666D7C07
20 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
0308 7F67
20 END
NAME T Y P E V A L U E ATTRIBUTES
A2 . . . . . . . . C ADDR 0000H A
H1 . . . . . . . . C ADDR 0012H A
H2 . . . . . . . . C ADDR 0014H A
H3 . . . . . . . . C ADDR 0016H A
P2 . . . . . . . . D ADDR 00A0H A
EXPERIMENTAL SETUP:-
21 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
Make sure correct power supply is given to the kit/Equipment. Wrong power supplies may cause
damage to your equipments
Hex File:
:10000000780A900300E493F5A01110A3D8F780F0CC:0D0010007B057AFF79FFD9FEDA
FADBF622D4: 0A0300003F065B4F666D7C077F67C8 :00000001FF
22 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
EXPERIMENT 5
AIM: An ALP to interface DC Motor with 8051
THEORITICAL CONCEPT:
Crystal Frequency=12MHz
Symbols Used: BFWD=BOTH FWD, BREV= BOTH REVERSE, MOT1= MOTOR 1 ONLY, MOT2= MOTOR2
ONLY
0000 1 ORG 0
27 END
EXPERIMENTAL SETUP:
24 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
PRECAUTIONS:
Make sure correct power supply is given to the kit/Equipment. Wrong power supplies
may cause damage to your equipments
EXPERIMENT 6
AIM: Write an ALP to transmit the data using P1 of 8051.
THEORITICAL CONCEPT:
; we are transmitting data at Port 1 using the max232 .
0000 1 ORG 00
15 END
NAME T Y P E V A L U E ATTRIBUTES
P0 . . . . . . . . D ADDR 0080H A
TI . . . . . . . . B ADDR 0098H.1 A
EXPERIMENTAL SETUP:
PRECAUTIONS:
Make sure correct power supply is given to the kit/Equipment. Wrong power supplies
may cause damage to your equipments
EXPERIMENT 7
AIM: Write an ALP to interface 4x4 keyboard with 8051.
THEORITICAL CONCEPT:
; we are connecting rows of 4x4 keyboard at Port 1(P1.0 to P1.3) and columns at Port 2(P2.0 to P2.3).
0000 1 ORG 00
41
59 END
NAME T Y P E V A L U E ATTRIBUTES
K1 . . . . . . . . C ADDR 0003H A
K2 . . . . . . . . C ADDR 000DH A
P0 . . . . . . . . D ADDR 0080H A
P1 . . . . . . . . D ADDR 0090H A
P2 . . . . . . . . D ADDR 00A0H A
31 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
EXPERIMENTAL SETUP:
• After selecting component ,click anywhere in the design area to select it and then click
again to place it.
• Place all the required components.
• connect the desired node by clicking at starting and ending point.
• Double click the 8051 component to open its properties.
• Browse for the HEX file.
• The controls at the left-bottom corner will help you simulate the circuit in real time.
PRECAUTIONS:
Make sure correct power supply is given to the kit/Equipment. Wrong power supplies
may cause damage to your equipments
EXPERIMENT 8
AIM: Write an ALP to interface the temperature sensor to 8051.
THEORITICAL CONCEPT:
; we are using ADC0848 to interface the temperature sensor.
0000 1 ORG 00
0016 13 CONVERSION:
0019 84 15 DIV AB
001F 84 18 DIV AB
0023 22 21 RET
0024 22 DATA_DISPLAY:
0030 22 29 RET
34 END
NAME T Y P E V A L U E ATTRIBUTES
B. . . . . . . . . D ADDR 00F0H A
P0 . . . . . . . . D ADDR 0080H A
P1 . . . . . . . . D ADDR 0090H A
35 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
P2 . . . . . . . . D ADDR 00A0H A
EXPERIMENTAL SETUP:
Make sure correct power supply is given to the kit/Equipment. Wrong power supplies
may cause damage to your equipments
36 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
EXPERIMENT 9
AIM: Write an ALP to interface the lcd 16x2 to P16f877A.
THEORITICAL CONCEPT:
; we are displaying output at lcd conneted to PORTB and PORTD.
LIST P=PIC16F877A,F=INHX32,N=0,ST=OFF,R=HEX
#include p16f877a.inc
ORG 00
RS EQU RB0
RW EQU RB1
EN EQU RB2
CLRF TRISD
CLRF TRISB
BCF LCD_CTRL,EN
CALL LDELAY
MOVLW 0X38
CALL COMNWRT
CALL LDELAY
MOVLW 0X0E
CALL COMNWRT
CALL LDELAY
MOVLW 0X01
CALL COMNWRT
CALL LDELAY
38 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
MOVLW 0X06
CALL COMNWRT
CALL LDELAY
MOVLW 0X84
CALL COMNWRT
CALL LDELAY
MOVLW A'N'
CALL DATAWRT
CALL DELAY
MOVLW A'O'
CALL DATAWRT
BRA AGAIN
BCF LCD_CTRL,RS
BCF LCD_CTRL,RW
BSF LCD_CTRL,EN
CALL SDELAY
BCF LCD_CTRL,EM
RETURN
BSF LCD_CTRL,RS
BCF LCD_CTRL,RW
BSF LCD_CTRL,EN
CALL SDELAY
BCF LCD_CTRL,EN
RETURN
END
39 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
EXPERIMENTAL SETUP
Make sure correct power supply is given to the kit/Equipment. Wrong power supplies
may cause damage to your equipments
40 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
RESULT AND COMMENTS: We have successfully studied the interfacing of PIC with LCD.
41 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
EXPERIMENT 10
AIM: Write an ALP to generate square wave P16f877A.
THEORITICAL CONCEPT:
; we are generating square wave using PortB as output Port.
LIST P=PIC16F877A,F=INHX32,N=0,ST=OFF,R=HEX
#INCLUDE P16F877A.INC
R1 EQU 0X07
R2 EQU 0X08
R3 EQU 0X09
ORG 00
CLRF TRISB
MOVLW 0X55
MOVWF PORTB
L3 COMF PORTB,F
CALL QDELAY
BRA L3
QDELAY
MOVLW D'2'
MOVWF R1
D1 MOVLW D'250'
MOVWF R2
D2 MOVLW D'250'
MOVWF R3
42 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
D3 NOP
NOP
DECF R3,F
BNZ D1
RETURN
END
EXPERIMENTAL SETUP:
PROCEDURE:
START PROTEUS SIMULATION:
• Place your component from the library , connect them accordingly.
• Click ok .
• After selecting component ,click anywhere in the design area to select it and then click
again to place it.
43 MICROCONTROLLER and EMBEDDED SYSTEM DESIGN LAB (EE-328-F)
Make sure correct power supply is given to the kit/Equipment. Wrong power supplies
may cause damage to your equipments
RESULT AND COMMENTS:
We have successfully studied the generation of square wave using PIC microcontroller.