Shop OBEX P1 Docs P2 Docs Learn Events
Which RAM do COG parameters get stored in? — Parallax Forums

Which RAM do COG parameters get stored in?

MX21MX21 Posts: 7
edited 2006-05-09 19:31 in Propeller 1
While writing a spin application that used multiple cogs,
I ran into an unexpected result.· When I overran an
array in global RAM, it wiped out a parameter that had
already been passed into another cog!· I would have
expected that once a parameter was passed to the cog,
it would be stored internally, and would thus be protected.
Where are the parameters kept?· Everytime I access a
parameter on a cog, does it take a performance hit going
to shared RAM to fetch the parameter?

MX
·

Comments

  • cgraceycgracey Posts: 14,133
    edited 2006-05-09 17:48
    It takes 102.4us at 80MHz for a COG to launch, before it is able to load up the parameters from main memory. Be sure to allow some time for this to happen. Also, many assembly programs·reload the parameters periodically to get updated information about what they should be doing. If you write over those VARs in main memory, while the·other COG is·expecting something meaningful to be there, there will be trouble.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-09 17:57
    All Spin variables and parameters are stored in Main RAM (in its own stack) -- for this reason you should make your stack(s) bigger than you think until you can analyze actual use (Phil Philgrim has created a neat tool for doing this).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • MX21MX21 Posts: 7
    edited 2006-05-09 18:41
    So the only way to use the COG RAM is through assembly?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-09 19:31
    Yes.· Remember, there's not a lot: just 512 longs (2K bytes), and cog RAM can only be accessed from within the cog itself.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.