frequency counting using 8051

Status
Not open for further replies.

arsal.javaid

Newbie level 1
Joined
Dec 22, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
pakistan
Activity points
1,289
i have written the following code in keil to calculate frequency of pulses coming on 8051 microcontroller. but the code does not work well
#include <reg51.h>

void msdelay(unsigned int);
void main( )
{
P1=0x00;
P2=0x00;
T0 = 1; //(make T0 an input)
TMOD = 0x05; // 0000 0101 (C/T = 1, mode 1)
TL0 = 0;
TH0 = 0; //clear counters

TR0=1; //start timer
while(1)
{
msdelay(1000);
P1 = TL0;
P2 = TH0;
TR0=0;
}
}
void msdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}


if any body please help me i will be very thankful
 

#include <reg51.h>

void msdelay(unsigned int);
void main( )
{
P1=0x00;
P2=0x00;
T0 = 1; //(make T0 an input)
TMOD = 0x05; // 0000 0101 (C/T = 1, mode 1)
TL0 = 0;
TH0 = 0; //clear counters


while(1)
{
P1 = TL0;
P2 = TH0;
TL0 = 0;
TH0 = 0; //clear counters
TR0=1; //start timer
msdelay(1000);
TR0=0;
TF0=0;
}
}
void msdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}



MAKE SURE YOU PROVIDE INPUT AT PIN 12(P3.4)

REGARDS
KJ
http://www.free8051projects.blogspot.com/
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…