Shop OBEX P1 Docs P2 Docs Learn Events
Prop1 outputs.... — Parallax Forums

Prop1 outputs....

Question on the Prop 1 IO. As I understand it on the propeller, if I have three cogs sharing a single I/O pin with the dira set to output on that pin, and the cogs on that pin outputing a high, the state of that pin will be high until all of the cogs on that pin are output low state. So if a fourth cog is monitoring that same pin, it should only see a low on that pin when all cogs set to output on that pin are low. I want to be able to tell when each of three cogs are in a ready state (here designated low) on a single pin input to the monitoring cog.

Can the pin be damaged if I have cogs output low and some output high on that same pin at the same time?

Thanks

Comments

  • jmgjmg Posts: 15,149
    Can the pin be damaged if I have cogs output low and some output high on that same pin at the same time?

    No, that is taken care of in the Logic.

    Manual says:

    2. Pin Outputs are the result of OR'ing the output states of the cogs together. A cog's
    output state consists of the bits of its I/O modules (the Counters, the Video Generator, and the I/O Output Register) OR'd together then AND'd with the bits of its Direction Register.
    In essence, each I/O pin’s direction and output state is the “wired-OR” of the entire cog collective.
    This allows the cogs to access and influence the I/O pins simultaneously without the need for any resource arbiter and without any possibility of electrical contention between the cogs.
    The result of this I/O pin wiring configuration can easily be described in the following simple
    rules:
    A. A pin is an input only if no active cog sets it to an output.
    B. A pin outputs low only if all active cogs that set it to output also set it to low.
    C. A pin outputs high if any active cog sets it to an output and also sets it high.


  • Cluso99Cluso99 Posts: 18,069
    Don't forget all 3 cogs will need to set their DIRA[pin]:=1 to make it an output for that cog.
  • Cluso, I don't understand what your saying. A cog doesn't rely on other cogs to make a pin an output. Can you explain your statement a bit more?
  • kwinnkwinn Posts: 8,697
    Each cog has set it's own pin to an output "to make it an output for that cog.". IOW one cog does not make it an output for all the cogs using that pin to communicate.
  • Cluso99Cluso99 Posts: 18,069
    If each of the 3 cogs output to say pin 5, then those cogs not only need to do an output, but they also must set the DIR bit for pin 5. So I am saying remember to also set the DIR bit to 1.
  • Dave HeinDave Hein Posts: 6,347
    edited 2017-04-24 14:53
    OK, that makes it clearer. Thanks
  • Also recall reading in one of the manuals that a cog can "see" the current state of all pins. Can't seem to find the source of that, but may be able to determine it by experiment. Can one of the three cogs with the pin set to output can see that pin state as though an input? The pin is output 0 on the cog in question, can it see if the other two have also gone low? The pin is being used as READY* for the cog function for example and all must be low to do X function.
  • INA reports the actual hi/lo state of every pin, regardless of which cog is accessing it. However, absent communication other cogs, you cannot tell which cog -- if any -- has contributed to that state.

    -Phil
  • tomcrawfordtomcrawford Posts: 1,126
    edited 2017-04-25 01:29
    You can do the same function with a single long in hub memory. Assign one byte to each of the three (up to four) master cogs. Say "ready" is a zero. The master cogs each write its byte with wrbyte. The "slave" reads all three bytes with a rdlong; when it sees zero, all three masters are ready. All the reads and writes are atomic.

    Edit: Not only can the slave determine which master is not ready, but also why.
Sign In or Register to comment.