Skip to content

samd: neopixel: Fix neopixels after #2297 #2363

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 1 commit into from
Dec 10, 2019

Conversation

jepler
Copy link

@jepler jepler commented Dec 8, 2019

This adapts the "inline assembler" code from the UF2 bootloader, which in turn is said to be adapted from the arduino neopixel library.

It also ensures that the timing-critical code is also aligned with a cache line, so it should not be sensitive to changes in unrelated code like the old version was.

This requires the cache remain ON when using M0, and be turned OFF on M4 (determined by trial and error)

Testing performed on a Metro M4:

  • measured timings using o'scope and found all values within datasheet tolerance.
  • Drove a string of 96 neopixels without visible glitches
  • on-board neopixel worked

Testing performed on a Circuit Playground Express (M0):

  • Color wheel code works on built-in neopixels
  • Color wheel code works on 96 neopixel strip

As a bonus, this may have freed up a bit of flash on M0 targets. (2988 -> 3068 bytes free on Trinket M0 when I built locally)

@jepler
Copy link
Author

jepler commented Dec 8, 2019

@theacodes can you let me know if this works for you?

@jepler jepler requested a review from tannewt December 8, 2019 01:19
This adapts the "inline assembler" code from the UF2 bootloader, which
in turn is said to be adapted from the arduino neopixel library.

This requires the cache remain ON when using M0, and be turned OFF on M4
(determined by trial and error)

Testing performed on a Metro M4:
 * measured timings using o'scope and found all values within
   datasheet tolerance.
 * Drove a string of 96 neopixels without visible glitches
 * on-board neopixel worked

Testing performed on a Circuit Playground Express (M0):
 * Color wheel code works on built-in neopixels
 * Color wheel code works on 96 neopixel strip

As a bonus, this may have freed up a bit of flash on M0 targets. (2988 ->
3068 bytes free on Trinket M0)

Closes: adafruit#2297
@theacodes
Copy link

Yep, works for Sol boards. :)

@jerryneedell
Copy link
Collaborator

FWIW - fixes my grandcentral_m4 and metro_m4_airlift -- Thanks!

@tannewt
Copy link
Member

tannewt commented Dec 9, 2019

How does this work on a 48mhz core and a 120mhz core with the same delay values? What would happen if we changed the SAMD51 clock up to 180mhz?

@tannewt
Copy link
Member

tannewt commented Dec 10, 2019

We chatted on Discord and assume that the delays work on both due to the disabled cache on the SAMD51.

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.

Thanks for the fix!

@tannewt tannewt merged commit dda9ea0 into adafruit:master Dec 10, 2019
@jepler jepler deleted the samd-neopixel branch November 3, 2021 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants