Solved - Best way to set/reset a pin from multiple cogs?
Christof Eb.
Posts: 1,241
Hi,
I need to use a pin as digital output and set it to high or low from different cogs. I have not yet found a description, what happens if I set the pin to high from one cog and set it to low from another one. There has been a description in P1 documents. So at the moment I believe that the cogs OR their outputs. A low cannot overwrite a high ( drvh ) from another cog. Is this true for P2 also?
Is there a Smartmode, which I could use instead of simple drvh drvl to achieve my goal?
Many thanks! Christof
Comments
Yes, OUT in the cogs is same as Prop1 behaviour.
Yes, Smartpins could be used to override pinout state. OUT is ignored then. P_TRANSITION (%00101) mode would do it. Each
WYPIN #1, #<pin number>
will toggle the pin. You kind of have to separately keep track of whether the pin is high or low since the smartpin doesn't tell you.Another way is just use the pin config fields to invert the pin output. Set both and OUT and DIR high then set P_INVERT_OUTPUT for a low and clear it for a high.
Another way is use DAC levels 255 for high and 0 for low.
Thanks a lot! - I will try to use P_INVERT_OUTPUT then.
Yes, this TAQOZ snippet works:
Not actually the Smartpin doing that. A Smartpin uses the X/Y/Z registers.
Well, if something can only be understood, if you read the Smartpin documentation, than this seems to be part of "Smartpin"?
To do the opposite of a given command seems to be something like artificial intelligence or own mind?
@evanh have to find that smartpin diagram…
Might be this one?
https://forums.parallax.com/discussion/comment/1545265/#Comment_1545265
Yes, that's the diagram.
I am being picky. And Chip has been unclear in the docs, yes. He doesn't appear to have a particular mind on pin vs smartpin.
Maybe dac level is most straightforward?
Guess would try that…