You are on page 1of 40

Jawaharlal Nehru Engineering College

MICROCONTROLLER and APPLICATIONS

Third Year Students

Name :Akash Ajaykumar Bhale

Roll No:304111
Index
Sr.No. Name of Date/Page no. Sign Remark
Experiment
1 Study of 8085
2 Study of 8085
interfacing
(prerequisite 2)

3 To Study 8051
assembler and
simulator (Keil)
4 Arithmetic operation
I
a) Program for HEX
and BCD add and
subtract
b) )Program to
find BCD
addition of two
numbers
5 Arithmetic operation
II
a)Multiplication of
two numbers
b)Division of two
numbers
6 To Examine flags and
stack (Keil)
7 Data Transfer
Programming
8 To Simulate I/O ports
(Keil)
9 The 8051 serial
interface.

10 Interfacing DAC and


ADC to the 8051.

11. Post requisite(Project


on proteus)/or NPTEL
virtual lab

Jawaharlal Nehru Engineering College


N-6, CIDCO, Aurangabad
Department of Electronics &Telecommunication
Vision of the Department:

To develop GREAT technocrats and to establish centre of excellence in the field of Electronics
and Telecommunications.

Global technocrats with human values


Research and lifelong learning attitude,
Excellent ability to tackle challenges
Awareness of the needs of society
Technical expertise

Mission of the Department:

1. To provide good technical education and enhance technical competency by providing


good infrastructure, resources, effective teaching learning process and competent, caring
and committed faculty.
2. To provide various platforms to students for cultivating professional attitude and ethical
values.
3. Creating a strong foundation among students which will enable them to pursue their
career choice.

MGM’S
Jawaharlal Nehru Engineering College
N-6, CIDCO, Aurangabad
Department of Electronics & Telecommunication

This is to certify that Mr./Ms ------------------------------------------------------------


Roll.No.----------------------- of fifth semester of B.Tech in Jawaharlal Nehru Engineering College
has completed the lab work satisfactorily in Electronics and Telecommunication course for the
academic year 2020-21 as prescribed in the curriculum

Subject Teacher H.O.D. Principal


PREREQUISITE NO 1
Aim :Study of 8085 microprocessor
Theory :
The salient features of 8085 µp are:
• It is a 8 bit microprocessor.
• It is manufactured with N-MOS technology.
• It has 16-bit address bus and hence can address up to 216 = 65536 bytes (64KB) memory
locations through A0-A15.
• The first 8 lines of address bus and 8 lines of data bus are multiplexed AD0 – AD7.
• Data bus is a group of 8 lines D0 – D7.
• It supports external interrupt request.
• A 16 bit program counter (PC)
• A 16 bit stack pointer (SP)
• Six 8-bit general purpose register arranged in pairs: BC, DE, HL.
• It requires a signal +5V power supply and operates at 3.2 MHZ single phase clock.
• It is enclosed with 40 pins DIP
Memory
Program, data and stack memories occupy the same memory space. The total
addressable memory size is 64 KB.

Program memory
Program can be located any where in memory.Jump ,brach and call instructions use 16-bit
addresses, i.e. they can be used to jump/branch anywhere within 64 KB. All jump/branch
instructions use absolute addressing.
Data memory - the processor always uses 16-bit addresses so that data can be
placed anywhere.
Stack memory is limited only by size of memory.Stack grows downwords.
First 64 bytes in a zero memory page should be reserved for vectors used by RS
instructions.

