Simulation Lab File - EC 708
Simulation Lab File - EC 708
COMMUNICATION ENGINEERING
Submitted to -. Submitted by -
Gautam Sonker
• 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
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.
Port 0 (P0.0 - P0.7): If designated as output, each of these pins can be connected up to 8 TTL
input circuits. If designated as input, they are high impedance inputs as their potential is
undefined with respect to the ground. If external memory is used, these pins are used for
alternate transfer of data and addresses (A0-A7) for accessing the extra memory chip. Signal on
ALE pin determines the mode of transfer on port.
Port 1 (P1.0 - P1.7): If designated as output, each of these pins can be connected up to 4 TTL
inputs. If designated as input, these pins act like standard TTL inputs (that is, they have an
internal resistor connected to the positive supply pole and a +5V voltage). Also, pins of Port 1
have alternate functions according to the following table:
Pin Alternate function
P1.0 T2 (Timer 2 input)
P1.1 T2EX (Timer 2 control input)
Port 2 (P2.0 - P2.7): If designated as input or output, this port is identical to Port 1. If external
memory is used, Port 2 stores the higher address byte (A8-A15) for addressing the extra
memory chip. Port 3 (P3.0 - P3.7): Similar to Port 1, Port 3 can also be used as universal I/O,
but pins of Port 3 also have alternate functions.
RST: Reset input: A high on this pin for two machine cycles while the oscillator is
running resets the device and terminate all activities. This is often referred to as a
power on reset. Activating a power on reset will cause all values in the register to be
lost. Figure A and figure B shows two ways of connecting the RST pin to the power
on reset circuitry.
Positive voltage impulse on RST pin resets the MCU. In order to be detected, this impulse
needs to have duration of at least two operating cycles (this cycle represents the time
necessary to execute one instruction and lasts for 12 oscillator signals).
EA/VPP: External Access Enable; When this pin is connected to the ground, MCU gets
program instructions from external program memory. In case that internal program memory is
used (common case); this pin should be connected to the positive supply pole (VCC). During
the loading of program to internal Flash memory, this pin is at +12V.
ALE/PROG: This pin emits an impulse sequence with a frequency equal to 1/6 of the
frequency generated by the main oscillator. If external memory is used, signal from this pin
controls the additional register for temporary storage of the lower address byte (A0 - A7). This
pin also serves as a control input during the writing of program to MCU.
PSEN: Program Store Enable; This pin is used for reading from external program memory
(ROM). When the AT89C52 is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped during
each access to external data memory.
XTAL1 and XTAL2: XTAL1 is the Input to the inverting oscillator amplifier and input to the
internal clock operating circuit. XTAL2 is Output from the inverting oscillator amplifier.
AT89C52 has an on chip oscillator but requires an external clock to run it(See Figure. C). Most
often quartz crystal is connected to XTAL1 and XTAL2.The quartz crystal oscillator connected
to XTAL pins also needs two capacitors of 30pf value.
VCC: Power Supply (4 – 6V)
GND: Negative supply pole (ground)
EXPERIMENT NO 2
AIM: Write an assembly language program to add, subtract, multiply and divide 16 bit
data by Atmel microcontroller.
PROGRAM:
Addition:
ORG 0000H
CLR C ; make CY=0
MOV A, #0E7H ; load the low byte now A=E7H
ADD A, #8DH ; add the low byte now A=74H and CY=1
MOV R6, A ; save the low byte of the sum in R6
MOV A, #3BH ; load the high byte
ADDC A, #3BH ; add with carry (3B+3C+1=78)
MOV R7, A ; save the high byte of the sum
Subtraction:
ORG 3000H
CLR C ; make CY=0
MOV A, #50H ; load the low byte now A= 50H
MOV R1, #30H ; load the byte now R1=30H
SUBB A, R1 ; subtract contents of A and R1
JNC Next
CPL A
INC A
Next: MOV R2, A
SJMP 3000H
Multiply:
ORG 4000H
MOV A, #03H ; move the first no. into acc
MOV B, #02H ; move the second no. into B
MUL AB ; multiply the contents of acc with B
SJMP 4000H
Divide:
ORG 5000H
MOV A, #25H ; move the first no. into acc.
MOV B, #5H ; move the second no. into B
DIV AB ; divide the contents of acc with B
SJMP 5000H
RESULT: Addition, Subtraction, Multiplication, Division of 16 bit data has been performed
successfully on the kit.
PRECAUTIONS: Make sure correct power supply is given to the kit/Equipment. Wrong power
supplies may cause damage to your equipment.
EXPERIMENT NO 3
AIM: Write an assembly language program to generate 10 KHz frequency using interrupts on P1.2.
PROGRAM:
RESULT: Square wave has been generated on P1.2 and displayed on CRO.
PRECAUTIONS: Make sure correct power supply is given to the kit/Equipment. Wrong power
supplies may cause damage to your equipments.
EXPERIMENT NO 4
APPARATUS: NV5001 Microcontroller development Board, MC-04 Kit, power cord and
connecting leads.
MOV A, #01H
LCALL COMMAND
MOV A, #06H
LCALL COMMAND
RET -----------------------------------------------------------------------------------------------------------------------
COMMAND:
ACALL READY
MOV P0, A
CLR RS_LCD
CLR RW_LCD
SETB E_LCD
CLR E_LCD
RET -----------------------------------------------------------------------------------------------------------------------
DISPLAY:
ACALL READY
MOV P0, A
SETB RS_LCD
CLR RW_LCD
SETB E_LCD
CLR E_LCD
RET -----------------------------------------------------------------------------------------------------------------------
READY: SETB P0.7
CLR RS_LCD
SETB RW_LCD
WAIT: CLR E_LCD
SETB E_LCD
JB P0.7, WAIT
RET ----------------------------------------------------------------------------------------------------------------------
END
PROCEDURE:
• Turn contrast control potentiometer in LCD interface block to clockwise position (in MC04).
• Turn Backlight control potentiometer in LCD interface block to anticlockwise position
(in MC04).
• Switch ‘On’ the power supply.
• Observe “NVIS’’ is coming on LCD and after some delay “Technologies”.
• Observe the output waveform between RS pin of LCD (P3.5) and ground, on oscilloscope.
• Observe the output waveform between R/W pin of LCD (P3.6) and ground, on oscilloscope
• Observe the output waveform between E pin of LCD (P3.7) and ground, on oscilloscope.
• Turn contrast control potentiometer and observe the contrast change on LCD.
• Turn Backlight control potentiometer and observe the change on backlight of LCD.
APPARATUS: NV5001 Microcontroller development Board, MC-04 Kit, power cord and
connecting leads.
CLR SEG_D
MOV P2, #00H
SETB SEG_D
MOV P2, #01100110B
LCALL DELAY_1S
CLR SEG_D
CLR SEG_B
CLR SEG_A
CLR SEG_C
MOV P2, #00H
LJMP LOOP -----------------------------------------------------------------------------------------------------
----------- -----
DELAY_1S: MOV R2, #06
DO3: MOV R3, #10
DHERE1: MOV R4, #10
DAGAIN: NOP
NOP
NOP
NOP
DJNZ R4, DAGAIN
DJNZ R3, DHERE1
DJNZ R2, DO3
RET ---------------------------------------------------------------------------------------------------------------
- -----
END
PROCEDURE:
APPARATUS: NV5001 Microcontroller development Board, MC-05 Kit, power cord and
connecting leads.
DESCRIPTION: The experiment has been designed to have a clear understanding of how
motors are interfaced and controlled with microcontroller. The Motor drive module is made in
such a way that student can understand the whole concepts of steeper motor, DC motor and
Servo system. The object is to connect and program a microcontroller to do any
operation with motors. It has input and output terminals for connection of external real world
applications.
PROGRAM: To monitor the status of switch and rotate the stepper motor.
END
PROCEDURE:
APPARATUS: NV5001 Microcontroller development Board, MC-05 Kit, power cord and
connecting leads.
PROGRAM: To monitor the PWM status and control the speed of DC motor in 100% and 25% duty
cycle pulse.
LCALL DELAY_1S
LCALL DELAY_1S
LCALL DELAY_1S
LCALL DELAY_1S
SJMP FIR_ROU -----------------------------------------------------------------------------------------------------
--------------- DELAY_1S_2 : MOV R2, #50
DHERE1_1_1 : MOV R3, #100
DHERE1_2 : NOP
DJNZ R3, DHERE1_2
DJNZ R2, DHERE1_1_1
RET --------------------------------------------------------------------------------------------------------------------
DELAY_1S : MOV R2,#100
DO3_3 : DEC R2
DJNZ R2, DO3_3
RET ----------------------------------------------------------------------------------------------------------------------
END
PROCEDURE:
APPARATUS: NV5001 Microcontroller development Board, MC-05 Kit, power cord and
connecting leads.
PROGRAM: To monitor the status of position control switch and control the angle of servo
motor.
PROCEDURE: