Skip to content

NeoPixel does not work on RP2350B with GPIO pin >=32 #16190

@sfe-SparkFro

Description

@sfe-SparkFro

Port, board and/or hardware

rp2 port with RP2350B

MicroPython version

v1.24.0-preview.461.gb8227a3f7.dirty

Reproduction

import neopixel
import machine

pin = 32

p = machine.Pin(pin)
n = neopixel.NeoPixel(p, 1)

n[0] = (127, 0, 0)
n.write()

Expected behaviour

A NeoPixel connected to pin should illuminate.

Observed behaviour

A NeoPixel connected to pin only illuminates if pin is <32. If pin is >=32, the NeoPixel does not illuminate.

Additional Information

The root problem appears to be here:

static inline void mp_hal_pin_low(mp_hal_pin_obj_t pin) {
gpio_clr_mask(1 << pin);
}
static inline void mp_hal_pin_high(mp_hal_pin_obj_t pin) {
gpio_set_mask(1 << pin);
}

gpio_set_mask() requires a 32-bit value, so the shifted bit gets truncated when using a pin >= 32. There is a gpio_set_mask64(), however for some reason it didn't work when I tried it (I didn't dig into it). However changing to gpio_put() works fine on my end.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy