In another thread, I'm trying to decode a X10 Rf signal, basically a serial protocol.
When I came across GetTimeCounterP, I thought my dreams had come true.
But... I'm having trouble making it work.
It would appear that GetTimeCounterP starts counting on a High to Low transition. So it gets the Loigc 0 period first and then the Logic 1 period.
How do I get GetTimeCounterP to start on a Positive ie Low to High transition?
So that it gets the Loigc 1 period first and then the Logic 0 period.
There are long levels of Logic 0 between messages. This is the Idle state.
And I don't want to have to add an inverter. The PCB already exists.
The format is -
Header = 9mS at Logic 1, then 4.5mS at Logic 0
A received 0 (Zero) bit is indicated by 0.55mS at Logic 1, then 0.55mS at Logic 0
A received 1 (One) bit is indicated by 0.55mS at Logic 1, then 1.6mS at Logic 0
My code looks something like
Device = mega8, VCC=5;
Import FreqCount;
Define
ProcClock = 16000000; {Hertz}
SysTick = 10; {msec}
FreqTimer = Timer1;
Var
CntHigh,CntLow : word;
CntOverFlow : Boolean ;
Begin
SetFreqCountMode(TPulseBase100ms);
Loop
CntOverFlow:= GetTimeCounterP(CntHigh,CntLow);
If (CntHigh > 800) AND (CntHigh < 1100) {AND (CntLow > 350) AND (CntLow < 500)} then WriteLn(SerOut, 'HEADER='+IntToStr(CntHigh:6:2)+'ms '+IntToStr(CntLow:6:2)+'ms '); Endif;
If (CntHigh > 30) AND (CntHigh < 60) AND (CntLow > 30) AND (CntLow < 60) then ST:=ST+'0'; Endif;
If (CntHigh > 30) AND (CntHigh < 60) AND (CntLow > 150) AND (CntLow < 170) then ST:=ST+'1'; Endif;
if GetFreqCountOvrFlow <> 0 then
WriteLn(SerOut, ST);
St := '';
endif;
Neil.
When I came across GetTimeCounterP, I thought my dreams had come true.
But... I'm having trouble making it work.
It would appear that GetTimeCounterP starts counting on a High to Low transition. So it gets the Loigc 0 period first and then the Logic 1 period.
How do I get GetTimeCounterP to start on a Positive ie Low to High transition?
So that it gets the Loigc 1 period first and then the Logic 0 period.
There are long levels of Logic 0 between messages. This is the Idle state.
And I don't want to have to add an inverter. The PCB already exists.
The format is -
Header = 9mS at Logic 1, then 4.5mS at Logic 0
A received 0 (Zero) bit is indicated by 0.55mS at Logic 1, then 0.55mS at Logic 0
A received 1 (One) bit is indicated by 0.55mS at Logic 1, then 1.6mS at Logic 0
My code looks something like
Code
Device = mega8, VCC=5;
Import FreqCount;
Define
ProcClock = 16000000; {Hertz}
SysTick = 10; {msec}
FreqTimer = Timer1;
Var
CntHigh,CntLow : word;
CntOverFlow : Boolean ;
Begin
SetFreqCountMode(TPulseBase100ms);
Loop
CntOverFlow:= GetTimeCounterP(CntHigh,CntLow);
If (CntHigh > 800) AND (CntHigh < 1100) {AND (CntLow > 350) AND (CntLow < 500)} then WriteLn(SerOut, 'HEADER='+IntToStr(CntHigh:6:2)+'ms '+IntToStr(CntLow:6:2)+'ms '); Endif;
If (CntHigh > 30) AND (CntHigh < 60) AND (CntLow > 30) AND (CntLow < 60) then ST:=ST+'0'; Endif;
If (CntHigh > 30) AND (CntHigh < 60) AND (CntLow > 150) AND (CntLow < 170) then ST:=ST+'1'; Endif;
if GetFreqCountOvrFlow <> 0 then
WriteLn(SerOut, ST);
St := '';
endif;
Neil.