Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/04/04 18:39
Read: times


 
#80382 - RE: frequency counter problem
Responding to: ???'s previous message
Hello Kai,
Sorry for writing so late. This is code that I have used.

//////////////////////////////////////

void Adc_Set() // initialisation of adc params
{
g_Adc_Start = 1;
g_Adc_End = 0;
g_Adc_Count = 0;
TH0 = 0;
TL0 = 0;
}

unsigned int Adc_Read() // reading the ADC(Freq)
{
unsigned int i;
unsigned char j,k;
j = TH0;
k = TL0;
i = (unsigned int)( j * 256) + (unsigned int)k;
return i;
}

void Timer2_Int(void) interrupt 5 using 1 // ISR for Timer 2 of 1ms .this timer is also used for 1 sec delay.//
{
TF2 = 0;
g_Count++;
g_One_Sec_Count = g_One_Sec_Count + 1;
if(g_One_Sec_Count == 100)
{
g_One_Sec_Count = 0;
g_Time_Count--;
if(g_Time_Count == 0)
g_Time_Over_Flag = 1;
}
if(g_Adc_Start == 1) // starts counting
{
TR0 = 1; // starts counting
g_Adc_Count ++; // counts 10 for 10ms delay //
if(g_Adc_Count == 10)
{
TR0 = 0; // stops counter
g_Adc_Start = 0;
g_Adc_End = 1;
}
}
}
main()
{
Timer_Init(); // timer initialisations
while(1)
{
if(g_Adc_Start == 0 && g_Adc_End == 0)
Adc_Set();
if(g_Adc_End == 1)
{
g_Adc_End = 0;
Tempint = Adc_Read();
Tempint = Tempint * 10;
sprintf(Char_Val,"%d",Tempint);
mpTransmitString(Char_Val);
mpTransmitChar(0x0d);
}
}
}

List of 9 messages in thread
TopicAuthorDate
frequency counter problem            01/01/70 00:00      
   RE: frequency counter problem            01/01/70 00:00      
      RE: frequency counter problem            01/01/70 00:00      
   RE: frequency counter problem            01/01/70 00:00      
   RE: frequency counter problem            01/01/70 00:00      
      RE: frequency counter problem            01/01/70 00:00      
         RE: frequency counter problem            01/01/70 00:00      
            RE: more            01/01/70 00:00      
   RE: frequency counter problem            01/01/70 00:00      

Back to Subject List