arsal.javaid
Newbie level 1
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
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