Interrupts:
INTR (Input)
INTERRUPT REQUEST; is used as a general purpose interrupt. It is sampled only during the
next to the last clock cycle of the instruction. If it is active, the Program Counter (PC) will be
inhibited from incrementing and an INTA will be issued. During this cycle a RESTART or
CALL instruction can be inserted to jump to the interrupt service routine. The INTR is enabled
and disabled by software. It is disabled by Reset and immediately after an interrupt is accepted.
INTA (Output)
INTERRUPT ACKNOWLEDGE; is used instead of (and has the same timing as) RD during the
Instruction cycle after an INTR is accepted. It can be used to activate the 8259 Interrupt chip or
some other interrupt port.
RST 5.5 RST 6.5 - (Inputs)
RST 7.5 RESTART INTERRUPTS; These three inputs have the same timing as I NTR except
they cause an internal RESTART to be automatically inserted. RST 7.5 ~~ Highest Priority RST
6.5 RST 5.5 o Lowest Priority The priority of these interrupts is ordered as shown above. These
interrupts have a higher priority than the INTR.
TRAP (Input)
Trap interrupt is a nonmaskable restart interrupt. It is recognized at the same time as INTR. It is
unaffected by any mask or Interrupt Enable. It has the highest priority of any interrupt.

FLAG REGISTER :
General purpose registers

Conclusion:

PREREQUISITE NO 2
Aim :Interface LED’s to 8085 using 8255
Write an 8085 based assembly language program to flash the LEDs connected through 8255
REQUIREMENTS: An 8085 kit, interface of LED through 8255 and driver circuit.
OUTPUT: The LEDs connected to PORT A of 8255 flash regularly.
PROCEDURE:
1. Connect 8 LEDs in common cathode configuration through driver circuit and 8255 PPI to
8085 kit.
2. Note down the address of Port A from manual.
3. Write an 8085 based program as per the algorithm.

ALGORITHM:

1. Initialize stack pointer


2. Output the code on Port A to make all LEDs ‘ON’
3. Call a delay subroutine
4. Output the code on Port A to make all LEDs ‘OFF’
5. Call the delay subroutine
6. Repeat steps 3-6 for continuous flashing
PROGRAM:
LXI SP 27FF ; INITIALIZE STACK POINTER
BACK: MVI A, FFH
OUT PORT A ; MAKE ALL LEDS ‘ON’
CALL DELAY ; CONTINUE THE STATUS
TILL DELAY
MVI A, OO
OUT PORT A ; MAKE ALL LEDS ‘OFF’
CALL DELAY
JNZ BACK ; REPEAT TO GET FLASHING
EFFECT
DELAY: LXI D, FF00H ; LOAD DELAY COUNT
NEXT: DCX D ; DECREMENT
COUNT
MOV A, E ; REPEAT UNTIL COUNT
ORA D ; REACHES ZERO.
JNZ NEXT
LOGIC: Stack pointer is used as we are using stack area for calling delay subroutine. The
delay adjusts the flashing interval. We set all bits of accumulator and output its contents on port
A which makes all LEDs on. Here we have assumed that all LEDs are connected in common
cathode mode. Similarly the LEDs are made off by resetting all bits of accumulator.
RESULT: Verify flashing of LEDs (Paste screenshot of 8085 virtual lab result)

Conclusion:
EXPERIMENT NO. 3
Aim: To study 8051 Assembler & simulator (Keil) with sample program.
Theory:
Assembler
An assembler is a program that translates symbolic code (assembly language) into executable
object code. This object code can be executed with a 80C51-compatible microcontroller. If you
have ever written a computer program directly in machine-recognizable form, such as binary or
hexadecimal code, you will appreciate the advantages of programming in symbolic assembly
language.
Assembly language operation codes (mnemonics) are easily remembered (MOV for move
instructions, ADD for addition, and so on). You can also symbolically express addresses and
values referenced in the operand field of instructions. Because you assign these names, you can
make them as meaningful as the mnemonics for the instructions. For example, if your program
must manipulate a date as data, you can assign it the symbolic name DATE. If your program
contains a set of instructions used as a timing loop (executed repeatedly until a specific amount
of time has passed), you can name the instruction group TIMER_LOOP.
An assembly program has three parts:

1. Machine instructions - Code the machine can execute. Detailed discussion of the machine
instructions is in the hardware manuals of the 80C51 microcontroller.
2. Assembler directives - Define the program structure and symbols, and generate non
executable code (data, messages, and so on.).
3. Assembler controls - Set assembly modes and direct assembly flow.

