arsal.javaid
New Member
How to calculate frequency of square wave with unknown frquency coming on P3.5 of 8051 controller in c?
my effort is as follows.plz help by modifying it.
i am not sure ,will the following program keep on counting or will calculate the pulses in one second..?
#include <AT89X51.H>
void msdelay(unsigned int);
void main()
{
unsigned char value;
T1=1; //make t1 an input
TMOD=0x06; //counter 1,mode 2 ,8 bit auto reload mode
TH1=0; //set count to 0
while(1) //repeat forever
{
do
{
TR1=1; //start timer
value=TL1; //store tL1 in value
P1=value; //place value on pins of p1
}
while(TF1==0); //wait here
TR1=0; //stop timer
TF1=0; //clear flag
}
}
void msdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
my effort is as follows.plz help by modifying it.
i am not sure ,will the following program keep on counting or will calculate the pulses in one second..?
#include <AT89X51.H>
void msdelay(unsigned int);
void main()
{
unsigned char value;
T1=1; //make t1 an input
TMOD=0x06; //counter 1,mode 2 ,8 bit auto reload mode
TH1=0; //set count to 0
while(1) //repeat forever
{
do
{
TR1=1; //start timer
value=TL1; //store tL1 in value
P1=value; //place value on pins of p1
}
while(TF1==0); //wait here
TR1=0; //stop timer
TF1=0; //clear flag
}
}
void msdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}