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

Task 3

The document outlines a microprocessor-based system design task requiring the generation of a signal on pin P1.1 with varying frequencies and duty cycles based on user button presses. It includes a detailed analysis of the required signal parameters for four cases and provides a C program to implement the functionality. The task also involves verifying the output using an oscilloscope to observe the signal changes.
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)
6 views6 pages

Task 3

The document outlines a microprocessor-based system design task requiring the generation of a signal on pin P1.1 with varying frequencies and duty cycles based on user button presses. It includes a detailed analysis of the required signal parameters for four cases and provides a C program to implement the functionality. The task also involves verifying the output using an oscilloscope to observe the signal changes.
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 3

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
Sunday, May 1st, 2021

Department of Computer Systems Engineering


University of Engineering and Technology, Peshawar
Task:
A. Generate a signal on pin P1.1 having frequency equal to 80 Hz with a duty cycle of 10%.
B. When a user presses a button at P1.2 then frequency changes to 40Hz with a 20% duty
cycle.
C. When a user again presses the same button then frequency changes to 20Hz with a duty
cycle of 40%.
D. When a user again presses the same button then frequency changes to 10Hz with a duty
cycle of 80%.
E. Show it on oscilloscope.
F. Each time a user presses a button the signal toggles from case A to B, then B to C, then C
to D and finally from D to A, on every subsequent button press.
G. Program only in C

Problem Analysis:
Case A: To generate a signal of frequency 80Hz we need a time period of 1/80 s
So T = 1/f = 1/80 = 0.0125s
T = 12.5 ms
As Duty Cycle is 10%, so
P1.1 ON (1.25 ms)
P1.1 OFF(11.25 ms)
Case B: To generate a signal of frequency 40Hz we need a time period of 1/40 s
So T = 1/f = 1/40 = 0.025s
T = 25 ms
As Duty Cycle is 20%, so
P1.1 ON (5 ms)
P1.1 OFF(20 ms)
Case C: To generate a signal of frequency 20Hz we need a time period of 1/20 s
So T = 1/f = 1/20 = 0.05s
T = 50 ms
As Duty Cycle is 40%, so
P1.1 ON (20 ms)
P1.1 OFF(30 ms)
Case D: To generate a signal of frequency 10Hz we need a time period of 1/10 s
So T = 1/f = 1/10 = 0.10s
T = 100 ms
As Duty Cycle is 80%, so
P1.1 ON (80 ms)
P1.1 OFF(20 ms)
Code:
#include <reg51.h>
#include <stdio.h>

sbit P1_1 = P1^1;


sbit P1_2 = P1^2;

void Delay(unsigned int time)


{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<123;j++);
}

void Delay1() //Delay of 0.25 ms


{
unsigned int i;
for(i=0;i<30;i++);
}

void main(void)
{
int check=0;
P1_2 = 1; //Configure for Input

while (1)
{
if(P1_2==0) //Button Pressed
check++;
switch(check%4)
{
case 0:
P1_1 = 1;
Delay(1); //1ms Delay
Delay1(); //0.25ms Delay
P1_1 =0;
Delay(11); //11ms Delay
Delay1(); //0.25ms Delay
break;
case 1:
P1_1 = 1;
Delay(5); //5ms Delay
P1_1 =0;
Delay(20); //20ms Delay
break;
case 2:
P1_1 = 1;
Delay(20); //20ms Delay
P1_1 =0;
Delay(30); //30ms Delay
break;
case 3:
P1_1 = 1;
Delay(80); //80ms Delay
P1_1 =0;
Delay(20); //20ms Delay
break;
}
}
}

Output / Graphs / Plots / Results:


Circuit Diagram:
Oscilloscope Verification:

Case A (Without Pressing the Button):

Case B (After Pressing the Button):

Case C (Pressing the Button for the 2nd Time):


Case D (Pressing the Button for the 3rd Time):

You might also like