Assembler Differences

This appendix lists the differences between between the Intel ASM 51 assembler, the
Keil A51 assembler, and the Keil A251/AX51 assembler.
Differences Between A51 and A251/AX51

Assembly modules written for the A51 assembler may be assembled using the
A251/AX51 macro assembler. However, since the A251 macro assembler supports the
Intel 251 architecture and the AX51 macro assembler supports extended 8051 variants
like the NXP 80C51MX, the following incompatibilities may arise when A51 assembly
modules are assembled with the A251/AX51 assembler

The AX51 assembler is a superset of the A51 assembler. This user's guide therefore
covers all development tools variants. Whenever a feature or an option is available in one
specific tool chain only, it is clearly marked.

For general reference to all tool variants and microcontroller architectures the terms listed
in the following table are used:
Term Refers to ...
Ax51 Macro Assembler A51, AX51 and A251 Macro Assembler .
Cx51 Compiler C51, CX51 and C251 ANSI C Compiler.
Lx51 Linker/Locator BL51, LX51 and L251 Linker/Locator.
LIBx51 Library Manager LIB51, LIBX51 and LIB251 Library
Manager.
OHx51 Object-Hex Converter OH51, OHX51 and OH251 Object-Hex
Converter.
x51 Architecture or x51 Device All classic 8051, extended 8051 and 251
device variants.
The µVision target debug interface to the Analog Devices Download/Debug Kernel allows you
to download and debug applications in ADuC83x and ADuC84x devices over the serial interface
(UART).
No hardware modifications are required and no additional RAM or ROM resources are allocated
for debugging.
The following image shows a typical configuration.
The µVision target debugger with Analog Devices debug interface helps you easily debug your
target programs in real-time. You may:

4. Download application code into on-chip flash.


5. High level debugging with C or Assembler source code.
6. Start application in real-time.
7. Single Step though application code.
8. Set an unlimited number of breakpoints.
9. Watch program variables.
10. Display and change memory contents.

Evaluation Tools

The Analog Devices evaluation boards are shipped with the Keil Evaluation Tools that
include the following:
11. Powerful and easy-to-use µVision IDE with editor, project management, and make.
12. Efficient C51 Compiler and Macro Assembler.
13. µVision Debugger with complete CPU and peripheral simulation.
14. Extensive tutorials and documentation.

The following restrictions apply to the evaluation tools:


15. The compiler, assembler, linker, and debugger are limited to 2 Kbytes of object code.
Source code may be any size. Programs that generate more than 2 Kbytes of object code
will not compile, assemble, or link.
16. The debugger supports files that are 2 Kbytes and smaller.
17. Programs begin at offset 0x0800.
18. The product may not be used to develop commercial products.

Instructions

Assembly language instructions specify the program code that is to be assembled by the
Ax51 assembler. The Ax51 assembler translates the assembly instructions in your
program into machine code and stores the resulting code in an object file.

Assembly instructions have the following general format:

« label: » mnemonic « operand » « , operand » « /, operand » « ; comment Where


label symbol name that is assigned the address at
which the instruction is located.
mnemonic is the ASCII text string that symbolically
represents a machine language instruction.
operand is an argument that is required by the
specified mnemonic.
comment is an optional description or explanation of
the instruction. A comment may contain any
text you wish. Comments are ignored by the
assembler.
Simulation
The µVision3 Debugger incorporates a C script language you can use to create Signal Functions.
Signal functions let you simulate analog and digital input to the microcontroller. Signal
functions run in the background while µVision3 simulates your target program.
The µVision3 simulator simulates the timing and logical behavior of serial communication
protocols like UART, I²C, SPI, and CAN. But µVision3 does not simulate the I/O port toggling
of the physical communication pins on the I/O port.
Keil Assembler-
An assembler allows to you to writer program using MCU instructions. It is used where
almost speed, small code size and exact hardware control is essential. The KEIL assembler
translate symbolic assembler language mnemonics into executable machine code while
supporting source level , symbolic debugger powerful capabilities like macro processing.
The assembler translates assembly source files into reloadable object modules and
optionally creates listing files with symbol tables and cross reference details, complete line
number, symbol type information is written to generate object files. This information allows
exact display of program variables in your debugger. Line numbers are used for source level
debugging at the other third party debugging tools.
KEIL assembler supports several different types of macro processors depending on
architecture. Standard macro processor is easier macro processor to use. It allows you to define
and use macros in your assembly programs using syntax that is compatible with that used in
many other assemblers. Macro processing language at the MPL is a string replacement facility
that is compatible with in ASM-51. Micro processor MPL has several predefined macro
processor. Macros save development and maintenance since common sequence need to be
developed once.

