ES & IOT DESIGN LAB 2023-2024
ES & IOT DESIGN LAB 2023-2024
CERTIFICATE
Certificate that this is the Bonafide Record of the work done by,
Date :
Place : KALAVAI
OM SAKTHI
NAME :
REG.NO :
YEAR/SEM : III / VI
CONTENTS
8 BIT ADDITION
AIM:
ALGORITHM:
Clear PSW
Select Register
ADD A & R0
Stop
PROGRAM:
OUTPUT:
INPUT OUTPUT
DATA 1 07 4500 0A
DATA 2 03
RESULT:
Thus the 8051 Assembly Language Program for addition of two 8-bit numbers was
executed.
FLOW CHART:
EXPT.NO: 1b
DATE :
8 BIT SUBTRACTION
AIM:
To perform subtraction of two 8-bit data and store the result in memory.
ALGORITHM:
1. Clear the carry flag.
2. Initialize the register for borrow.
3. Get the first operand into the accumulator.
4. Subtract the second operand from the accumulator.
5. If a borrow results increment the carry register.
6. Store the result in memory.
PROGRAM:
Label Address Mnemonics Hex code Comments
Op code Operand
START 4100 CLR C C3 Clear CY Flag
4101 MOV A, #0A 74 0A Get the data1 in Accumulator
4103 SUBB A, #05 94 05 Subtract data2 fromdata1
4105 MOV DPTR, #4500 90 4500 Initialize memory location
4108 MOVX @DPTR, A F0 Store the difference in memory location
L1 4109 SJMP L1 80 FE Stop the program
OUTPUT:
INPUT OUTPUT
DATA 1 0A 4500 05
DATA 2 05
RESULT:
Thus the 8051 Assembly Language Program for subtraction of two 8-bit numbers was
executed.
FLOW CHART:
Start
Multiply A with B
Stop
EXPT.NO: 1c
DATE :
8 BIT MULTIPLICATION
AIM:
To perform multiplication of two 8-bit data and store the result in memory.
ALGORITHM:
1. Get the multiplier in the accumulator.
2. Get the multiplicand in the B register.
3. Multiply A with B. Store the product in memory.
PROGRAM:
OUTPUT:
INPUT OUTPUT
DATA 1 05 4500 0F
DATA 2 03
RESULT:
Thus the 8051 Assembly Language Program for Multiplication of two 8-bit numbers
was executed.
FLOW CHART:
Start
Divide A by B
Stop
EXPT.NO: 1d
DATE :
8 BIT DIVISION
AIM:
To perform division of two 8-bit data and store the result in memory.
ALGORITHM:
1. Get the Dividend in the accumulator.
PROGRAM:
Label Address Mnemonics Hex code Comments
Opcode Operand
START 4100 MOV A, #15 74 15 Store data1 in accumulator
4102 MOV B, #03 75 F0 03 Store data2 in B register
4105 DIV AB 84 Divide
4106 MOV DPTR, #4500 90 4500 Initialize memory location
4109 MOVX @DPTR, A F0 Store remainder
410A INC DPTR A3 Go to next memory location
410B MOV A, B E5 F0 Store quotient
410D MOVX @DPTR, A F0
L1 410E SJMP 410E 80 FE Stop the program
OUTPUT:
INPUT OUTPUT
DATA 1 15 4500 05
DATA 2 03
RESULT:
Thus the 8051Assembly Language Program for division of two 8-bit numbers was
executed.
FLOW CHART:
EXPT.NO: 2a
DATE :
AIM:
To write an assembly language to perform 1‟s and 2‟s complement number using
8051.
ALOGRITHM:
PROGRAM:
OUTPUT:
INPUT OUTPUT
DATA 05 4500 FB
RESULT:
Thus the assembly language program to find 2‟s complement was executed and
verified successfully using 8051 microcontroller.
EXPT.NO: 2b
DATE :
AND OPERATION:
AIM:
To perform Logical AND Operation using 8051 microcontroller.
ALGORITHM:
1. Get the input value and store data in the accumulator.
PROGRAM:
Label Address Mnemonics Hex code Comments
Op code Operand
START 4100 CLR C C3 Clear CY Flag
4101 MOV A, #07 74 07 Get the data1 in Accumulator
4103 ANL A, #03 34 03 AND Acc with immediate data
4105 MOV DPTR, #4500 90 4500 Initialize the memory location
4108 MOVX @DPTR, A F0 Store the result in memory location
L1 4109 SJMP 4109 80 FE Stop the program
OUTPUT:
INPUT OUTPUT
DATA 1 07 4500 02
DATA 2 03
RESULT:
Thus the assembly language program to perform Logical AND Operation using 8051
Performed and the result is stored.
EXPT.NO: 2c
DATE :
OR OPERATION:
AIM:
To perform Logical OR Operation using 8051 microcontroller.
ALGORITHM:
1. Get the input value and store data in the accumulator.
PROGRAM:
Label Address Mnemonics Hex code Comments
Op code Operand
START 4100 CLR C C3 Clear CY Flag
4101 MOV A, #08 74 08 Get the data1 in Accumulator
4103 ORL A, #04 34 04 OR Acc with immediate data
4105 MOV DPTR, #4500 90 4500 Initialize the memory location
4108 MOVX @DPTR, A F0 Store the result in memory location
L1 4109 SJMP 4109 80 FE Stop the program
OUTPUT:
INPUT OUTPUT
DATA 1 08 4500 0C
DATA 2 04
RESULT:
Thus the assembly language program to perform Logical OR Operation using 8051
Performed and the result is stored.
EXPT.NO: 2d
DATE :
XOR OPERATION:
AIM:
To perform Logical EX-OR Operation using 8051 microcontroller.
ALGORITHM:
1. Get the input value and store data in the accumulator.
PROGRAM:
Label Address Mnemonics Hex code Comments
Op code Operand
START 4100 CLR C C3 Clear CY Flag
4101 MOV A, #06 74 06 Get the data1 in Accumulator
4103 XRL A, #02 34 02 XOR Acc with immediate data
4105 MOV DPTR, #4500 90 4500 Initialize the memory location
4108 MOVX @DPTR, A F0 Store the result in memory location
L1 4109 SJMP 4109 80 FE Stop the program
OUTPUT:
INPUT OUTPUT
DATA 1 06 4500 04
DATA 2 02
RESULT:
Thus the assembly language program to perform Logical EX-OR Operation using
8051 Performed and the result is stored.
IAR Embedded Workbench
Project Management
Follow the steps to create a new project. Install the IAR Embedded Workbench IDE.
1. Click on the IAR Embedded Workbench icon in the Start menu.
2. The window with workspace and IAR Information Center for ARM will appear as
follows
3. Create the New Project. Provide the name for your project which must be related to your
application so that you can easily access the file. Click Project-> Create New Project…
4. Create New Project Dialog Box appears. Click in the empty project. Check that the tool
chain is ARM or not. If not choose the ARM tool chain and click Ok
5. Choose the correct directory in which you want to keep your projects and files. Give the
project name in the save as window.
Inside the workspace window the project which is created in the previous step is getting
added as like the following picture.
6. Create a file, which is the application code. Click File-> New->File to write the new file
7. Enter the code in the new file. Name it and save it in the same directory. While saving
use the extension like filename.c.
8. Add the file with your project. Right click on project in the workspace window and click
Add-> Add “filename.c” (or click on Project-> Add Files, then choose the file to be
added with your project).
After adding your file with your project you can see that your file is getting added with your
project in the workspace window. Additional Output folder is also created in the same space.
9. Copy the folder INC which is the header files for your device and STM_lib.a file which
is the library file for your device. These are given to you with the sample programs.
12. Mention the output file format. Click Output Converter->Generate Additional Output->
Output Format-> Intel Extended. Click Override Default. The filename.hex will be
created in the specified directory.
13. Click Linker->Config->Overide Default. Choose the configuration file from
$TOOLKIT_DIR$\config\linker\ST\stm32f407xG.icf.
The ST-link Utility is used to download the output file into the device. In the IAR
Embedded Workbench make the following options to use the ST-Link for downloading. Do the
following steps for downloading the code into target board.
1. In the Options window, Click Debugger->Setup->Drivers, Choose ST-LINK.
Aim:
To study the ARM evaluation system, general features and architecture overview of
the STM32F407VG controllers.
Theory:
Introduction
The STM32F407VGcontroller is based on the high-performance ARM
Cortex™-M4F 32-bit RISC core operating at a frequency of up to 168 MHz. The
ARM Cortex M4 processors are high performance embedded processors which has
several capabilities. The Cortex-M4Fcore features a Floating point unit (FPU) single
precision which supports all ARM singleprecisiondata-processing instructions and
data types. It also implements a full set of DSPinstructions and a memory protection
unit (MPU) which enhances application security.
General Features
The features of the STM32F407VG are
i) 100 pin LQFP Package
ii) ARM CORTEX 32-bit RISC core
iii) Operating Voltage 1.8V to 3.6V
iv) 4-to-26 MHz crystal oscillator
v) Memories
– Up to 1 Mbyte of Flash memory
– Up to 192+4 Kbytes of SRAM
vi) Low power Sleep, Stop and Standby modes
vii) 82 GPIOs
viii) 3×12-bit, 2.4 MSPS A/D converters (ADC)
ix) 2×12-bit D/A converters
x) General-purpose DMA: 16-stream DMAcontroller with FIFOs and burst
support
xi) Up to 17 timers: each timer can operate in IC/OC/PWM or pulse counter mode
xii) Up to 15 communication interfaces
– Up to 3 × I2C interfaces (SMBus/PMBus)
– Up to 4 USARTs/2 UARTs (ISO 7816 interface, LIN, IrDA,
modemcontrol)
– Up to 3 SPIs
– 2 × CAN interfaces (2.0B Active)
– SDIO/MMC interface
xiii) Advanced connectivity
– USB 2.0 full-speed device/host/OTGcontroller
– USB 2.0 high-speed/full-speeddevice/host/OTG controller with dedicated
DMA
– 10/100 Ethernet MAC with dedicated DMA:supports
xiv) 8- to 14-bit parallel camera interface up to54 Mbytes/s
xv) CRC calculation unit, 96-bit unique ID
xvi) RTC: subsecond accuracy, hardware calendar
Architecture Overview
System architecture:
The main system consists of 32-bit multilayer AHB bus matrix that interconnects:
● Height masters: – Cortex™-M4F core I-bus, D-bus and S-bus
– DMA1 memory bus
– DMA2 memory bus
– DMA2 peripheral bus
– Ethernet DMA bus
– USB OTG HS DMA bus
● Seven slaves: – Internal Flash memory ICode bus
– Internal Flash memory DCode bus
– Main internal SRAM1 (112 KB)
– Auxiliary internal SRAM2 (16 KB)
– AHB1peripherals including AHB to APB bridges and APB peripherals
– AHB2 peripherals
– FSMC
The bus matrix provides access from a master to a slave, enabling concurrent access
andefficient operation even when several high-speed peripherals work simultaneously.
Block Diagram
BusMatrix
The BusMatrix manages the access arbitration between masters. The arbitration uses
around-robin algorithm.
AHB/APB bridges (APB): The two AHB/APB bridges, APB1 and APB2, provide
full synchronous connections between the AHB and the two APB buses, allowing
flexible selection of the peripheral frequency.
Adaptive real-time memory accelerator (ART Accelerator): It balances the
inherent performance advantage of the ARM Cortex M4F so that the CPU can operate
up to 168 MHz frequency without wait states, thereby increasing the overall system
speed and efficiency.
CRC calculation unit: The CRC (cyclic redundancy check) calculation unit is used to
get a CRC code from a 32-bit data word and a fixed generator polynomial. Among
other applications, CRC-based techniques are used to verify data transmission or
storage integrity.
Brownout reset (BOR): During power on, the Brownout reset (BOR) keeps the
device under reset until the supply voltage reaches the specified VBOR threshold.
Programmable voltage detector (PVD): Programmable Voltage Detector is used to
monitor the VDD/VDDA power supply by comparing it to a threshold selected.
Reset and clock control (RCC): The clock controller provides a high degree of
flexibility to the application in the choice of the external crystal or the oscillator to run
the core and peripherals at the highest frequency and, guarantee the appropriate
frequency for peripherals that need a specific clock. The maximum frequency of the
AHB domain is 168 MHz. The maximum allowed frequency of the high-speed APB2
domain is 84 MHz. The maximum allowed frequency of the low-speed APB1 domain
is 42 MHz
Inter-integrated circuit interface (I²C): Up to three I²C bus interfaces can operate in
multimaster and slave modes. They can support the Standard- and Fast-modes.
Universal synchronous/asynchronous receiver transmitters (USART): The
STM32F407VG embed four universal synchronous/asynchronous receiver
transmitters (USART1, USART2, USART3 and USART6) and two universal
asynchronous receiver transmitters (UART4 and UART5).
Aim:
To develop a ‘C’ language program to flash the LEDs
Theory:
LEDs (Light Emitting Diodes) are basic display devices used almost all areas of digital world
from small scale to large scale. The attractive colors and different shapes of the LEDs enable the
digital world as a colorful environment. The applications of this efficient and environmentally-
friendly light source are endless, however, there are 5 main fields of application: automotive use,
backlight sources for consumer electronics, display screens for advertising, electronic equipment,
and general lighting.
Here onboard LEDs are used for flashing. Port D (PD8 to PD11) is connected with LEDs. To
operate the LED in Port D assign the Port D as output port.
Procedure:
1. Create New Project in the specified directory using IAR Embedded Workbench
2. Enter the ‘C’ program given below in the file
3. Add the file with your project. Make changes in the options.
4. Power on the device and connect the ST-Link USB cable from PC to device.
5. Download the code into the controller using ST-LINK
6. Reset the device
7. The onboard LEDs will be flashing
*Header Files*/
#include"stm32f4xx.h"
/*Delay Function*/
void delay()
long int i;
for(i=0;i<9000000;i++);
void led_init()
/*Main Routine*/
void main()
{
led_init();
while(1)
GPIOD->ODR = 0X0F00;
delay();
GPIOD->ODR = 0X0000;
delay();
Result
Thus the ‘C’ program is developed to flash LEDs
INTERFACING ADC AND DAC
Aim:
To develop a C-Language program toconvert the analog data given through potentiometer to
digital data using ADC and convert it back into analog data using DAC.
Theory:
ADC
The Analog to Digital Converter (ADC) is a device that converts continuously varying analog
quantity (usually voltage) into digital quantity which represents the quantity’s amplitude. The
STM32F407VG hasthree 12-bit ADC which is a successive approximation analog-to-digital
converter. It has up to 19multiplexed channels allowing it to measure signals from 16 external
sources, two internalsources, and the VBAT channel. The A/D conversion of the channels can be
performed insingle, continuous, scan or discontinuous mode. The result of the ADC is stored into a
leftorright-aligned 16-bit data register.It is possible to perform faster conversion by reducing the
ADC resolution.
DAC
The Digital to Analog Converter (DAC) performs the reverse operation of ADC. The DAC
converts digital quantity (usually binary) into analog quantity (voltage, current or electrical charge).
The DAC module in the STM32F407VG is a 12-bit, voltage output digital-to-analog converter. The
DAC can beconfigured in 8- or 12-bit mode and may be used in conjunction with the DMA
controller. In12-bit mode, the data could be left or right-aligned. The DAC has two output channels,
eachwith its own converter.
Procedure:
1. Create New Project in the specified directory using IAR Embedded Workbench
2. Enter the ‘C’ program given below in the file
3. Add the file with your project. Make changes in the options.
4. Power on the device and connect the ST-Link USB cable from PC to device.
5. Download the code into the controller using ST-LINK
6. Connect RS-232 or USB cable with your PC and Check the COM Port
7. Open the WinXTalk/Hyper Terminal Software at 115200 Baudrate in your PC
8. Reset the device.
9. Rotate the potentiometer (varying voltage), the corresponding digital data is displayed in the
PC. Since it is 12-bit ADC you will get 0 for 0V and FFF (4095 in decimal) for 3.0V.
10. The digital data is again converted into analog data by means of DAC. The DAC output can
be viewed by using CRO/DS.
*Header Files*/
#include "stm32f4xx.h"
#include <stdio.h>
/*Declarations*/
int ConvertedValue = 0;
void adc_configure()
{
void dac_configure()
GPIOA->MODER |= 0x00000f00; // MODE Register PortA, PA4 & PA5 are analog!
int adc_convert()
return ADC3->DR;
void USART2_config()
{
/*Main Routine*/
int main(void)
USART2_config();
adc_configure();
dac_configure();
while(1)
return data;
Result:
Thus, the ‘C’ program is developed to interface ADC and DAC, so that the analog data is
converted into digital by means of ADC and this digital data is converted back into Analog data by
means of DAC.
INTERFACING PWM AND LED
Aim:
To develop a C-Language program tointerface PWM and LED, so that the brightness of the
LEDs can be varied with PWM signal.
Theory:
Pulse Width Modulation allows you to generate a signal with a specified frequency. The
PWM is an easy and powerful module designed to generate the square wave with the specified
frequency and duty cycle which reduces the human effort to write the code. Most of the embedded
controllers have in-built PWM module. The timer is associated with the PWM operation. The
STM32F407VG controllers have seventeen timers. Each timer is working in several modes like time-
base unit, input capture, output compare and PWM mode. The PWM is terminated in the I/O lines.
The LEDs are interfaced at the end of the I/O lines. By varying the duty cycle of the PWM signal the
brightness of the LEDs can be varied.
Timer3 is used here for PWM generation. The TIM3_CH1 and TIM3_CH2 are the two PWM
channels terminated in PC6 and PC7 respectively. The PWM modules are very supportive modules
VLEDD Module
for motor control applications.
Procedure:
1. Create New Project in the specified directory using IAR Embedded Workbench
2. Enter the ‘C’ program given below in the file
3. Add the file with your project. Make changes in the options.
4. Power on the device and connect the ST-Link USB cable from PC to device.
5. Download the code into the controller using ST-LINK
6. Connect the VLEDD module with VSK-SCM4 (P12 and P13 connectors)
7. Reset the Device
8. Press the Increment or decrement switches. According to the PWM signal the brightness of
the LEDs in the VLEDD module can be varied
*Header Files*/
#include "stm32f4xx.h"
/*Declarations*/
int duty;
void switch_config(void)
for(int i = 0; i <delay;i++)
void TIM3_Config(void)
RCC->AHB1ENR |= (1 << 2); //Clock for PORTC, Timer3 Channel is connected with PORTC
int switch_read()
int val;
if(duty_cycle <= 0)
duty_cycle =1;
delay(1000);
}
else if(val == 0x04) //If increment switch is pressed
delay(1000);
duty_cycle =1500;
/* main functions */
int main(void)
while(1)
Result:
Thus, the ‘C’ program to interface PWM and LED is developed, so that the brightness of the
LEDs are adjusted according to the PWM signal
INTERFACING KEYBOARD AND LCD
Aim:
To develop a C-Language program tointerface keypad and LCD.
Theory:
LCD
The LCD (Liquid Crystal Displays) is the smallest structure of the monitor which is used for
display purpose. The basic operation of the LCD is the alignment of crystal molecules as per the
applied voltage. The controller performs variety of operations that cannot be viewed by the end user.
The LCDs of different sizes are used to view the results. For example, in the washing machine the
LCD is interfaced to tell the customer what the process is going on and the time left for the process
to be completed.
The character LCDs are used to display only numbers, characters and some special characters. The
images can be displayed only by using graphics LCD. Here 16×2 Alphanumeric LCD is used. We
can display 16 characters per line. The command lines are RS (Register Select), RW (Read/Write)
and EN (Enable) are used to control the LCD functions. The Commands and data are given through
data lines. The brightness of the LCD can be adjusted with the help of potentiometer. Port E (PE5 to
PE15) is connected with the LCD lines.
Keypad
The keys are the input devices through which we can enter the input to the controller. Each
key has to be connected with each I/O line. To limit the number of I/O lines for key reading matrix
keyboard is used. The matrix keypad uses only half of the I/O lines when compared to the normal
key connections. Here 4×4 matrix keyboard is used for implementation. The keypad is connected
with the Port D.
Procedure:
1. Create New Project in the specified directory using IAR Embedded Workbench
2. Enter the ‘C’ program given below in the file
3. Add the file with your project. Make changes in the options.
4. Power on the device and connect the ST-Link USB cable from PC to device.
5. Download the code into the controller using ST-LINK Utility
6. Reset the device
7. Press any key in the matrix keypad. It is displayed in the LCD
/*Header Files*/
#include "stm32f4xx.h"
/*ptototype functions */
void pinout_config(void);
void Row1_check();
void Row2_check();
void Row3_check();
void Row4_check();
int val;
/*Main Routine*/
void main(void)
{
pinout_config(); //Pinout Configurations
while (1)
Row2_check();
Row3_check();
Row4_check();
void Row1_check()
/*1 st row */
lcd_out('C');
lcd_out('D');
lcd_out('F');
void Row2_check()
/*2nd row */
lcd_out('8');
lcd_out('9');
lcd_out('A');
lcd_out('B');
void Row3_check()
/*3rd row */
lcd_out('4');
lcd_out('5');
lcd_out('6');
lcd_out('7');
void Row4_check()
/*4th row*/
lcd_out('0');
lcd_out('1');
lcd_out('2');
lcd_out('3');
}
void delay(int a)
int i,j;
for(i=0;i<a;i++)
for(j=0;j<a;j++);
delay(200);
GPIOE->ODR = (comm<<8)|(0<<5); //write the data from 8th bit.(i.E) PD8 to PD15
delay(200);
delay(200);
GPIOE->ODR = (a<<8)|(1<<5); //write the data from 8th bit.(i.E) PD8 to PD15
delay(200);
GPIOE->BSRRH = 0x0080;//enable pin low
void pinout_config(void)
Result:
Thus the ‘C’ program is developed to interface keypad and LCD.
INTERFACING STEPPER MOTOR AND
TEMPERATURE SENSOR
Aim:
To develop a ‘C’ language program to read the temperature value through ADC and rotate
the stepper motor in the clockwise directison if the temperature is below 40 degrees and rotate the
stepper motor in the anti-clockwise direction if the temperature exceeds 40 degrees.
Theory:
Stepper Motor
Stepper motors, effectively have multiple "toothed" electromagnets arranged around acentral
metal gear. To make the motor shaft turn, first one electromagnet is given power,which makes the
gear's teeth magnetically attracted to the electromagnet's teeth. Whenthe gear's teeth are thus aligned
to the first electromagnet, they are slightly offset from thenext electromagnet.So when the next
electromagnet is turned on and the first will turn off, the gear rotatesslightly to align with the next
one and from there the process is repeated. Each of thoseslight rotations is called a "step." In that
way, the motor can be turned to a precised angle.There are two basic arrangements for the
electromagnetic coils: bipolar and unipolar.
Procedure:
1. Create New Project in the specified directory using IAR Embedded Workbench
2. Enter the ‘C’ program given below in the file
3. Add the file with your project. Make changes in the options.
4. Power on the device and connect the ST-Link USB cable from PC to device.
5. Download the code into the controller using ST-LINK
6. Connect the Stepper motor in P14
7. Connect the RS-232/USB cable to PC. Check the COM port
8. Open WINXtalk/Hyper Terminal at the baudrate of 115200
9. Reset the device
10. The temperature is displayed in the PC. If the temperature is below 40 degrees the stepper
motor is rotate in clockwise direction otherwise it is rotate in anti-clock wise direction.
Result
Thus, the ‘C’ program is developed to interface the stepper motor and temperature sensor.
EXPT.NO:
DATE :
AIM:
To write a program to Generate a Square waveform using 8051
microcontroller
APPARATUS REQUIRED:
1. 8 Bit Microcontroller Trainer kit
2. Keyboard
3. Power Guard
4. CRO
TABULATION:
RESULT:
Thus the 8051 Assembly Language Program for Generation of Square
Waveform was executed and Verified successfully.
EXPT.NO:
DATE :
APPARATUS REQUIRED:
1. 8 Bit Microcontroller Trainer kit
2. Keyboard
3. Power Guard
4. CRO
ORG 0x00
JMP START
ORG 0x30
START:
MOV A, P1 ; Load the first 8-bit number from port 1 into the accumulator
MOV B, P2 ; Load the second 8-bit number from port 2 into register B
ADD A, B ; Add the contents of B to the accumulator
MOV P3, A ; Store the result in port 3
SJMP $ ; Infinite loop to halt execution
OUTPUT:
INPUT OUTPUT
DATA 1 0A 4500 0F
DATA 2 05
RESULT:
Thus the assembly language program to perform the addition of two 8 bit
numbers using On-Chip ports 8051 microcontroller was Performed and the result
is stored.
EXPT.NO:
DATE :
APPARATUS REQUIRED:
1. 8 Bit Microcontroller Trainer kit
2. Keyboard
3. Power Guard
4. CRO
ORG 0x00
JMP START
ORG 0x23 ; Interrupt vector for serial interrupt
JMP SERIAL_ISR
ORG 0x30
START:
MOV TMOD, #20h ; Set Timer 1, Mode 2 for serial communication
MOV TH1, #0FDh ; Set baud rate to 9600 (assuming 11.0592 MHz crystal)
SETB TR1 ; Start Timer 1
MOV SCON, #50h ; Configure serial port for 8-bit data, enable receiver
SETB IE.4 ; Enable serial interrupt
SJMP $ ; Infinite loop to halt execution
SERIAL_ISR:
JNB TI, RECEIVE ; Jump if not transmit interrupt
CLR TI ; Clear transmit interrupt flag
PERFORM MULTIPLICATION
MOV A, SBUF ; Receive first 8-bit number
MOV R0, A ; Save it in R0
ACALL WAIT SERIAL ; Wait for next byte
MOV B, SBUF ; Receive second 8-bit number
MUL AB ; Multiply the two numbers
OUTPUT:
INPUT OUTPUT
DATA 1 0A 4500 32
DATA 2 05
RESULT:
Thus the assembly language program to perform the multiplication of two
8 bit numbers using Serial ports 8051 microcontroller was Performed and the
result is stored.
EXPT.NO:
DATE :
Design of a Digital Clock using Timers/Counters in
8051.
AIM:
To write a assembly program for blinking an LED along with a digital
clock using timers/counters in the 8051 microcontroller.
APPARATUS REQUIRED:
1. 8 Bit Microcontroller Trainer kit
2. Keyboard
3. Power Guard
4. CRO
MOV P2, #0xFF ; Initialize Port 2 as input port for setting the time
TIMER_DELAY equ 500 ; Delay value for timer interrupts (in milliseconds)
MOV TH0, #TIMER_DELAY_MS / 256 ; Load Timer 0 high byte with delay
MOV TL0, #TIMER_DELAY_MS % 256 ; Load Timer 0 low byte with delay
INC P1.0 ; Increment seconds on display (assuming connected to the first seg )
INC P1.1 ; Increment tens of seconds (assuming connected to the second seg)
INC P1.3 ; Increment tens of minutes (assuming connected to the fourth seg)
RETI
SKIP_MINUTE:
RETI
OUTPUT:
In this program, the LED connected to Port 1, pin 7 (P1.7) will blink at a
fixed rate while the digital clock runs. Adjust the TIMER_DELAY value to
change the blinking frequency of the LED.
RESULT:
Thus the assembly program for blinking an LED along with a digital clock
using timers/counters in the 8051 microcontroller was Performed and the result
is stored.