Pulsein stop program in absence of input pulses
FX
Posts: 4
Hi All,
I have a problem with BS2 Functions Library Object Version 1.5.1 primary author Martin Hebel
PUB PULSIN (Pin, State) : Duration
{{
Reads duration of Pulse on pin defined for state, returns duration in 2uS resolution
Shortest measureable pulse is around 20uS
Note: Absence of pulse can cause cog lockup if watchdog is not used - See distributed example
x := BS2.Pulsin(5,1)
BS2.Debug_Dec(x)
}}
in absence of input pulses the program does not proceed.
Where can I find instructions / example in note for use watchdog and avoid program stop ?
Thanks in advance
Francesco
I have a problem with BS2 Functions Library Object Version 1.5.1 primary author Martin Hebel
PUB PULSIN (Pin, State) : Duration
{{
Reads duration of Pulse on pin defined for state, returns duration in 2uS resolution
Shortest measureable pulse is around 20uS
Note: Absence of pulse can cause cog lockup if watchdog is not used - See distributed example
x := BS2.Pulsin(5,1)
BS2.Debug_Dec(x)
}}
in absence of input pulses the program does not proceed.
Where can I find instructions / example in note for use watchdog and avoid program stop ?
Thanks in advance
Francesco
Comments
So, what you can to is have a simple function (e.g. measure) for the measurement. You add a variable for example named pulseinOK and set it to false before running the measure-function.
The function itself calls x:=BS2.Pulsin ... and then sets puseinOK to true.
In the place where you are interested in the measurement you don't call the function directly. You use a COGNEW( measure, @somestack)
Now you have to wait until either the pulseinOK is set to true or the time you want to wait has passed. If the time has passed you can stop the COG.
Without knowing more about your problem and what you need the pulsein for, this can only be a general advice, which might turn out to be usefull or maybe not (in case your timings are though the additional COGNEW might be no option).