Repository navigation
Conversation
A pause (the p note) is reported with a frequency of 0 and was passed to the PWM driver like any other note. Drivers that refuse a 0 Hz frequency, such as the RA4 one, make PWMIOC_START fail with EINVAL. play_pwm() then printed an error and returned without waiting, so every pause was skipped, the following notes were played too early and one error line was printed per pause. Wait for the duration of the pause instead, with the output left stopped as it is after every note. Tested on a custom N32H760 board with a passive buzzer on a timer PWM output: a tune made of two pauses returns without an error after the expected delay and the timer stays stopped. Assisted-by: Claude Code:glm-5.4 Signed-off-by: JingYue LIAO <felix-liao@my.swjtu.edu.cn>
xiaoxiang781216
approved these changes
Nov 27, 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.
Note: Please adhere to Contributing Guidelines.
Summary
examples/audio_rttlplays every tone through a PWM device withPWMIOC_SETCHARACTERISTICS,PWMIOC_START,usleep()andPWMIOC_STOP. A pause (thepnote) comes out of the parser with a frequency of 0 and was passed to the driver like any other note.Several PWM lower halves refuse a frequency of 0 in
pwm_start(): RA4, HT32F491x3, GD32VW55x, GD32W51x and TLSR82 return-EINVAL, Ameba returns-ERANGEand LiteX-EPERM. On such a driverplay_pwm()printed an error and returned before theusleep(), so every pause lasted nothing, the following notes were played too early and one error line was printed per pause.The pause is now handled before the PWM device is touched:
play_pwm()waits for the duration of the pause and returns. The output is stopped at that point, since every note ends withPWMIOC_STOP. Notes are played as before.Impact
Only
audio_rttlruns that name a PWM device are affected:No change to Kconfig, the build system or any driver.
Testing
Build host: Ubuntu 26.04.1 LTS, x86_64 (AMD Ryzen 9 8940HX), GCC 15.2.0, CMake 4.2.3.
Target 1:
arm/n32h7, custom board with an N32H760 (bft_v1:nsh, local tree based on NuttX 13.0.1), arm-none-eabi-gcc 15.3.1A passive buzzer is driven by a timer PWM output,
/dev/pwm2. The PWM lower half of this board refuses 0 Hz inpwm_start()with-EINVAL, like the RA4 driver. One tick is 10 ms.To keep the test silent the tune has pauses only. Two images were built that differ only in
examples/audio_rttl/audio_rttl_main.c: one with the file as onapache/master(c621be657), one with this change.audio_rttl_main()was started with the command line below from a test thread whosestderrwas redirected to memory and read back over the debug probe, together with the timer control register and the pin level.Before:
The call returned within the tick it was started in.
After:
The call returned after 16 ticks (160 ms; a 30 ms
usleep()takes 4 ticks on this target). In both cases the timer counter was disabled and the output pin was low afterwards.Target 2:
sim:nshonapache/nuttxmaster58250c3546No in-tree board configuration builds the example, so it was switched on by hand:
CONFIG_PWM=y,CONFIG_AUDIO=y,CONFIG_AUDIOUTILS_RTTTL_C=y,CONFIG_EXAMPLES_AUDIO_SOUND=y. The example builds without warnings andaudio_rttlis in the built-in command list.🤖 Generated with Claude Code