what happens if pin number is out of range
TWRackers
Posts: 33
I'm looking at a piece of code I downloaded from OBEX, and there's a variable named "Strobe" which is used to select one of the 32 I/O pins on the Propeller. The documentation says "Strobe" can be set to -1 if the pin is to remain unused. Farther down are several places where OUTA[Strobe] is used to set the state of the selected pin, but there's no code to guard against the Strobe == -1 case. What do the DIRA / OUTA / INA commands do if the selected pin number is < 0 or > 31? Would these be NO-OPs, or would only the low 5 bits of the pin number be used to force it in range?
Comments
Since -1 is just 32 one bits, OUTA[Strobe] would access I/O pin 31 if Strobe is -1. I/O pin 31 is normally an input pin, so the use of OUTA[ 31 } would have no effect.
so the direction bit is left alone if Strobe == anything negative. I assume it's done that way so that either (non-negative) the pin is set to output, or (negative) it's left alone for the other cogs to deal with. But wouldn't that imply that if ANOTHER cog were to set pin 31 (if Strobe == -1) to output, that THIS cog would start changing pin 31's state too even if it was intended that there be no strobe generated? Recall that ONLY the DIRA command is guarded by an IF, not the OUTA commands.