Shop OBEX P1 Docs P2 Docs Learn Events
Restart a COG (not so easy question!) — Parallax Forums

Restart a COG (not so easy question!)

mistikomistiko Posts: 2
edited 2009-11-21 17:38 in Propeller 1
Hi all,

my question should appear simple: "How can I restart a cog?" but I think it's not so easy. I have some assembly·code running into a cog and I want to restart its execution from another cog. According to documenation·COGINIT can be used to start or restart a cog but when used to "restart" the effect is that the cog is stopped and the code is re-loaded from hub memory into cog memory (and some time this is simply too slow and useless).
I simply want to restart the execution of code inside a cog without reloading it from hub memory. The code to be executed·is already in the cog memory and I need to restart its execution, why reloading it from hub memory?
I need to restart a cog·avoiding code reload from hub memory into cog memory because this is really sloooow (due to hub access restrictions)·for my application.
A simple, clean restart of a cog should be possible but honestly I dinn't find·how to do it,·maybe someone can help me.

Thanks in advance.

Marco

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-11-21 17:37
    Marco,

    The only way to do what you want is to poll a hub location for a flag that's set by the other cog. When your assembly program sees that the flag is set, clear it and do a jmp #0 to restart the cog.

    -Phil
  • AribaAriba Posts: 2,690
    edited 2009-11-21 17:38
    Hello Marco

    Welcome to the forum.

    Restart of a cog without releoading the code is not possible. I missed this many times, and suggested such an instruction for Prop II.
    With such an instruction it would be possible to use 1 cog as an interrupt controller, which restarts other cogs according pin states or timeouts or ....
    With the existing Propeller you can only poll a HubRam location or a pin in the cog and restart it by itself with a jmp #0.

    Andy
Sign In or Register to comment.