Experiment 1
-
Upload
indira-kundu -
Category
Documents
-
view
4 -
download
1
description
Transcript of Experiment 1
Experiment No. 2
Aim: Write a program to generate square wave of 50% duty cycle having frequency 5 KHz at port pin P2.1 using timer 1 in mode 2. Modify program to generate pulse waveform of 70% duty cycle using timer on the same pin.Circuit Diagram
Fig.1 Circuit diagram for generating the 50% duty cycle pulse having 5 kHz frequency on P2.1 pinWorksheet 2
1) Modify program for 80% duty cycle
Hint: Use separate delay loop for ON time and OFF time. Total time is 200 s, so use 160 s for ON time and 40 s for OFF time. You can also prepare delay subroutine of 10 s. Call delay subroutine 16 times for ON time and 4 times for OFF time.2) Execute following C program in Keil and measure frequency of the square
wave.
# include
#include
sbit wave_pin P1^0;
void sqdelay(unsigned int);
void main(void)
{
while(1)
{
wave_pin=1;
sqdelay(100);
wave_pin=0;
sqdelay(100);
}
}
void sqdelay(unsigned int t)
{
unsigned int i,j;
for(i=0;i