Simulation-
Simulator mode configures the µvision debugger as software only product that accurate
simulates target systems including systems including instruction and on chip peripherals. This
allows application code testing before hardware is available and gives you several benefits for
rapid, reliable embedded software development.
Simulation allows software testing on your desktop with no hardware environment.
Early software debugging on functional bases improves overall software reliability. Simulation
allows break points that are impossible with hardware debuggers. Simulation offers optimal
inputs signals hardware debugger add extra noise. Single stepping through single processing
algorithm is possible. External signal are stepped when CPU halts. Failure entries that would
destroy real hardware peripherals are easily chore.
KEIL Compiler-
The µvision IDE is the easiest way for the most developers to create embedded SIM programs.
To launch µvision click on your icon desktop at the selected KEIL µvision3 for start menu. The
µvision screen provides a menu bar that contains means of commands various tool bars that
contains buttons for common commands and window that displays project details, source files,
dialogue box, and other information of course, multiple windows can be open simultaneously.

4. Menu Bar –
It provides access to most µvision commands including file operations, editor operations, project
maintenance development tool setting program debugging, window selection and manipulation
and online help.

5. File Menu –
It includes commands that are open, save, print and close source files device database and license
manager dialogs are accessed from this menu.

6. Edit Menu-
It includes editing commands like undo, cut, copy, paste and indentation, bookmark functions
advanced editor functions, editor configuration.

7. View Menu-
It includes commands that select which to do editor window and debugger window to display as
well as commands that configure window viewing options.

8. Project Menu-
It includes commands that open, import, close project files. In addition project group and file
options project more functions are accessed from this menu.

9. Debug Menu-
It includes commands that start and stop depression, run the program, single step, half program
execution modify the program memory map. In addition commands are available to manage
break points, setting trace recording, enable execution profile analyzer and performance analyzer
and manage debug.

10. Flash Menu –


It include commands you use configure, program flash memory for embedded target system.

11. Peripheral Menu-


It includes dialogues that display and allow you change on-chip peripheral settings. The content
of this menu are failed to explain specific microcontroller you to do.
e.g. Dialogs are typically available for SIM configuration , interrupt , timer/counter general
purpose UART’s,C CAN, PWM real time clock watch dog timers

12. Tool Menu-


It allows you to configure and integrate your several third party utilities directly from µvision
IDE.

13. SVCS Menu-


It allows you to configure and integrate your several third party µvision.

14. Window Menu-


It includes arrange, split, select and close work space currently open bottom of menu.

15. Help menu-


It includes lone help system, list peripherals, access requests to technical support , check for
product uploads display product µvision.
TOOL BARS-The µvision IDE incorporates several tool bars that contain buttons for most
commonly used commands.

16. File tool bar contains buttons for commands used to edit source file.
17. Build tool bar contains buttons for commands used to build target.
18. Debug tool bar contains buttons for commands used in debugger.

Simulator and programmer for 8051-A simulator is software to mimic a microcontroller


operation with a Personal Computer. This helps in running the assembly language program off-
line and debug for errors. This is also a powerful learning tool before actually working with a
Microcontroller A programmer is hardware used to transfer the machine code to the internal
program memory of a microcontroller.
Working with KEIL Compiler µVision3-

