Mca
Mca
Objective: The main objective is to study and write the program to perform
addition, subtraction,
Multiplication and division of two 8 bit numbers using 8051 microcontroller
instructions
and to study what and how the instructions are used in writing the program.
Procedure:
PRO4:
program and save this (filename.asm/filename.c) and add this
source file to the project using either one of the following two
methods. (i) Project->Manage->Components, Environment
Books->addfiles-> browse to the required file ->OK
“OR” ii) right click on the Source Group in the Project Window
and the Add Files to Group option.
PRO5:
Build the project; using Project -> Build Project. Keil µvision
translates all the user application and links. Any errors in the
code are indicated by – “Target not created” in the Build
window, along with the error line. Debug the errors. After an
error free, to build go to Debug mode.
PRO6:
Now user can enter into Debug mode with Debug- Start / Stop
Debug session dialog. Or by clicking in the icon.
PRO7:
The program is run using the Debug-Run command & halted
using Debug-Stop Running. Also the (reset, run, halt) icons can
be used. Additional icons are (step, step over, and step into, run
till cursor).
exp 2
To Write and execute Assembly Language Program to sort the 10 8-bit numbers in
Assembler Directives:
ORG(origin): This directive indicates the start of the program. This is used to set
the
register address during assembly. For example; ORG 0000h tells the compiler all
subsequent code starting at address 0000h.
Procedure:
PRO5:
Build the project; using Project -> Build Project. Keil µvision
translates all the user application and links. Any errors in the
code are indicated by – “Target not created” in the Build
window, along with the error line. Debug the errors. After an
error free, to build go to Debug mode.
PRO6:
Now user can enter into Debug mode with Debug- Start / Stop
Debug session dialog. Or by clicking in the icon.
PRO7:
The array elements are given at the corresponding data
memory location as per specified in the program.
The program is run using the Debug-Run command & halted
using Debug-Stop Running. Also the (reset, run, halt) icons can
be used. Additional icons are (step, step over, and step into, run
till cursor).
exp 3
Experiment No.-3
Aim: To Write and execute Assembly Language Program to transfer a block of data
8051 supports 64K Bytes of external data memory in addition to 128 Bytes of
internal
RAM. The external data memory is accessed using 16-bit address lines and its
address
varies from 0000H to FFFFH.
The general block diagram of data memory is shown below.
Procedure:
PRO5:
Build the project; using Project -> Build Project. Keil µvision
translates all the user application and links. Any errors in the
code are indicated by – “Target not created” in the Build
window, along with the error line. Debug the errors. After an
error free, to build go to Debug mode.
PRO6:
Now user can enter into Debug mode with Debug- Start / Stop
Debug session dialog. Or by clicking in the icon.
PRO7:
The block of elements are given at the corresponding external
memory location as per specified in the program.
The program is run using the Debug-Run command & halted
using Debug-Stop Running. Also the (reset, run, halt) icons can
be used. Additional icons are (step, step over, and step into, run
till cursor).
8051 microcontroller.
Objective: The main objective is to generate software delay and write a software to
create a delay of
20msecs. As well to understand difference between software and hardware delay.
CALCULATI
ON
For Delay
nested loop configuration is used. By knowing the execution time for each
instruction,
delay programs to generate different delays can be created.
MOV R1,#255 ; 1 MACHINE CYCLE
LOOP1: NOP ;1 MACHINE CYLCE
DJNZ R1,LOOP1 ;2 MACHINE CYCLES
PRO5:
Build the project; using Project -> Build Project. Keil µvision
translates all the user application and links. Any errors in the
code are indicated by – “Target not created” in the Build
window, along with the error line. Debug the errors. After an
error free, to build go to Debug mode.
PRO6:
Now user can enter into Debug mode with Debug- Start / Stop
Debug session dialog. Or by clicking in the icon.
PRO7:
The program is run using the Debug-Run command & halted
using Debug-Stop Running. Also the (reset, run, halt) icons can
be used. Additional icons are (step, step over, and step into, run
till cursor). Waveform is seen using a Logic analyser in Keil.
Flowchart: Students will draw the Flowchart on left side the sheet.
Result and
Discussion:
20ms
20ms
Conclusion:
Related
discussion
questions
exp5
Aim: To Write and Execute an Assembly language program for 8051to transmit data
Algorithm: 1) Configure Timer 1 in mode 2 for generating the baud rate clock
CALCULATI
ON
For Baud
rate
Baud Rate =
Baud Rate =
SMOD= Baud Rate Doubler bit available in PCON reg
F CLK = Oscillator Frequency
TH1= Timer1 Auto-reload Value
Baud Rate for SMOD:
Procedure:
PRO5:
Build the project; using Project -> Build Project. Keil µvision
translates all the user application and links. Any errors in the
code are indicated by – “Target not created” in the Build
window, along with the error line. Debug the errors. After an
error free, to build go to Debug mode.
PRO6:
Now user can enter into Debug mode with Debug- Start / Stop
Debug session dialog. Or by clicking in the icon.
PRO7:
The program is run using the Debug-Run command & halted
using Debug-Stop Running. Also the (reset, run, halt) icons can
be used. Additional icons are (step, step over, and step into, run
till cursor).
Transmission of text ”HAPPY” can be seen on serial window.
Objective: The main objective is to study timers to generate delays and learn the
LED interfacing to
8051 and write a software to create square wave of particular frequency using built
in
Timer0/Timer1.
To learn 8051 instructions used and understand the use of them in writing the
program .
The resistor is important in LED interfacing to limit the flowing current and avoid
damaging the LED and/or MCU.
Interface 1 will glow LED, only if the PIN value of the MC is HIGH as current
flows
towards the ground.
Interface 2 will glow LED, only if the PIN value of the MC is LOW as current
flows
towards PIN due to its lower potential.
Algorithm: 1. Load the mode control word in the TMOD register
2. Load the initial value of count in timer register
3. Enable the Timer to operate
4. Wait for the overflow until the Timer flag is set (keep on checking status timer
flag bit)
5. Stop the Timer operation
6. if this sequence is to be repeated, clear timer flag bit ,reload the timer
register and go
to step 3
7. Repeat the process
CALCULATI
ON for
DELAY
1 µs= 1 count
250 µs= 250 counts
Procedure:
PRO 5:
PRO6:
Go to Flash -> Configure Flash tools. There select output
window. In that click on Create HEX file so that Hex file will be
created while build the project which would be useful in
downloading the program file into 8051 program memory. We
can do the whole circuit implementation using Proteus 8
software.
Build the project; using Project -> Build Project. Keil µvision
translates all the user application and links. Any errors in the
code are indicated by – “Target not created” in the Build
window, along with the error line. Debug the errors. After an
PRO7:
Now user can enter into Debug mode with Debug- Start / Stop
Debug session dialog. Or by clicking in the icon.
PRO8:
The program is run using the Debug-Run command & halted
using Debug-Stop Running. Also the (reset, run, halt) icons can
be used. Additional icons are (step, step over, and step into, run
till cursor). Simulation of LED blinking can be seen on Parallel
Port2 window.
The better simulation results can be obtained by designing
whole circuitry in Proteus 8.11.
exp 7
Experiment No.-7
Aim: Interfacing of 7-Segment display and Write an assembly level program in 8051
for decimal
up counter from 0 to 9
Objective: The main objective is to study 7-segment display device and learn the 7-
segment
7-segment display
Digit drive pattern: Digit drive pattern of a seven segment LED display is simply
the
different logic combinations of its terminals ‘a’ to ‘h‘ in order to display
different digits
and characters. The common digit drive patterns (0 to 9) of a common cathode seven
segment display are shown in the table below.
Circuit
Diagram:
Procedure:
PRO 5:
PRO6:
Go to Flash -> Configure Flash tools. There select output
window. In that click on Create HEX file so that Hex file will be
created while build the project which would be useful in
downloading the program file into 8051 program memory.
Whole circuit is implemented using Proteus 8 software.
Build the project; using Project -> Build Project. Keil µvision
translates all the user application and links. Any errors in the
code are indicated by – “Target not created” in the Build
window, along with the error line. Debug the errors. After an
error free, to build go to Debug mode.
PRO7: Now user can enter into Debug mode with Debug- Start / Stop
Debug session dialog. Or by clicking in the icon.
PRO8:
PRO9:
Flowchart: Students will draw the Flowchart on left side the sheet.
Result and
Discussion:
Conclusion:
exp 8
Experiment No.-8
Aim: Interfacing of LCD and Write an assembly level program in 8051 to display a
word “ELEX”
on LCD
Objective: The main objective is to study LCD module and its pin functions. Learn
the LCD interfacing
VEE pin is meant for adjusting the contrast of the LCD display and the contrast can
be
adjusted by varying the voltage at this pin.
R/W pin is meant for selecting between read and write modes. High level at this pin
enables read mode and low level at this pin enables write mode.
E pin is for enabling the module. A high to low transition at this pin will enable
the
module.
DB0 to DB7 are the data pins. The data to be displayed and the command
instructions are
placed on these pins.
LED+ is the anode of the back light LED and this pin must be connected to Vcc
through a
suitable series current limiting resistor. LED- is the cathode of the back light
LED and this
pin must be connected to ground.
High logic at the RS pin will select the data register and Low logic at the RS pin
will select
the command register. If we make the RS pin high and the put a data in the 8 bit
data line
(DB0 to DB7) , the LCD module will recognize it as a data to be displayed . If we
make RS
pin low and put a data on the data line, the module will recognize it as a command.
An LCD module can be interfaced with a microcontroller either in 8 bit mode (as
seen
above) or in 4 bit mode. 8 bit mode is the conventional mode which uses 8 data
lines and
RS, R/W, E pins for functioning. However 4 bit mode uses only 4 data lines along
with the
control pins. This will saves the number of GPIO pins needed for other purpose.
The steps that has to be done for initializing the LCD display is given below and
these
steps are common for almost all applications.
Send 38H to the 8 bit data line for initialization
Send 0EH for making LCD ON, cursor ON and cursor blinking ON.
Send 06H for incrementing cursor position.
Send 01H for clearing the display and return the cursor.
Send 80H to force cursor at the beginning of 1 st Line.
Sending data to the LCD.
The steps for sending data to the LCD module is given below. The LCD module has
pins
namely RS, R/W and E. It is the logic state of these pins that make the module to
determine whether a given data input is a command or data to be displayed.
Make R/W low.
Make RS=0 if data byte is a command and make RS=1 if the data byte is a data to
be displayed.
Place data byte on the data register.
Pulse E from high to low.
Repeat above steps for sending another data.
Circuit
Diagram:
Procedure:
PRO3: Start Project – New Project, and select the CPU from the device
database (Database-Atmel- AT89C51 or AT89S51 as per the
board).On clicking ‘OK’, the following option is displayed.
Choose ‘No’.
PRO 5: Build the project; using Project -> Build Project. Keil µvision
translates all the user application and links. Any errors in the
code are indicated by – “Target not created” in the Build
window, along with the error line. Debug the errors. After an
error free, to build go to Debug mode.
PRO6: Now user can enter into Debug mode with Debug- Start / Stop
Debug session dialog. Or by clicking in the icon.
PRO7:
PRO8:
The program is run using the Debug-Run command & halted
using Debug-Stop Running. Also the (reset, run, halt) icons can
be used. Additional icons are (step, step over, and step into, run
till cursor). Simulation of LCD display can be seen on parallel
port P1.
Open Proteus 8. Pick the components required and design the
whole circuitry. Open the Hex File and download it onto the
microcontroller. Run the simulation.
exp 9
Experiment No.-9
Aim: To write and execute an Assembly Language Program to generate two square
waveforms
of particular frequency simultaneously on P3.0 and P3.1 as well third activity i.e.
taking
the data from two ports P0 and P1 continuously, comparing them and setting the pin
P2.5
if they are not equal or clearing them if they are equal using 8051
microcontroller.
Objective: The main objective is to study 8051 Interrupts and use them to generate
two square
waveforms of frequency simultaneously on port pins as well as performing third
activity
by processor.
To learn 8051 instructions used and understand the use of them in writing the
program
In course of this waiting, the timer flags get set and then waiting is exited and
the
instructions in the ISR’s are executed. The last instruction in the ISR is RETI
which takes
control back to the main program instruction SJMP HERE.
Instead of simply waiting, the processor can be made to do something else. A Port
based
program can be made run along with the running of the both the Timers. This is the
charm of using Interrupts. The processor is not stuck with doing just one program.
A
number of tasks can be doen simultaneously if separate hardware is available for
each of
them, Here the CPU does the Port program, while both timers are kept running by
virtue
of it having specific hardware for that job.
Note: In Interrupt Mode, both timers can work independently. In polled mode this is
difficult as the CPU is in a loop, polling the flag of one timer.
instruction in the ISR is RETI and then control returns to the main program
9. Once the control branches to the interrupt vector, TF0/TF1 is automatically
cleared.
10. That is how it generates two square waves on P2.0 and P2.1 using interrupt
mode.
11. Meanwhile processor will be busy in performing third activity as follows.
1. Set the Ports P1 and P0 as input ports
2. Read the data from P1 and P0
3. Compare both the data and if they are not equal set the pin P2.5 or clear the
pin P2.5 if
they are equal.
Procedure:
PRO 5: Build the project; using Project -> Build Project. Keil µvision
translates all the user application and links. Any errors in the
code are indicated by – “Target not created” in the Build
window, along with the error line. Debug the errors. After an
error free, to build go to Debug mode.
Now user can enter into Debug mode with Debug- Start / Stop
PRO6:
Debug session dialog. Or by clicking in the icon.
PRO7:
The program is run using the Debug-Run command & halted
using Debug-Stop Running. Also the (reset, run, halt) icons can
be used. Additional icons are (step, step over, and step into, run
till cursor). Simulation of two waveforms generation can be
seen on Logic Analyzer.