0% found this document useful (0 votes)
32 views71 pages

ES & IOT DESIGN LAB 2023-2024

The document is a practical record for students of the Electronics and Communication Engineering department at Adhiparasakthi College of Engineering, detailing various experiments conducted in the ET3491-Embedded System and IoT Design Lab during the academic year 2023-2024. It includes aims, algorithms, programs, and results for basic arithmetic operations, logical operations, and the use of the IAR Embedded Workbench IDE for project management. Each experiment is structured with a clear format, showcasing the assembly language programs executed on the 8051 microcontroller.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views71 pages

ES & IOT DESIGN LAB 2023-2024

The document is a practical record for students of the Electronics and Communication Engineering department at Adhiparasakthi College of Engineering, detailing various experiments conducted in the ET3491-Embedded System and IoT Design Lab during the academic year 2023-2024. It includes aims, algorithms, programs, and results for basic arithmetic operations, logical operations, and the use of the IAR Embedded Workbench IDE for project management. Each experiment is structured with a clear format, showcasing the assembly language programs executed on the 8051 microcontroller.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 71

OM SAKTHI

ADHIPARASAKTHI COLLEGE OF ENGINEERING


(NAAC ACCREDITED)
G. B. Nagar, Kalavai - 632 506, Ranipet District, Tamil Nadu.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

CERTIFICATE

Certificate that this is the Bonafide Record of the work done by,

Mr/Ms with Register Number Third


year / VIth Semester B.E - ELECTRONICS AND COMMUNICATION
ENGINEERING in Anna University during the year 2023-2024 in respect of Practical
ET3491-EMBEDDED SYSTEM AND IOT DESIGN LAB.

Submitted for the practical Examination held on _ at


ADHIPARASAKTHI COLLEGE OF ENGINEERING.

SIGNATURE OF FACULTY-IN-CHARGE SIGNATURE OF HEAD OF THE DEPARTMENT

Internal Examiner External Examiner

Date :

Place : KALAVAI
OM SAKTHI

ADHIPARASAKTHI COLLEGE OF ENGINEERING


(NAAC ACCREDITED)
G. B. Nagar, Kalavai - 632 506, Ranipet District, Tamil Nadu.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING

ET3491-EMBEDDED SYSTEM AND IOT DESIGN LAB

NAME :

REG.NO :

YEAR/SEM : III / VI
CONTENTS

SL. DATE NAME OF THE EXPERIMENT PAGE MARKS SIGNATURE


NO NO
INTERNAL MARKS STAFF INCHARGE
EXPT.NO: 1a
DATE :

BASIC ARITHMETIC OPERATIONS USING 8051

8 BIT ADDITION

AIM:

To write a program to add two 8-bit numbers using 8051 microcontroller.

ALGORITHM:

1. Clear Program Status Word.


2. Select Register bank by giving proper values to RS1 & RS0 of PSW.
3. Load accumulator A with any desired 8-bit data.
4. Load the register R 0 with the second 8- bit data.
5. Add these two 8-bit numbers.
6. Store the result.
7. Stop the program.
FLOW CHART:
Start

Clear PSW

Select Register

Load A and R0 with 8 – bit data‟s

ADD A & R0

Store the sum

Stop
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 ADDC A, #03 34 03 Add the data1 with data 2
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 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

Get Multiplier in ACCR

Get Multiplicand in B Register

Multiply A with B

Store Result in Memory

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:

Label Address Mnemonics Hex code Comments


Op code Operand
START 4100 MOV A, #05 74 05 Store data1 in accumulator
4102 MOV B, #03 75 F0 03 Store data2 in B register
4105 MUL AB A4 Multiply both
4106 MOV DPTR, #4500 90 4500 Initialize memory location
4109 MOVX @DPTR, A F0 Store lower order result
410A INC DPTR A3 Go to next memory location
410B MOV A, B E5 F0 Store higher order result
410D MOVX @DPTR, A F0
L1 410E SJMP 410E 80 FE Stop the 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

Get Dividend in ACCR

Get Divisor in B Register

Divide A by B

