P2 pin direction instructions do these work??

I am using spin tools ide and get errors. Do these work
Titus Rev 5 06-11-2020 Jon Titus, Page 1 of 62
Pin-Direction Instructions
DIRL {#}D Set direction bit(s) to logic 0 (input)
DIRH {#}D Set direction bit(s) to logic 1 (output)
DIRC {#}D Set direction bit(s) to Carry flag
DIRNC {#}D Set direction bit(s) to inverse of Carry flag
DIRZ {#}D Set direction bit(s) to Zero flag
DIRNZ {#}D Set direction bit(s) to inverse of Zero flag
DIRRND {#}D Set direction bit(s) to random state(s)
DIRNOT {#}D Invert direction bit(s)
Example: DIRL #20 'Set P20 as an input pin
Pin-Output Instructions
OUTL {#}D Set output bit(s) to logic 0
OUTH {#}D Set output bit(s) to logic 1
Thanks.
I am trying to replicate the outa and dira in spin 1
I keep seeing references but can't pin it down.
Thanks
Also in pintoggle can it multiple pins in a pattern something like this: %0101??
Comments
Yes, they work. OUTA/DIRA registers also work the same as they did on Prop1.
All pin ops, including
PINTOGGLE
, operate on a range of pins. You can't have gaps in that range. If you want to have some of those pins set high and some set low and then flip them all at once then yep,PINTOGGLE
will do that.@evanh
Hey buddy,
been a while, hope all is good.
Thanks for the info.
Martin
Even though pintoggle can't do it, you could use XOR on the output port if just you wanted to toggle multiple non-contiguous IO pins in a group. But this can only change a single port worth (32 I/O pins) at a time.
For PASM
XOR outa, pin_mask ' pin_mask are the bits you want to toggle .e.g #%1001000111011
For SPIN
outa ^= %11001101
Now I just don't know if Chip's SPIN2 interpreter or flexspin directly converts this into a single XOR instruction operating directly on the OUTA hardware register or does a read/modify/write first (non-atomic). Probably doesn't matter in most cases as each COG has it's own copy of port output registers so other COGs can modify their own copy without affecting things. It would matter if interrupt service routines run but SPIN2 doesn't support them.
@rogloh
Thanks. I am porting some spin1 basic pin "toggling" to experiment with some steppers. Tried to get the stepper clicks to work no luck. Tried to get Adafruit stepper motor driver same A4988 chip no go. Tried Pololu version no luck decided to use L293D and build myself. I know that works. Will later do something more sophisiticated.
Appreciate the help. Was going through the P2 stuff and had some minor issues.
Martin