0% found this document useful (0 votes)
17 views6 pages

Task 5

The document outlines a microprocessor-based system design project for counting buses at a BRT entry point in Peshawar using an 89C51 microcontroller. It details the task requirements, including the use of timers to create a one-minute delay and the implementation of the system in C or Assembly language. The project includes a schematic, code, and results demonstrating the functionality of the system after simulating bus entries.
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)
17 views6 pages

Task 5

The document outlines a microprocessor-based system design project for counting buses at a BRT entry point in Peshawar using an 89C51 microcontroller. It details the task requirements, including the use of timers to create a one-minute delay and the implementation of the system in C or Assembly language. The project includes a schematic, code, and results demonstrating the functionality of the system after simulating bus entries.
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/ 6

MICROPROCESSOR BASED SYSTEM DESIGN

TASK 5

Spring 2021
CSE307 MBSD

Submitted by: Shah Raza


Registration No. : 18PWCSE1658
Class Section: B

“On my honor, as student of University of Engineering and Technology, I have neither given
nor received unauthorized assistance on this academic work.”

Student Signature: ______________

Submitted to:
Dr. Bilal Habib
Saturday, May 22, 2021

Department of Computer Systems Engineering


University of Engineering and Technology, Peshawar
Task:
At a BRT entry point in Peshawar, there is only one lane of busses to enter from GT-road. We have
connected a sensor which sends a signal (high-to-low edge) to our embedded system whenever a bus
passes through the entry-point and enters the Metro lane. Use an 89C51 to count the number of busses
passed though the entry point in one minute. As soon the one-minute time is over, it is indicated by
turning ON a led at P3.1 pin, send the final value of count to Port-2 and finally goes into an infinite loop,
doing nothing.
• Draw schematic along with timing diagram. Oscillator frequency is 12MHz.
• Entry of bus can be simulated using a button press.
• Use timers for creating a delay of 1 min.
Hint: Use timer interrupt. Feel free to use C or Assembly.
Problem Analysis:
We need a delay of 1 minute = 60 sec
1 sec = 1000msec
60 sec = 60000msec
65.535ms is the max delay we can create, so to attain a delay of 60000ms, we should create a delay
of 60ms and run it 1000 times.

Timer1 Timer0
Gate C/T M1 M0 Gate C/T M1 M0
0 0 0 1 0 1 1 0 (Hex= 16)

Timer 1: Used as Timer with mode 1


Timer 0: Used as Counter with mode 2
Timer 0 (Used as Counter in Mode 2):

Timer 1 (Used as timer in Mode 1):


Code:
#include <reg51.h>
#include <stdio.h>

sbit Input = P3^4; //Input for Counter 0


sbit Led = P3^1; //Output Led
int x;

void StartTimer()
{
TR1 = 1; //Start Timer 1
TR0 = 1; //Start Counter 0
}

void timer1() interrupt 1 //Called after each 60ms delay


{
x++;
//The if Comparison also takes some machine cycles so we check for 967 instead of 1000 to
match a delay of 1 minute
if(x==967) //delay of 1 minute = 60000ms reached
{
Led = 1; //Turn Led on after 1 minute
P2 = TL0; //Send the Counter Value to Port 2
while(1) //Go in infinite loop
{
}
}
//Reset the timer 1 values
TH1 = 0x15;
TL1 = 0x9F;
}

void initTimer()
{
TMOD = 0x16; //Timer 1 mode 1 and Counter 0 mode 2
//Delay of 60ms
TH1 = 0x15;
TL1 = 0x9F;
IE = 0x88; //Enable TF Enterrupt for Timer1
TH0 = 0; //Start Counter from 0
Input = 1; //Set for Input
}
void main(void)
{
Led = 0; //Turn Off the Led
P2 = 0; //Turn Off the Port 2
initTimer();
StartTimer();
while (1)
{
}
}

Output / Graphs / Plots / Results:


Schematic:
Output at 20sec (Button pressed 7 times):
Although the button is pressed 7 times, the result would not show now according to the given task. The
result will only appear after 60 seconds.

Output at 60sec (Button pressed 7 times):


Oscilloscope Verification:

As we can see, the Led is turned on exactly after 60 seconds.

You might also like