Store Quotient & Remainder in


Memory

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.

2. Get the Divisor in the B register.


3. Divide A by B.
4. Store the Quotient and Remainder in memory

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 :

BASIC LOGIAL OPERATIONS USING 8051

PROGRAM TO FIND 2‟S COMPLIMENT OF A NUMBER

AIM:
To write an assembly language to perform 1‟s and 2‟s complement number using
8051.

ALOGRITHM:

1. Get the value


2. Get the complement value of data.
3. Initialize the data pointer value as memory.
4. Move the complemented value to memory of data pointer.
5. Increment the value and memory.
6.Store the result in memory.
7.Stop the process.

PROGRAM:

Label Address Mnemonics Hex code Comments


Op code Operand
4100 MOV A, #05 74, 05 Get the initial value
4102 CPL A F4 Complement the value
4103 MOV DPTR, # 4500 90, 4500 Initialize the memory
4106 MOVX @ DPTR, A F0 Move the data to memory
4107 INC A 04 Increment Accumulator
4108 INC DPTR A3 Increment the memory
4109 MOVX @ DPTR, A F0 Move the value to memory
ECE: 410A SJMP 410A 80, FE Continue the process.

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.

2. Get the second values and store the B register.

3. Logical operation to perform the given number.

4. Store the output value in memory.

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.

2. Get the second values and store the B register.

3. Logical operation to perform the given number.

4. Store the output value in memory.

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.

2. Get the second values and store the B register.

3. Logical operation to perform the given number.

4. Store the output value in memory.

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

The IAR Embedded Workbench IDE—an overview


The IDE is the environment where all necessary tools—the toolchain—are integrated:
aC/C++ compiler, an assembler, a linker, an editor, a project manager with Make utility,and the
IAR C-SPY® Debugger. The tools used specifically for building your sourcecode are referred to
as the build tools.The compiler, assembler, and linker can also be run from a command line
environment,if you want to use them as external tools in an already established project
environment. The general features of the IAR Embedded Workbench are
 Well-known development environment for 8-bit, 16-bit and 32-bit platforms
 Maximum code inheritance capabilities
 Comprehensive
 Specific target support
 Highly customizable environment
 Powerful IDE allows to develop and manage complete embedded application
 External tools can be added

The integrated tools of the IAR Embedded workbench are


 The highly optimizing IAR C/C++ Compiler
 The IAR Assembler
 The versatile IAR ILINK Linker, including accompanying tools
 A powerful editor
 A project manager
 A command line build utility
 The IAR C-SPY® Debugger, a state-of-the-art high-level language debugger.

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.

10. Right click in the Project and click Options….

Options for node “filename”


Dialog Box will appear. Click on the
General Options->Target->Device.
Choose device as STM32F407VG
11. Mention the header file directory. Click C/C++ Compiler-> Preprocessor and add the
directory of the header files.

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.

14. Click->Linker->Library to include the STMlib.a library file as follows.


15. Compile your project. Click Project->Rebuild All.

16. Save the Workspace. Name it and Save it,


17. If there are no errors in your project then the output is generated in the specific directory.
If there are errors in the code then the error message is displayed in the message window.
By clicking double times on the error message the location of the error in the file is
indicated.
ST-Link for Downloading

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.

2. Click Debugger -> Download -> Use Flash Loaders.


3. Then Click ST-LINK and then choose Interface as SWD.

4. Close the Options window. Click Project->Download->Download active application.


The output file is downloaded into the target device. Before downloading the code, check
whether the USB Cable is connected in the ST-Link USB connector. If there is any problem in
the connection it is also intimated in the message window.If you have any problem in the
downloading even if your connections are made correct just disconnect the cable and connect it
again. To get the output just reset the device by pressing on the reset button. The output will be
executed till the next application is getting loaded. Since, the code is loaded into the Flash
memory the code will not be erased even the power is off.
STUDY OF ARM EVALUATION SYSTEM

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).

Serial peripheral interface (SPI): The STM32F407VG feature up to three SPIs in


