Bug fixes for rare glitches on WS2812B pixels (NeoPixels) and 030 errors on micro:bit V2 (1/3)#61
Open
kevinjwalters wants to merge 44 commits intolancaster-university:masterfrom
Open
Conversation
added 30 commits
July 25, 2025 22:59
… been sent to improve blocking behaviour of WS2812B.
…unction for NRF52PWM.
…ders to work. This deals with lancaster-university/codal-microbit-v2#241
…M.STOP. Using the hardware register changes in setStreamingMode in new setPwmLoopInten(). lancaster-university#59
…same as nrfx_pwm_stop() implementation. lancaster-university#59
Avoid dynamic memory allocations in interrupts by reusing existing ManagedBuffer, less cycles with reuse reducing likelihood of overrun. lancaster-university#59
…initialising lock with 0 value. lancaster-university#59
…ppening when PWM is not running. New irqtotalcount plus irqtotalcountatstart and irqtotalcountatstop per output. lancaster-university#59
…eded and did not appear to help. lancaster-university#59
… prevent spurious interrupts. lancaster-university#59
The wrapping counters need more care in comparisons with careful use of unsigned and signed values. lancaster-university#59
…filled before use. (1370 cycles faster at -O2). lancaster-university#59
added 14 commits
August 5, 2025 01:08
Something is amiss here, values can appear way below 10240 cycles. lancaster-university#59
…PWM values at end of output rather than use emptyBuffer. lancaster-university#59
…ful for an isPlaying() member function. lancaster-university#59
…TATS. Plus removed some of the older debug coding. lancaster-university#59
This was referenced Aug 15, 2025
Author
|
Unrelated to this I would be very grateful if you could discuss increasing the file system size from 24k to at least 32k with the creator (microbit-foundation/micropython-microbit-v2#226). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Tickets
This is one of a trio of PRs which fixes issues with
neopixel_send_buffer()used by MicroPython's:@finneyj @martinwork @microbit-carlos may be interested in this.
Summary
The summary of changes for all three PRs (this one has the bulk of them in
WS2812BandNRF52PWMclasses) is:volatileto variables in classes for better safety between main and interrupt handler codeWS2812B::play()fully blocking to prevent hazardous overlapping executions ofneopixel_send_buffer()- this was implemented using the existingdataWanted()perhaps not quite how it's intended to be used?nrfx_pwm_stop()+ sprinkling of event clears ofEVENTS_SEQENDemptyBuffererrorFlaganderrorFlagCumulative(not yet exposed via API or MicroPython)#ifdisabled currently: added detail pwm statistics and error counters with history and anomalying DMESG printing (only intended for future debugging - this could be removed)dataReadyNRF52TouchSensormore efficient.WS2812BtoNRF52PWMby reusing existing buffers, removing data initialisation forManagedBufferand optimised code - this required a minor addition to the interface forDataSourcePWM2_IRQnfrom 3 to 2.periodUs, remove of redundantsetSampleRate(), change lock initalisation inWS28128B- these had no impact on glitching bugs.I've highlighted the three things in bold italics which I think need the most reviewing.
The fixes were applied to a branch from master made on the 24th July 2025. This will clearly be different code to the production release where these bugs were originally observed:
MicroPython v1.18 on 2023-10-30; micro:bit v2.1.2 with nRF52833on a V2.2.1 micro;bit.The diff looks a lot bigger than it really is, the bulk of the lines are the PWM statistics code which is
#ifed out.Testing
The bug fixes have been tested:
Partner PRs:
Additional information (not required reading):