Shop OBEX P1 Docs P2 Docs Learn Events
Trying to toggle pins in spin2 — Parallax Forums

Trying to toggle pins in spin2

@cgracey

I started with the blink example in Pnut34z:

pub go() | x

repeat
pinwrite(56 addpins 7, getrnd())
waitms(100)
This works.

Attempting to toggle individual pins went to the docs and tried several of the commands
nothing works.
Suggestions please.
Thanks
1097 x 628 - 58K

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2020-10-25 19:46
    I haven't used any of these instructions, but based on the documentation it looks like WRPIN(1, 1) is setting a smart pins field starting at bit 1 to a value of 1. I assume you intended to do the equivalent of pinh(1) instead.

    pinh(%111001) should be setting P57 high. Is that what you wanted to do?

    I think pinh(%10101100) should set P44 high assuming it ignores anything beyond the 6 least significant bits.
  • JonnyMacJonnyMac Posts: 8,927
    edited 2020-10-25 21:19
    The pin instructions would with one pin, or a pin group. To create a pin group you can use...
      pingroup := basepin ADDPINS count
    
    If count is 7, pingroup will consist of 8 pins from basepin to basepin+7. Once you have a group defined, you can use any of the commands, including pintoggle(pingroup) which will toggle all the pins in the group. Note, too, that the pinx instructions will take care of the direction bits for you, too.

    This works on the P2 Eval
      pingroup := 56 addpins 3
      pinwrite(pingroup, %0101)
      repeat
        waitms(250)
        pintoggle(pingroup)
    

    Looking at your listing I wonder if you're misunderstanding pinigh, pinlow, etc. Those commands act on the pin # or pin group that is passed to it.
  • I am trying to do work a seven seven segment display in a salvaged vfd display. Thanks
  • Thanks for the tips. Got it figured out.
Sign In or Register to comment.