slave and master modes in full-duplex and simplex communication modes. SPI1 can
communicate at up to 37.5 Mbits/s, SPI2 and SPI3 can communicate at up to 21
Mbit/s.
Inter-integrated sound (I2S): Two standard I2S interfaces (multiplexed with SPI2
and SPI3) are available. They can be operated in master or slave mode, in full duplex
and simplex communication modes, and can be configured to operate with a 16-/32-bit
resolution as an input or output channel. Audio sampling frequencies from 8 kHz up to
192 kHz are supported.
Audio PLL (PLLI2S): The devices feature an additional dedicated PLL for audio I2S
application. It allows to achieve error-free I2S sampling clock accuracy without
compromising on the CPU performance, while using USB peripherals.
Secure digital input/output interface (SDIO): An SD/SDIO/MMC host interface is
available, that supports three different databus modes: 1-bit (default), 4-bit and 8-bit.
The interface allows data transfer at up to 48 MHz, and is compliant with the SD
Memory
Ethernet MAC interface: The STM32F407VG devices provide an media access
controller (MAC) for ethernet LAN communications through an industry-standard
medium independent interface (MII) or a reduced medium-independent interface
(RMII).
Controller area network (bxCAN): The two CANs are compliant with the 2.0A and
B (active) specifications with a bitrate up to 1 Mbit/s. They can receive and transmit
standard frames with 11-bit identifiers as well as extended frames with 29-bit
identifiers.
Universal serial bus on-the-go full-speed (OTG_FS):The STM32F407VG embed an
USB OTG full-speed device/host/OTG peripheral with integrated transceivers. The
USB OTG FS peripheral is compliant with the USB 2.0 specification and with the
OTG 1.0 specification. It has software-configurable endpoint setting and supports
suspend/resume.
Universal serial bus on-the-go high-speed(OTG_HS): The STM32F407VG devices
embed a USB OTG high-speed (up to 480 Mb/s) device/host/OTG peripheral. The
USB OTG HS supports both full-speed and high-speed operations.
Digital camera interface (DCMI): STM32F407VG products embed a camera
interface that can connect with camera modules and CMOS sensors through an 8-bit to
14-bit parallel interface, to receive video data. The camera interface can sustain a data
transfer rate up to 54 Mbyte/s at 54 MHz.

Random number generator (RNG): STM32F407VG embed an RNG that delivers


32-bit random numbers generated by an integrated analog circuit.
General-purpose input/outputs (GPIOs): Each of the GPIO pins can be configured
by software as output (push-pull or open-drain, with or without pull-up or pull-down),
as input (floating, with or without pull-up or pull-down) or as peripheral alternate
function. Most of the GPIO pins are shared with digital or analog alternate functions.
Analog-to-digital converters (ADCs): Three 12-bit analog-to-digital converters are
embedded and each ADC shares up to 16 external channels, performing conversions in
the single-shot or scan mode. In scan mode, automatic conversion is performed on a
selected group of analog inputs.
Temperature sensor: The temperature sensor has to generate a voltage that varies
linearly with temperature. The conversion range is between 1.8 V and 3.6 V. The
temperature sensor is internally connected to the ADC1_IN16 input channel which is
used to convert the sensor output
voltage into a digital value.
Digital-to-analog converter (DAC): The two 12-bit buffered DAC channels can be
used to convert two digital signals into two analog voltage signal outputs.
Serial wire JTAG debug port (SWJ-DP): The ARM SWJ-DP interface is embedded,
and is a combined JTAG and serial wire debug port that enables either a serial wire
debug or a JTAG probe to be connected to the target.
Nested vectored interrupt controller: The nested vectored interrupt controller
(NVIC) is an embedded interrupt Controller that supports low latency interrupts
processing.
Timers and watchdogs: The STM32F407VG devices include two advanced-control
timers, eightgeneral-purpose timers, two basic timers and two watchdog timers. The
advanced-control timers (TIM1, TIM8) can also be considered as complete general-
purpose timers.Their 4 independent channels can be used for:
● Input capture
● Output compare
● PWM generation (edge- or center-aligned modes)
● One-pulse mode output