KEIL Compiler µVision3 is a simulator/assembler for 8051 microcontroller to write and edit the code in
assembly language, compile it and also to run the code. Output of the assembly language program can be
verified using simulator.

Steps to use KEIL Compiler µVision3-

19. After installing the software, open8051 IDE

20. To create new project, go to:

Project New Project Save project (save project without any extension) select Microcontroller.

21. To write the assembly code in the editor , go to


File New
22. After writing the assembly code in the editor, save the file with .asm extension.
23. Then go to work space and right click on source group and then add saved file.
24. Then write click on the added file and select built option to check the errors.
25. Check for the errors in the output window
View Output
26. Once the error free code was made, debug the code.
Debug Start debug session
27. Debug options are
a. Step into – Each time only one instruction will be executed (single step mode).
b. Run– To run the whole code at once.
28. Additional things:
c. To view RAM, program memory, SFRs, and External memory, serial window, logic
analyzer, performance analyzer window use the option VIEW.
d. To set break points in the code (where debugging stops at that point)
Debug Insert Break Point
29. To stop the simulation
Debug Stop debug session
After checking the code in the simulator, the code (file with .HEX extension in Intel HEX format) is
loaded into Atmel 89C51 microcontroller using Universal Programmer. Although a separate 8051
assembly can be used at times assemble and generate Hex code for an assembly language program,
KEIL CompilerµVision3can perform that task.

Conclusion:

EXPERIMENT NO. 4

Aim: Examining flags and stacks.(Kiel)


Theory:
CPU Registers
These topics provide an overview of the CPU registers available on the x51 variants.
In addition to the CPU registers R0 - R7, all x51 variants have an SFR space that is used to
address on-chip peripherals and I/O ports. The SFR area includes the CPU registers SP (stack
pointer), PSW (program status word), A (accumulator, accessed via the SFR space as ACC), B,
DPL and DPH (16-bit register DPTR).
8051 Variants
The classic 8051 provides 4 register banks o
f 8 registers each. These register banks are mapped into the DATA memory area at address 0 –
0x1F. In addition the CPU provides a 8-bit A (accumulator) and B register and a 16-bit DPTR
(data pointer) for addressing XDATA and CODE memory. These registers are also mapped into
the SFR space as special function registers.
Program Status Word (PSW)
The Program Status Word (PSW) contains status bits that reflect the current CPU state. The 8051
variants provide one special function register called PSW with this status information. The 251
provides two additional status flags, Z and N, that are available in a second special function
register called PSW1.
PSW Register (all 8051 and 251 variants)
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
CY AC FO RS1 RS0 OV UD P
Additional PSW1 Register (on 251 Architecture only)
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
CY AC N RS1 RS0 OV Z —

The following table describes the status bits in the PSW:


RS1 RS0 Working Register Bank and Address
0 0 Bank0 (D:0x00 - D:0x07)
0 1 Bank1 (D:0x08 - D:0x0F)
1 0 Bank2 (D:0x10 - D:0x17)
1 1 Bank3 (D:0x18H - D:0x1F)

Symbol Function
CY Carry flag
AC Auxiliary Carry flag (For BCD Operations)
F0 Flag 0 (Available to the user for General Purpose)
RS1, Register bank select:
RS0 RS1 RS0 Working Register Bank and Address
0 0 Bank0 (D:0x00 - D:0x07)
0 1 Bank1 (D:0x08 - D:0x0F)
1 0 Bank2 (D:0x10 - D:0x17)
1 1 Bank3 (D:0x18H - D:0x1F)
0V Overflow flag
UD User definable flag
P Parity flag
— Reserved for future use (251 Only)
Z Zero flag (251 Only)
N Negative flag (251 Only)

Program :
Write program here

RESULT :

Paste screenshot of your result on keil platformon keil


Conclusion :
EXPERIMENT NO. 5

