Skip to content

Fixes and updates. #36

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 3 commits into from
Apr 11, 2023
Merged

Fixes and updates. #36

merged 3 commits into from
Apr 11, 2023

Conversation

iabdalkader
Copy link
Collaborator

* The current underlying DMA buffer Queue is not thread-safe and
in some cases it can corrupt the memory. Replace the underlying
DMA buffer container with a thread-safe implementation.
* Detect DAC underrun in available() and reset if needed. If DAC
stops for any reason, no buffers will become free again. We need
to detect this and abort.
* Flush all pending buffers when DAC is stopped. This releases back
all the buffers to the ready queue, and fixes an edge case where
DAC stops while holding all of the ready buffers.
* Check for NULL descriptor pointers in every function.
* Increase DMA stream priority to highest.
* Add new command to stop DAC ("k").
* Print memory usage.
* Increase max frequency to 128KHz.
* Use a smaller DMA buffer size and rework the wave generators
to support it.
@github-actions
Copy link

github-actions bot commented Apr 4, 2023

Memory usage change @ e21c57b

Board flash % RAM for global variables %
arduino:mbed_giga:giga 🔺 +136 - +632 +0.01 - +0.03 ❔ -176 - +8 -0.03 - 0.0
Click for full report table
Board examples/Advanced/ADC_Multi
flash
% examples/Advanced/ADC_Multi
RAM for global variables
% examples/Advanced/ADC_Multi_Channel
flash
% examples/Advanced/ADC_Multi_Channel
RAM for global variables
% examples/Advanced/ADC_Multi_To_DAC
flash
% examples/Advanced/ADC_Multi_To_DAC
RAM for global variables
% examples/Advanced/ADC_Serial_Plotter
flash
% examples/Advanced/ADC_Serial_Plotter
RAM for global variables
% examples/Advanced/ADC_To_DAC
flash
% examples/Advanced/ADC_To_DAC
RAM for global variables
% examples/Advanced/DAC_One_Channel
flash
% examples/Advanced/DAC_One_Channel
RAM for global variables
% examples/Advanced/DAC_Sine_wave
flash
% examples/Advanced/DAC_Sine_wave
RAM for global variables
% examples/Advanced/DAC_Two_Channels
flash
% examples/Advanced/DAC_Two_Channels
RAM for global variables
% examples/Beginner/Audio_Playback
flash
% examples/Beginner/Audio_Playback
RAM for global variables
% examples/Beginner/Waveform_Generator
flash
% examples/Beginner/Waveform_Generator
RAM for global variables
%
arduino:mbed_giga:giga 136 0.01 0 0.0 136 0.01 0 0.0 328 0.02 8 0.0 200 0.01 0 0.0 328 0.02 8 0.0 264 0.01 8 0.0 264 0.01 8 0.0 328 0.02 8 0.0 328 0.02 8 0.0 632 0.03 -176 -0.03
Click for full report CSV
Board,examples/Advanced/ADC_Multi<br>flash,%,examples/Advanced/ADC_Multi<br>RAM for global variables,%,examples/Advanced/ADC_Multi_Channel<br>flash,%,examples/Advanced/ADC_Multi_Channel<br>RAM for global variables,%,examples/Advanced/ADC_Multi_To_DAC<br>flash,%,examples/Advanced/ADC_Multi_To_DAC<br>RAM for global variables,%,examples/Advanced/ADC_Serial_Plotter<br>flash,%,examples/Advanced/ADC_Serial_Plotter<br>RAM for global variables,%,examples/Advanced/ADC_To_DAC<br>flash,%,examples/Advanced/ADC_To_DAC<br>RAM for global variables,%,examples/Advanced/DAC_One_Channel<br>flash,%,examples/Advanced/DAC_One_Channel<br>RAM for global variables,%,examples/Advanced/DAC_Sine_wave<br>flash,%,examples/Advanced/DAC_Sine_wave<br>RAM for global variables,%,examples/Advanced/DAC_Two_Channels<br>flash,%,examples/Advanced/DAC_Two_Channels<br>RAM for global variables,%,examples/Beginner/Audio_Playback<br>flash,%,examples/Beginner/Audio_Playback<br>RAM for global variables,%,examples/Beginner/Waveform_Generator<br>flash,%,examples/Beginner/Waveform_Generator<br>RAM for global variables,%
arduino:mbed_giga:giga,136,0.01,0,0.0,136,0.01,0,0.0,328,0.02,8,0.0,200,0.01,0,0.0,328,0.02,8,0.0,264,0.01,8,0.0,264,0.01,8,0.0,328,0.02,8,0.0,328,0.02,8,0.0,632,0.03,-176,-0.03

@iabdalkader
Copy link
Collaborator Author

Hi @aentinger can you please review this and if it looks good, merge and do another release ? Thanks.

Copy link
Contributor

@aentinger aentinger left a comment

Choose a reason for hiding this comment

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

Inhowfar is the new buffer implementation "threadsafe"? I'm asking because I'm not seeing any locking 🤔 .

@iabdalkader
Copy link
Collaborator Author

is the new buffer implementation "threadsafe"? I'm asking because I'm not seeing any locking

Yes it should be very safe, the old one shared the variables between push/pop producer/consumer sides, this one even if the tail/head is moved during push/pop it should still be safe and there's no shared size variable used. Also note we can't really use locking as the IRQ also needs to write to this queue, so we'll have to use critical sections, but I don't think anything else is needed, I also did some stress testing on this and couldn't find any issues.

@aentinger
Copy link
Contributor

Check, thanks for the clarification 👍

@aentinger aentinger self-requested a review April 11, 2023 11:52
Copy link
Contributor

@aentinger aentinger left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@aentinger aentinger merged commit c506380 into main Apr 11, 2023
@aentinger aentinger deleted the fix_queues branch April 11, 2023 11:53
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DMA DAC intialization is unstable Programming >2M Samples/sec on DAC seems to cause Giga board to hang
3 participants