Skip to content

Fix for neopixels on <100MHz STM32 boards #2350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2019
Merged

Fix for neopixels on <100MHz STM32 boards #2350

merged 2 commits into from
Dec 6, 2019

Conversation

hierophect
Copy link
Collaborator

Unlike the Atmel and NRF ports, the STM32F series has many different max CPU speeds across the starter, foundation and advanced lines. At lower CPU speeds, the previous neopixel code encounters an issue where the cycle time required to change a GPIO pin begins to approach the maximum allowable logic high period for a neopixel 0 bit. This results in the neopixel outputting a strong white as every bit is evaluated as 1 rather than 0.

I had hoped to replace the system with a weighted one, where the processor cycles needed to change the GPIO pins would be subtracted from the timing, making timing consistent across all frequencies. Unfortunately, I haven't managed to get a fully dynamic system granular enough to be workable. In lieu of writing the whole thing in assembly, I've just shuffled the timing enough to hit acceptable timing across most frequencies. It should work on any ST chip higher than 84MHz, and is protected against optimization differences.

As a side note, if anyone's used the ARDUINO_ARCH_ARDUINO_CORE_STM32 code here, I'd be interested to know if it works, since I don't see how the theoretical timings it uses could cooperate with the 0.22us cycle time required for the functions it uses without added trickery. It might provide some insight on this issue.

Resolves #2346. @dhalbert, maybe you could also give it a shot on your dud feather and see if it helps at all?

Bin for Feather below, but it won't do anything other than not break - will be more relevant once #2315 passes review. Also applies to the F411 Discovery, if anyone else has one.
firmware.bin.zip

@hierophect hierophect added the stm label Dec 3, 2019
@hierophect hierophect requested a review from tannewt December 5, 2019 18:36
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thank you!

@tannewt tannewt merged commit 840f88b into adafruit:master Dec 6, 2019
@hierophect hierophect deleted the stm32-neopixel-fix branch December 6, 2019 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STM32: incorrect neopixel timings on 84MHz boards
2 participants