Shop OBEX P1 Docs P2 Docs Learn Events
Must base pins be factors of 8 when used with setnib? — Parallax Forums

Must base pins be factors of 8 when used with setnib?

ke4pjwke4pjw Posts: 1,179
edited 2025-02-15 02:28 in PASM2/Spin2 (P2)

Dumb question. It has been months since I have programmed the P2.

Are "base pins" required to be 0,8,16,24,32,40,48,56 ?

I want to do something like this, where tx is actually pin 44.

                 altsn     tx,#outa                             ' What is the base PIN?
                 setnib  pinnib                                ' Turn off the pins with 0 code

Comments

  • evanhevanh Posts: 16,234
    edited 2025-02-15 04:48

    That's fine. For SETNIB you are limited to multiples of four. It's not really a base pin but rather a cogRAM index.
    In terms of pin ops like PINH() a base pin can be any pin number, afaik.

  • ke4pjwke4pjw Posts: 1,179

    @evanh said:
    That's fine. For SETNIB you are limited to multiples of four. It's not really a base pin but rather a cogRAM index.
    In terms of pin ops like PINH() a base pin can be any pin number, afaik.

    Man, I lucked out when I placed those lines on pin 44 then :)

    As always, thanks evanh!

  • JonnyMacJonnyMac Posts: 9,225
    edited 2025-02-15 15:56

    Are you writing a group of four bits to a specific base pin? You could borrow from the Spin2 interpreter pinwrite() code. This works for any pin, though all four pins must be in the same 32-bit outputs register.

    pri write4(pin, value) | mask
    
      org
                            testb     pin, #5               wc      ' check for outa or outb
                            bitc      .write, #9                    ' adjust write register
                            mov       mask, #%1111                  ' make 4-pin mask
                            shl       mask, pin                     ' align to pin
                            shl       value, pin
                            or        pin, #%11_000000              ' make 4-pin group   
    
                            setq      mask 
    .write                  muxq      outa, value
                            dirh      pin                           ' enable pins
    
      end
    
  • ke4pjwke4pjw Posts: 1,179

    Hey @JonnyMac ! I just wanted to do minimal code changes to the pixel driver of yours that I modified to do 8 ports at a time, but instead just drive 4. (This is my hacked up 8 port driver, not your good multipin driver) I am current using:

                     altsb     tx,#outa                             ' What is the base PIN?
                     setbyte pinbyte                                ' Turn off the pins with 0 code
    

    I have built a "long range" board I that can plug into the quad RS-485 driver I have on my light controller. I designed the transmitter for DMX, but then realized I can also send ws2811 data to it to drive some of the problematic 80ft runs I have.

  • JonnyMacJonnyMac Posts: 9,225

    Interesting. I normally use a TC4427 for pixel driving. I wouldn't have thought the RS-485 driver would tolerate the narrow pulses of the WS2811 signal. Nice to know.

  • ke4pjwke4pjw Posts: 1,179

    @JonnyMac said:
    Interesting. I normally use a TC4427 for pixel driving. I wouldn't have thought the RS-485 driver would tolerate the narrow pulses of the WS2811 signal. Nice to know.

    From my research, RS-485 should be able to do 5Mbps at 100ft, which should be more than enough for the type of signaling used by pixels.

    I know other pixel controllers have been doing similar for years. They call this type of receiver a "dumb receiver". No MCU or anything, just pixel data.

    I will let you know how well it works.

  • evanhevanh Posts: 16,234
    edited 2025-02-17 06:10

    Those coloured lines on the graph don't look right. More jitter should come closer to the conservative line, not further away. Ie: The conservative line is rated for high level of jitter.

  • ke4pjwke4pjw Posts: 1,179

    @JonnyMac it works! This is though 210ft of cat-5e. The waveform looks square.

  • ke4pjwke4pjw Posts: 1,179
    edited 2025-02-19 15:17

    FYI: I had to change the way the pin group is calculated which was called out above, but I forgot to change. You need to divide the pin number by 4 instead of 8 (shift right 2 instead of 3). tx is my pin

    shr       tx, #3
    

    changed to

    shr       tx, #2
    

    That took a while for me to figure out. I had forgotten about having to do that in my code. Pin group 0 always works no matter if it is a nib/byte/etc. because it starts at 0. That's when I realized the problem and re-read what was stated in this post by @JonnyMac . The method I use to set the pin group is different.

  • RS_JimRS_Jim Posts: 1,772

    @ke4pjw
    terry, tried to watch video but get an error.
    jim

Sign In or Register to comment.