Reputation: 67
i'm using DS89C450 timer0 to count from 0 when the value of incoming data is '0' and it will only stop when the the data '1' and it will compare with the values i have. However, is it possible to store the value of how much the timer counted so i could use if loop for the comparing of the values.
For Example:
for(i=0;i<15;i++)
{
if(in_data == 0)
{
TH0 = 0x00; //Set Timer0 to count from 0
TL0 = 0x00;
TR0 = 1; //Start Timer0
if(in_data == 1) //if InputData = 1
{
TR0 = 0; //Stop Timer0
//Store Timer0 value under "TimerValue"
}
if(TimerValue == 2212) //If TimerValue = 2212(decimal)/08A4(Hex)
{
Data[i] = 0x00; //Set Data[i] = 0
}
}
Does anyone know is it possible to do so?
Upvotes: 1
Views: 443
Reputation: 15175
I'm guessing TH0
holds your timers value.
You should be able to find your your processors input size for this port in the handbook.
Then you can just
//since no more details are provided i'm assuming TH0 and TL0 are 8 bits
short TimerValue = (TH0 << 8) | TL0; // to store the value.
Upvotes: 1