There are ten synchronizable general-purpose timers embedded in the STM32F407VG


devices. It include 4 full-featured general-purpose timers: TIM2, TIM5, TIM3, and
TIM4.The TIM2 and TIM5 timers are based on a 32-bit auto-reload up/downcounter
and a 16-bit prescaler. The TIM3 and TIM4 timers are based on a 16-bit auto-reload
up/downcounter and a 16-bit prescaler. The TIM9, TIM10, TIM11, TIM12, TIM13,
and TIM14 timers are based on a 16-bit auto-reload upcounter and a 16-bit prescaler.
TIM10, TIM11, TIM13, and TIM14 feature one independent channel, whereas TIM9
and TIM12 have two independent channels for input capture/output compare, PWM or
one-pulse mode output. They can be synchronized with the TIM2, TIM3, TIM4, TIM5
full-featured general-purpose timers. They can also be used as simple time bases.
Basic timers are TIM6 and TIM7. These timers are mainly used for DAC trigger and
waveform generation. They can also be used as a generic 16-bit time base.
Result:
The evaluation, general features and architecture of the STM32F407VG controller are
studied.
FLASHING OF LED

Aim:
To develop a ‘C’ language program to flash the LEDs

Apparatus & Software Required


1. VSK-SCM4 Development board.
2. IAR Embedded Workbench software.
3. ST-Link Utility
4. USB Cable

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

PROGRAM (FLASHING OF LEDS)

*Header Files*/

#include"stm32f4xx.h"

/*Delay Function*/

void delay()

long int i;

for(i=0;i<9000000;i++);

/*Function to Initialize LED*/

void led_init()

RCC->AHB1ENR = 1<<3; //enable clock for port D

GPIOD->MODER = 0X00550000; //enable pD8,pD9,pD10,pD11 as output mode

/*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.

Apparatus & Software Required:


1. VSK-SCM4 Development board.
2. IAR Embedded Workbench software.
3. USB Cable
4. CRO/DS
5. WinXTalk/Hyper Terminal Software

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.

INTERFACING ADC AND DAC :

*Header Files*/

#include "stm32f4xx.h"

#include <stdio.h>

/*Declarations*/

int ConvertedValue = 0;

/*Function to Configure ADC*/

