PASM version of pinwrite(pinfield, data)?
Phonos
Posts: 45
Is there a simple way to set non-contiguous pin values within a pinfield in a single PASM2 instruction? I am trying to turn non-contiguous Smart Pins on/off in the same clock cycle with a drvh/drvl type of mechanism and am unable to come up with the right approach.
Comments
You can write directly into OUTA and OUTB registers to affect pin states.
(pinwrite(base addpins ext), data)
is roughly equivalent to this (minus port a/b handling)
Infact, the actual pinwrite implementation in the Spin2 Interpreter (y and w are the parameters):
Of course if your pin numbers start on a multiple of 8, you might use SETBYTE instead of the longer SETQ/MUXQ approach. (same for SETIB/SETWORD).
Or if you just want to toggle pin states, you can obviously just a XOR instruction.
Thank you for the response. This makes sense but I have a problem implementing...
This code is intended to blink leds 56 and 59 (p_ext, p_base = 5, 24) but it doesn't. Am I close?
RES variables must always come after everything else, otherwise the addresses shift around and everything stops making sense.
Works like a champ; only the desired pinfield is modified. Thank you for the solution and for remedial PASM education.
I am having a problem understanding how this works. If I put the assembly code inline it works. If I put it in a cog it fails. Am I missing a fundamental consideration.
This version works:
This version does not:
Normally, you want your main to not return while other tasks are still going, put an empty repeat block after coginit (or coginit over cog 0, if you really want). Not sure if that's it though.
If I use outb in the led register it works. Apparently the bitc led,#9 instruction isn't modifying the register.
That would normally indicate missing ORG, but it seems to be there (i usually prefer explicit
ORG 0
but it shouldn't matter. Or does it? Am confused on this one, too.).I am confused too but now I have a version that works... sometimes I think I am losing my mind!