Prop go to sleep? or
I have not yet figured out what happens when this program i.e the code in the PUB come to its end.
I thought the pin output should remain high!
By adding a repeat I can hold high, but then I stucked in that object.
This is the whole I compile
PUB Main
·· dira[noparse][[/noparse]16] := 1
·· outa[noparse][[/noparse]16] :=1
What I want to do is as in a "normal" MPU like the AVR I have a code which via interupt toggles a pin with a LED.
The main purpose is you can se that the program is running.
Also how to implement a watchdog routine, any ideas?
Goran·
I thought the pin output should remain high!
By adding a repeat I can hold high, but then I stucked in that object.
This is the whole I compile
PUB Main
·· dira[noparse][[/noparse]16] := 1
·· outa[noparse][[/noparse]16] :=1
What I want to do is as in a "normal" MPU like the AVR I have a code which via interupt toggles a pin with a LED.
The main purpose is you can se that the program is running.
Also how to implement a watchdog routine, any ideas?
Goran·
Comments
then within the repeat loop have an 'IF' condition to call a different Pub etc....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Necessity is the mother of invention'
A watchdog routine can be done by starting another cog with COGNEW which waits for some period of time using WAITCNT, then checks whatever you want, then waits again.
It start to make sense now.
So compared with a MPU which has interupt and built in watchdog, I need to use one cog for the purpose of a watchdog.
I have to dig in to this
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski
It depends on why you want a watchdog timer. For example, a "true" watchdog timer requires the use of a cog because the timer has to run independently from anything else running. On the other hand, sometimes you just want a timeout. Since the system clock is running independently, you can easily test to see if a future time is exceeded like in this code fragment:
If you look in the Propeller manual under abort, you'll see that this works like "catch"/"throw" or other similar mechanisms in other languages.
I made a small code based on your input.
Used a new cog· with a small asm where a got both the watchdog and the LED blinking (so you can see that the program runs).
Now I have to refine the code and test it with my main program.(debugging is sometime timeconsuming)
Regards, Goran
I'm shure that is not what you want.
What if the clocks fails or varies in frequency?
A watchdog should always use an independent clock.
Ideally that's true. Practically, it may not be necessary. It depends on what you're protecting against. It may be that if the clock fails or varies in frequency enough to affect the "watchdog" timer, then your system has deteriorated to the point where there's nothing functioning to respond to a watchdog interrupt. There's nothing like a "fail-safe" interrupt that is never responded to.
In the case of the Propeller, the clock circuitry is robust and unlikely to fail. It's possible for a crystal to fail under very high mechanical shock loads, but you can buy crystals designed to resist that if that's a problem. The most likely problem is a programming failure when the clock mode is changed either deliberately (to reduce power consumption) or accidently (when a program "scribbles" all over itself and the Spin interpreter essentially executes garbage). If that's a concern, I think you would need a more extensive "fail-safe" design than just an independent watchdog timer.