jgarff / rpi_ws281x

Userspace Raspberry Pi PWM library for WS281X LEDs
BSD 2-Clause "Simplified" License
1.77k stars 622 forks source link

GPIO pins acts "together" behaviour #391

Closed szafranski closed 4 years ago

szafranski commented 4 years ago

I found very weird issue/behaviour. When LED pin is changed to "12", both pins GPIO 12 and GPIO 18 are outputting the same signal. Looks like they are somehow "tied" together. Same behaviour occurs when there is "18" provided in the config file - GPIO 12 and GPIO 18 output the signal. So looks like when pin GPIO 18 is used, GPIO 12 cannot be used for other purposes. Few questions:

  1. Is this a known issue?
  2. Are there any other pin "pairs" that cannot be used together?
  3. Can MOSI on SPI1 bus on Raspberry Pi 3 B+ be used as data pin?
Gadgetoid commented 4 years ago

Pins BCM12 and BCM18 are indeed both PWM0, so if they're muxed to PWM mode then they will always have the same output. (mode Alt5 is PWM0 on BCM18 and mode Alt0 is PWM0 on BCM12)

You should be able to switch either BCM12 or BCM18 (depending on which pin you happen to be using to drive the LEDs) into regular GPIO mode (or an available alt mode) in order to use it elsewhere.

Both pins being switched into PWM mode when you're only attempting to use one might be a bug.

szafranski commented 4 years ago

They are acting together in pwm mode. Can they be untangled?

W dniu wt., 10.03.2020 o 11:42 Philip Howard notifications@github.com napisał(a):

Pins BCM12 and BCM18 are indeed both PWM0, so if they're muxed to PWM mode then they will always have the same output. (mode Alt5 is PWM0 on BCM18 and mode Alt0 is PWM0 on BCM12)

You should be able to switch either BCM12 or BCM18 (depending on which pin you happen to be using to drive the LEDs) into regular GPIO mode (or an available alt mode) in order to use it elsewhere.

Both pins being switched into PWM mode when you're only attempting to use one might be a bug.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jgarff/rpi_ws281x/issues/391?email_source=notifications&email_token=AFUHCADLEKY4CLKDWBVEWOLRGYKRZA5CNFSM4LACZTMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOK4VSI#issuecomment-597019337, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFUHCAFSXZG3Y7WHUR62PQ3RGYKRZANCNFSM4LACZTMA .

szafranski commented 4 years ago

I just got what you wrote. Thanks. So until that another pin is changed (in some another program etc) it will always act "together"?

jgarff commented 4 years ago

I just looked at the lower layer C code. It should only switch the pin you've selected, not both. I can't speak for higher layers though unfortunately.

It would also appear that these pins aren't changed back to previous settings on program exit, so it's possible that if you're playing with different ports, and haven't rebooted in between, this could also explain the behavior.

On Sat, Apr 4, 2020 at 10:23 AM szafranski notifications@github.com wrote:

I just got what you wrote. Thanks. So until that another pin is changed (in some another program etc) it will always act "together"?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jgarff/rpi_ws281x/issues/391#issuecomment-609052958, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACB55G7UMSJ3SITDUC57REDRK5NJVANCNFSM4LACZTMA .

szafranski commented 4 years ago

I was switching pins back and forth without reboot so that will explain that situation probably.

W dniu sob., 4.04.2020 o 18:42 Jeremy Garff notifications@github.com napisał(a):

I just looked at the lower layer C code. It should only switch the pin you've selected, not both. I can't speak for higher layers though unfortunately.

It would also appear that these pins aren't changed back to previous settings on program exit, so it's possible that if you're playing with different ports, and haven't rebooted in between, this could also explain the behavior.

On Sat, Apr 4, 2020 at 10:23 AM szafranski notifications@github.com wrote:

I just got what you wrote. Thanks. So until that another pin is changed (in some another program etc) it will always act "together"?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/jgarff/rpi_ws281x/issues/391#issuecomment-609052958 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACB55G7UMSJ3SITDUC57REDRK5NJVANCNFSM4LACZTMA

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jgarff/rpi_ws281x/issues/391#issuecomment-609055748, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFUHCAFRVRAZ56UTEGFOLRLRK5PN5ANCNFSM4LACZTMA .