Aim: Simulating I/O ports(Keil).


Theory:
Simulation
The µVision3 Debugger incorporates a C script language you can use to create Signal Functions.
Signal functions let you simulate analog and digital input to the microcontroller. Signal
functions run in the background while µVision3 simulates your target program.
The µVision3 simulator simulates the timing and logical behavior of serial communication
protocols like UART, I²C, SPI, and CAN. But µVision3 does not simulate the I/O port toggling
of the physical communication pins on the I/O port.
To provide fast simulation speed and optimum access to communication peripherals, the logic
behavior of communication peripherals is reflected in virtual registers that are listed with the
DIR VTREG command. This has the benefit that you can easily write debug functions that
stimulate complex peripherals.
I/O Ports
µVision defines a VTREG for each I/O port: i.e. PORT2. Do not confuse these VTREGs with
the Peripheral Registers for each port (i.e. P2). The Peripheral Registers can be accessed inside
the CPU memory space. The VTREGs are the signals present on the pins.
With µVision, it is easy to simulate input from external hardware. If you have a pulse train
coming into a port pin, you can use a signal function to simulate the signal. For example, the
following signal function inputs a square wave on PORT2 pin 0 with a frequency of 1000Hz.
signal void one_thou_hz (void) {
while (1) { /* repeat forever */
PORT2 |= 1; /* set PORT2 bit 0 */
swatch (0.0005); /* delay for .0005 secs */
PORT2 &= ~1; /* clear PORT2 bit 0 */
swatch (0.0005); /* delay for .0005 secs */
} /* repeat */
}
The following command starts this signal function:
one_thou_hz ()
Simulating external hardware that responds to output from a port pin is only slightly more
difficult. Two steps are required. First, write a µVision user or signal function to perform the
desired operations. Second, create a breakpoint that invokes the user function.
Suppose you use an output pin (PORT2 bit 0) to enable or disable an LED. The following signal
function uses the PORT2 VTREG to check the output from the CPU and display a message in
the Command window.
signal void check_pA0 (void) {
if (PORT2 & 1)) { /* Test PORT2 bit 0 */
printf ("LED is ON\n"); } /* 1? LED is ON */
else { /* 0? LED is OFF */
printf ("LED is OFF\n"):
}
}
Now, you must add a breakpoint for writes to port 1. The following command line adds a
breakpoint for all writes to PORT2.
BS WRITE PORT2, 1, "check_p20 ()"
Now, whenever your target program writes to PORT2, the check_P20 function prints the current
status of the LED.
Simulate I/O Ports
µVision provides dialogs that show the status of all I/O ports. The I/O Pins are represented with
VTREGs. You may use this VTREGs also together with signal functions or breakpoints as
shown in the following example program.

µVision provides dialogs that show the status of all I/O ports. The I/O Pins are represented with
VTREGs. You may use this VTREGs also together with signal functions or breakpoints as
shown in the following example.
// in your C user program
PortAvalue = P2; // read Port 2 input
Breakpoints that you define in the µVision simulator:
bs write PORT2, 1, "printf (\"Port2 value=%X\\n\", PORT2)"
bs read PORT5, 1, "PORT5 = getint (\"Input Port5 value\")"
When you execute your C program, µVision asks you for a Port5 input value. If a new output
value is written to Port3, a message is printed in the Output Window - Command page.

ASSEMBLY PROGRAM

Write program here


RESULT:
Paste screenshot of your result on keil platformon keil

Conclusion :
EXPERIMENT NO. 6
Data Transfer Programming
Aim : To transfer data from one memory location to another
Program :

RESULT :

Before execution :
Paste screenshot of your result on keil platformo
After Execution

Paste screenshot of your result on keil platform

Conclusion:
EXPERIMENT NO. 7

Arithmetic operation I (8051)

Exercise a): Addition of two 16 bit hex numbers.


