0% found this document useful (0 votes)
102 views

Bec0355 Micro Lab Task 05

This document describes an 8051 microcontroller program that uses timer interrupts to generate two different frequencies on an output port. Timer 0 is configured to generate a 500Hz waveform on P1.0 by reloading the timer with 0xFC66 after each overflow interrupt. Timer 1 is configured to generate a 7kHz square wave on P1.1 by reloading with 0xFFBE after each overflow interrupt. The program is tested using the logic analyzer in KEIL IDE and outputs frequencies of 492.571Hz on P1.0 and 6776.47Hz on P1.1, approximating the desired 500Hz and 7kHz frequencies.
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)
102 views

Bec0355 Micro Lab Task 05

This document describes an 8051 microcontroller program that uses timer interrupts to generate two different frequencies on an output port. Timer 0 is configured to generate a 500Hz waveform on P1.0 by reloading the timer with 0xFC66 after each overflow interrupt. Timer 1 is configured to generate a 7kHz square wave on P1.1 by reloading with 0xFFBE after each overflow interrupt. The program is tested using the logic analyzer in KEIL IDE and outputs frequencies of 492.571Hz on P1.0 and 6776.47Hz on P1.1, approximating the desired 500Hz and 7kHz frequencies.
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/ 7

MICROCONTROLLER AND ITS APPLICATIONS

ECE 3003
LAB SLOT: L1+L2
PROF. PADMINI T. N
VELLORE INSTITUTE OF TECHNOLOGY
2021-2022
LAB TASK- 05
KEIL SIMULATOR SOFTWARE

DINESH HANUMATH KUMAR


19BEC0355
Q.) Write an 8051 assembly program using timer 0 to generate
a 500 Hz waveform and timer 1 to generate a 7 kHz square
wave frequency on P1.0 and P1.1 respectively using timer
interrupts. Then examine the frequency using the KEIL IDE
inbuilt Logic Analyzer.
Note: Calculations for time delay and the general format of
the special function register (SFR) used in the program
should be specified.
Report should contain:
1. General Format of sfr.
2. Time delay calculation.
3. The codes with comments
4. Results obtained (screen shot).

KEIL SIMULATOR CODE:


//19BEC0355 DINESH HANUMATH KUMAR
ORG 0000H
LJMP MAIN; By Pass Interrupt Vector Table
// ISR FOR TIMER 0
ORG 000BH; Timer 0 Vector Interrupt Table
CPL P1.0; Toggle P1.0 Pin
MOV TL0,#66H
MOV TH0,#0FCH
RETI; Return from ISR

ORG 001BH; Timer 1 Interrupt Vector Table


CPL P1.1; Toggle From ISR
MOV TL1,#0BEH
MOV TH1,#0FFH
RETI; Return from ISR
ORG 30H
MAIN:MOV TMOD,#00010001B; Timer 0 in Mode 1 and Timer 1 in Mode 1
MOV TL0,#66H; Lower Bit to Generate 500HZ Frequency
MOV TH0,#0FCH; Upper Bit to Generate 500HZ Frequency
MOV TL1,#0BEH; Lower Bit to Generate 7KHZ Frequency
MOV TH1,#0FFH; Upper Bit to Generate 7KHZ Frequency
MOV IE,#8AH; Enable Timer 0 and Timer 1 Interrupt
SETB TR0; Start Timer 0
SETB TR1; Start Timer 1
HERE:SJMP HERE; Looping till there is Interrupt
END

SPECIAL FUNCTION REGISTERS USED:


TMOD - 8 bit register which determines usage of timer 0/1 as
counter/timer and mode of operation. For timer 1 and 0 to be in mode 1,
TMOD will be set as 00010001b.

TCON-8 bit register which determines when the timers 0/1 are set
on/off(TR0 and TR1), also consists of timer overflow flags(TF0 and TF1)
and lower 4 bits control interrupt bits. In our program, we assign a high
bit to TR0 and TR1 to start the timers.

IE- 8 bit register which enables/disables interrupts from 2 timer


overflow interrupts(3 for 8952 microcontroller), 2 external interrupts
and 1 serial port interrupt. Once it detects an interrupt, it jumps to a
fixed location in memory depending on the interrupt. In our program,
instead of checking TF0/TF1, we check for timer overflow interrupts for
compliment our port values. We assign IE=10001010, IE(7) is high to
enable the interrupt register, IE(1)(jumps to 000BH location) and
IE(3)(jumps to 001BH location) enable Timer 0 and Timer 1 interrupt
respectively.
CALCULATIONS:
1.) FOR 500HZ
Time period = 1/500 =0.002s.
ON Time = 0.002/2 = 0.001 = 1 ms.
(65536-X)*1.085 *10^(-6) = 0.001
X= 65536-922 = 64614.
X= (FC66)H.
2.) FOR 7KHZ
Time period = 1/7000 =0.000142s.
ON time = 0.000142/2 = 0.0000714.
(65536-X)*1.085 *10^(-6) = 0.0000714.
X= 65536-66 = 65470.
X= (FFBE)H.
OUTPUTS:
The Frequency of wave generated in PORT 1.0 is 492.571Hz Which is
approximately 500Hz.(BLUE WAVE)
The Frequency of wave generated in PORT 1.1 is 6776.47Hz Which is
approximately 7KHz (BLACK WAVE).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy