Switching on a cog - once!
Hello there,
I've a bit of problem with enabling a cog, which is shown in the code space below:
However, the program works, but it didn't initialize the cog once, but a lot of times according to the loop, causing the system to stutter.
How can I turn the cog on once, and latch it? I know it could be a basic programming question, but I couldn't figure this one out.
I've a bit of problem with enabling a cog, which is shown in the code space below:
some program loop here:
repeat
|-- ...
|-- ...
|-- IF (alarm)
|-- coginit(3, anotherCog, @stack3)
|-- ...
However, the program works, but it didn't initialize the cog once, but a lot of times according to the loop, causing the system to stutter.
How can I turn the cog on once, and latch it? I know it could be a basic programming question, but I couldn't figure this one out.

Comments
VAR byte alarm byte alarmCog long stack3[20] PUB start repeat '... '... if alarm if alarmCog == 0 alarmCog := cognew(anotherCog, @stack3) + 1 '... '...Generally using coginit is frowned upon.