This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

measuring time between two events ...?????

Hi there...

I would like to measure the time between two events.
I think, I must use a timer in "counter mode"
If I am on the right track..here goes my code:


#include <REG167.H>
#include <stdio.h>

sbit DP2_0 = DP2^0;
sbit DP2_1 = DP2^1;
sbit L_SWITCH = P2^0;
sbit R_SWITCH = P2^1;

void main(void)
{ T3CON = 0x0009;// as counter T3R = 1; //start timer
while(1) { if(L_SWITCH== 0)//if left switched is pressed {

T3R = 1; //start timer T3UD = 0; // Count up T3IN = L_SWITCH; // input from ext

printf("COunter started"); }

if(R_SWITCH== 0) { T3R=0; //stop timer printf("Counter = %3u\r",T3); } }
}

/*************************************************/

</b >

Problem I guess is "T3IN".....in debugger it's not getting activated n hence the output is always 0...

Would appreciate if get an expert opinion.

Thanx.

Amit

0