Aim: Arithmetic operation II (HEX and BCD add and subtract)
Statement: write an 8051 based assembly language program to add two 16 bit Hex number.
Algorithm:
1. Move first number to a register
2. Move second number to a another register.
3. Add lower nibble of both number and store in register
4. Add with carry higher nibble of both numbers.
5.Stop
Data: Two 16 bit hex numbers
conclusion: Thus program for two 16 bit hex number addition was written and output was
verified.
Program:
Write code here
Result:
Paste screenshot of your result on keil platform

b.Write an assembly language program to perform the subtraction of two 16-bit numbers.

Write Program here :

Result:
Paste screenshot of your result on keil platform
conclusion:

EXPERIMENT NO. 8
Arithmetic operation II
Exercise a): Multiplication of a 8 bit no.
b): Division of a 8bit no.

Aim: - Write an ALP for Multiplication & Division of two 8 bit bit numbers.
Statement: - Write an 8051 based assembly language program to multiply and Divide 8 bit no
by 8 bit no stored at memory location.
Algorithm:

1. Initialize and load data in reg. A


2. Initialize and load data in reg. B
3. Store result from accumulator and register b to a memory location
4. Stop

Program :
Write program here

Result :

Paste screenshot of your result on keil platform


Coclusion :

EXPERIMENT NO. 9

Aim: - Program to test I\O ports


a)To write a program to interface LED to 8051 kit
Statement: - Interface LED to 8051 kit and make it blink on and off.
Algorithm:

1. Initialize with address 6500h


2. Initialize accumulator with 00h
3. Move output data on port 1
4. Call delay
5. Complement accumulator
6. Move output data on port 1
7. Stop

Result: Blinking of LED.

Program:

Write program here


Result :

Paste screenshot of your result on keil platform

Conclusion:

EXPERIMENT NO. 10
Serial Communication Programming

Aim: To Conduct an experiment to configure 8051 microcontroller to transmit characters


“ENTER YOUR NAME” to a PC using the serial port and display on the serial window.

Note: To use result of this program, after selecting DEBUG session in the main menu use View-
> serial window #1. On running & halting the program, the data is seen in the serial window.

Program:

Write program here


RESULT:

Paste screenshot of your result on keil platform

Baud rate Calculation:

Crystal freq/ (12*32) = (11.0592MHz)/(12*32) = 28800.


Serial communication circuitry divides the machine cycle
frequency (11.0592MHz)/(12) by 32 before it is being used by the timer to set the baud rate.

To get 9600, 28800/3 is obtained by loading timer1 with -3 (i.e., FF – 3 = FD) for further clock
division. For 2400 baud rate, 28800/12 => -12 = F4 in TH1.

EXPERIMENT NO.10
Waveform generation using DAC
Aim : To interface ADC and DAC to 8051
Write a C program to generate square wave of amplitudeV & frequency
Hz using DAC. Display the waveform on the CRO. Circuit Diagram for wave form generation:

Dual DAC

Program:
#include <REG51xD2.H>
void delay(unsigned int x) /* delay routine */
{
for(;x>0;x--);
}

main()
{
unsigned char on = 0x7f,off=0x00; unsigned int fre = 230;

while(1)
{
P0=P1=on; /* write amplitude to port */ delay(fre);
P0=P1=off; /* clear port */ delay(fre);

}
}
DESIGN:
Let f = 2 kHz, Therefore T = 1/f= 0.5msec,
Count value for the delay is (T/ 1clock cycle period) = 0.5 x 10-3sec/1.085 x 10-6sec Hence Count
value is =460. Hence for 50% Duty cycle the Count value is half of the Count value=230.
Note: Delay produced by the program will depend on the microcontroller you are using, so
frequency of the waveform generated may not match with the given frequency.

Write a C program to generate ramp wave of amplitudeV using DAC. Display the waveform on
the CRO.

Program:
Write program here

Result :
Paste screenshot of your result on keil platform

Conclusion :
EXPERIMENT NO.11

Project title:
Working:
Ckt diagram:
Program.:
Simulation screenshots :

You might also like