Repository navigation
Conversation
In task dispatch, each channel collects its values in a CHANNELS_BUFFERS_SIZE-slot buffer that only data.get*() empties. The count stops at CHANNELS_BUFFERS_SIZE, but the write used it as an index: a channel the application never fetches (it only peeks, or does not read it) wrote one slot past its heap block every dispatch, and peek() returned a frozen value. A full buffer now keeps its last slot for the newest value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 2026
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.
Summary
In task dispatch, every enabled channel collects its values in a
CHANNELS_BUFFERS_SIZE-slot (32) buffer that onlydata.get*()empties. The count stops at 32, but the dispatch uses it as the write index:data_dispatch_do_dispatch(adc) for each new DMA sample current_count = count of the channel + if current_count >= CHANNELS_BUFFERS_SIZE + current_count = CHANNELS_BUFFERS_SIZE - 1 # keep the last slot for the newest value active_buffer[current_count] = sample # was: index 32, past the heap block increment count (stops at 32)When it happens: an application enables a channel and never fetches it with
get*(). It only peeks, or doesn't read that channel at all, for example a sensor enabled byenableDefaultSensors(). Then:peek()returns slot 31, which never changes: the reading freezes.Evidence
Test firmware on a Spin with the Twist 1.4.2 devicetree (env
STLink):enableDefaultSensors(), buck legs at 200 kHz;Over SWD, a marker 0xA5A5 is written at index 32 of each ADC1 channel buffer, then read back as the firmware runs:
mainpeek()returns)Merge Danger
Door: two-way
One check in the dispatch loop.
Blast Radius: unfetched channels
peek()follows the signal, and no write goes past the buffer.get*()each period never fill up.🤖 Generated with Claude Code