void adc_configure()
{

RCC->APB2ENR |= 1<<10; //The ADC3 is connected the APB2 peripheral bus

RCC->AHB1ENR |= 1<<0; //ADC is connected with PORTA!

GPIOA->MODER |= 0x0000000F; //analog mode PA1,PA2

ADC3->CR2 = 0x00000003; //data right alignment, continuous conversion mode.

ADC3->SMPR2 = 0x00000030; //ADC3 channel-1 with 144 cycles

ADC3->SQR3 = 0x00000001; //rank1 to ADC3 channel-1

/*Function to configure DAC*/

void dac_configure()

RCC->APB1ENR |= 0x20000000; // Enable clock for DAC

DAC->CR |= 0x00000001; // DAC control reg, both channels ON

GPIOA->MODER |= 0x00000f00; // MODE Register PortA, PA4 & PA5 are analog!

/*Functoin to convert ADC*/

int adc_convert()

ADC3->CR2 |= 0x40000000; //Start of Conversion

while(! (ADC3->SR & 0x0002) ); //Wait for End Of Conversion

return ADC3->DR;

/*Function to Configure USART2*/

void USART2_config()
{

RCC->AHB1ENR |= 1 << 0; //clock to portA

RCC->APB1ENR |= 1 <<17; //clock to USART2

GPIOA->MODER |= 0x000000A0; //alternate function mode(PA2,PA3)

GPIOA->AFR[0] |= 0x00007700; //USART2 RX, TX

USART2->BRR = 0x16D; //115200 baud rate

USART2->CR1 = 0x200C; //Enable Transmission

/*Main Routine*/

int main(void)

USART2_config();

adc_configure();

dac_configure();

while(1)

ConvertedValue = adc_convert(); //Read the ADC converted value

printf("\n\r ADC value => %d",ConvertedValue); //print the ADC value

DAC->DHR12R1 =ConvertedValue; //Move the Digital value to DAC

int putchar(int data)

USART2->DR = (data & 0x01FF);

while((USART2->SR & 0x40) ==0)// Loop until the end of transmission


{}

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.

Apparatus & Software Required:


1. VSK-SCM4 Development board.
2. IAR Embedded Workbench software.
3. USB Cable
4. VLEDD-02 Board with connector

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

INTERFACING LED AND PWM :

*Header Files*/

#include "stm32f4xx.h"

/*Declarations*/

static int duty_cycle = 1 ;

int duty;

/*Fuction to configure increment and decrement switch*/

void switch_config(void)

RCC->AHB1ENR |= (1 << 4 ); // enable the clock to portE

GPIOE->MODER |= 0x00000000; //set portE as i/p mode

GPIOE->OSPEEDR = 0xAAAAAAAA; //Speed 50MHz

/*Function for delay*/


void delay(int delay)

for(int i = 0; i <delay;i++)

for(int j = 0;j < delay;j++);

/*Function to configure Timer3*/

void TIM3_Config(void)

RCC->APB1ENR |= (1 << 1); // clock for TIM3

RCC->AHB1ENR |= (1 << 2); //Clock for PORTC, Timer3 Channel is connected with PORTC

GPIOC->MODER |= 0x0000A000;//Alternate fuction mode

GPIOC->AFR[0] |= 0x22000000;//TIM3 Fuction

/*Function to read the switch*/

int switch_read()

int val;

val = ((GPIOE->IDR)&0x14); //Read PORTE

if(val == 0x10) //if decrement switch is pressed

if(duty_cycle <= 0)

duty_cycle =1;

duty_cycle--; //variable decrement

delay(1000);

}
else if(val == 0x04) //If increment switch is pressed

duty_cycle++; //variable increment

delay(1000);

if(duty_cycle >= 1500)

duty_cycle =1500;

return(duty_cycle); //return the value of the duty cycle

/* main functions */

int main(void)

TIM3_Config(); //Timer3 Configurations

switch_config(); //switch configuration

TIM3->ARR = 0x348; //25khz, Auto reload register

TIM3->PSC = 0; //Prescale register

TIM3->CCMR1 = (1 << 3); //enable channel1 preload register

TIM3->CCMR1 = (1 << 11); //enable channel2 preload register

TIM3->CR1 = (0 << 8 )| (0 << 9 );//Clock Division, Internal Clock

TIM3->CCMR1 |=(1 << 4) | (1 << 5 ) | (1 << 6 ); //PWM Mode for Channel 1

TIM3->CCMR1 |= (1 << 12 )| (1 << 13 ) | (1 << 14 ); //PWM mode for Channel 2

while(1)

duty = switch_read(); //receive switch value

TIM3->CCR1 = duty; // apply duty cycle

TIM3->CCER |= ( 1 << 0 ) | ( 1 << 1 ); //enable channel 1


TIM3->CCR2 = duty; //apply duty cycle

TIM3->CCER |= (1 << 4 ) | (1 << 5 ); //enable channel 2

TIM3->CR1 |= ( 1 << 0 ); //Enable Counter

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.

Apparatus & Software Required:


1. VSK-SCM4 Development board.
2. IAR Embedded Workbench software.
3. USB Cable

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

INTERFACING KEYBOARD AND LCD:

/*Header Files*/

#include "stm32f4xx.h"

/*ptototype functions */

void delay(int a);

void pinout_config(void);

void command_write(int comm);

void lcd_out(unsigned int a);

void Row1_check();

void Row2_check();

void Row3_check();

void Row4_check();

int val;

/*Main Routine*/

void main(void)

{
pinout_config(); //Pinout Configurations

command_write(0x38); //Function Set

command_write(0x01); //Clear Display

command_write(0x0C); //Cursor Off,0x0F for Cursor on

command_write(0x06); //Address auto increment

while (1)

command_write(0x87); //Choose Address 87

Row1_check(); //Check which key is pressed in the Rows

Row2_check();

Row3_check();

Row4_check();

/*Function to check the key in Row1*/

void Row1_check()

/*1 st row */

GPIOD->BSRRH = 0x0001; //low PD0

GPIOD->BSRRL = 0x000E; //high PD1 to PD3

val = (GPIOD->IDR)&0xF0; //status of D4 to D7

if(val == 0xE0) //1st column

lcd_out('C');

else if(val== 0xD0) //2nd column

lcd_out('D');

else if(val== 0xB0) //3rd column


lcd_out('E');

else if(val== 0x70) //4th column

lcd_out('F');

/*Function to check the key in Row2*/

void Row2_check()

/*2nd row */

GPIOD->BSRRH = 0x0002; //low PD1

GPIOD->BSRRL = 0x000D; //high PD0,PD2,PD3

val = (GPIOD->IDR)&0xF0; //status of D4 to D7

if(val == 0xE0) //1st column

lcd_out('8');

else if(val== 0xD0) //2nd column

lcd_out('9');

else if(val== 0xB0) //3rd column

lcd_out('A');

else if(val== 0x70) //4th column

lcd_out('B');

/*Function to check the key in Row3*/

void Row3_check()

/*3rd row */

GPIOD->BSRRH = 0x0004; //low PD2


GPIOD->BSRRL = 0x000B; //high PD0,PD1,PD3

val = (GPIOD->IDR)&0xF0; //status of D4 to D7

if(val == 0xE0) //1st column

lcd_out('4');

else if(val== 0xD0) //2nd column

lcd_out('5');

else if(val== 0xB0) //3rd column

lcd_out('6');

else if(val== 0x70) //4th column

lcd_out('7');

/*Function to check the key in Row4*/

void Row4_check()

/*4th row*/

GPIOD->BSRRH = 0x0008; //low PD3

GPIOD->BSRRL = 0x0007; //high PD0,PD1,PD2

val = (GPIOD->IDR)&0xF0; //status of D4 to D7

if(val == 0xE0) //1st column

lcd_out('0');

else if(val== 0xD0) //2nd column

lcd_out('1');

else if(val== 0xB0) //3rd column

lcd_out('2');

else if(val== 0x70) //4th column

lcd_out('3');
}

void delay(int a)

int i,j;

for(i=0;i<a;i++)

for(j=0;j<a;j++);

void command_write(int comm)

delay(200);

GPIOE->BSRRH = 0x0020; //low RS pin

GPIOE->ODR = (comm<<8)|(0<<5); //write the data from 8th bit.(i.E) PD8 to PD15

GPIOE->BSRRL = 0x0080; //enable pin high

delay(200);

GPIOE->BSRRH = 0x0080; //enable pin low

/*Function to write a data to be displayed in the LCD*/

void lcd_out(unsigned int a)

delay(200);

GPIOE->BSRRL = 0x0020; //high RS pin

GPIOE->ODR = (a<<8)|(1<<5); //write the data from 8th bit.(i.E) PD8 to PD15

GPIOE->BSRRL = 0x0080;//enable pin high

delay(200);
GPIOE->BSRRH = 0x0080;//enable pin low

/*Function to configure the GPIO*/

void pinout_config(void)

RCC->AHB1ENR |= 1<<3; // enable the clock to portD,

RCC->AHB1ENR |= 1<<4; //enable clock to portE

GPIOD->MODER |=0x00000055; //set port PD0-PD3 as o/p mode

GPIOE->MODER = 0X55555500; // lcd_pins PE4 to PE15 output pins

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.

Apparatus & Software Required:


1. VSK-SCM4 Development board.
2. IAR Embedded Workbench software.
3. USB Cable
4. Stepper Motor
5. RS-232/USB cable to PC
6. WinXTalk/Hyper Terminal Software

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 :

Generation of Square waveform using 8051

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

PROGRAM TO GENERATE A SQUARE WAVEFORM :

MOV P1, #0X00 ; Initialize Port 1 as output port


MAINLOOP:
SETB P1.0 ; Set pin P1.0 high to generate square wave
ACALL DELAY ; Call delay subroutine
CLR P1.0 ; Clear pin P1.0 to generate square wave
ACALL DELAY ; Call delay subroutine
SJMP MAINLOOP ; Jump back to the main loop
DELAY:
MOV R2, #0FFh ; Load R2 with 255
DELAY_LOOP:SS
MOV R1, #0FFh ; Load R1 with 255
DELAY_LOOP_2:
DJNZ R1, DELAY_LOOP_2 ; Decrement R1 and jump if not zero
DJNZ R2, DELAY_LOOP ; Decrement R2 and jump if not zero
RET ; Return from subroutine
OUTPUT:

TABULATION:

AMPLITUDE TIME PERIOD

RESULT:
Thus the 8051 Assembly Language Program for Generation of Square
Waveform was executed and Verified successfully.
EXPT.NO:
DATE :

Programming using On-Chip Ports in 8051


AIM:
To write a program to perform the addition of two 8 bit numbers using On-
Chip ports 8051 microcontroller

APPARATUS REQUIRED:
1. 8 Bit Microcontroller Trainer kit
2. Keyboard
3. Power Guard
4. CRO

PROGRAMMING USING ON – CHIP PORTS

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 :

Programming using Serial Ports in 8051


AIM:
To write a program to perform the multiplication of two 8-bit numbers
using Serial ports 8051 microcontroller

APPARATUS REQUIRED:
1. 8 Bit Microcontroller Trainer kit
2. Keyboard
3. Power Guard
4. CRO

PROGRAMMING USING ON – CHIP PORTS

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

SEND THE RESULT OVER SERIAL PORT


MOV SBUF, A ; Send the lower byte of the result
ACALL WAIT_SERIAL ; Wait for transmission to complete
RECEIVE:
CLR RI ; Clear receive interrupt flag
WAIT_SERIAL:
JNB TI, WAIT_SERIAL ; Wait until the transmit is complete
RETI ; Return from interrupt

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

PROGRAMMING USING ON – CHIP PORTS

ORG 0x0000 ; Define origin

MOV P1, #0x00 ; Initialize Port 1 as output port for LED

MOV P2, #0xFF ; Initialize Port 2 as input port for setting the time

TIMER_DELAY equ 500 ; Delay value for timer interrupts (in milliseconds)

TIMER_DELAY_MS equ (65536 - (TIMER_DELAY * 1000) / 921.6) ;

MOV TMOD, #0x01 ; Set Timer 0 in mode 1 (16-bit timer)

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

SETB TR0 ; Start Timer 0

SETB EA ; Enable global interrupts

LED_STATE equ 0 ; Define initial LED state

MAINLOOP: ; Main loop

SJMP MAINLOOP ; Repeat indefinitely


TIMER0_ISR: ; Timer 0 interrupt service routine

INC P1.0 ; Increment seconds on display (assuming connected to the first seg )

CJNE P1.0, #10, SKIP_MINUTE ; Check if seconds reached 10

MOV P1.0, #0 ; Reset seconds to 0

INC P1.1 ; Increment tens of seconds (assuming connected to the second seg)

CJNE P1.1, #6, SKIP_MINUTE ; Check if tens of seconds reached 6

MOV P1.1, #0 ; Reset tens of seconds to 0

INC P1.2 ; Increment minutes (assuming connected to the third segment)

CJNE P1.2, #10, SKIP_HOUR ; Check if minutes reached 10

MOV P1.2, #0 ; Reset minutes to 0

INC P1.3 ; Increment tens of minutes (assuming connected to the fourth seg)

CJNE P1.3, #6, SKIP_HOUR ; Check if tens of minutes reached 6

MOV P1.3, #0 ; Reset tens of minutes to 0

INC P1.4 ; Increment hours (assuming connected to the fifth segment)

CJNE P1.4, #10, SKIP_HOUR ; Check if hours reached 10

MOV P1.4, #0 ; Reset hours to 0

SKIP_HOUR: Toggle LED state CPL P1.7

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.

You might also like