Brunocor26 opened a new pull request, #19199:
URL: https://github.com/apache/nuttx/pull/19199
## Summary
Fixes three bugs in the RP23XX (RISC-V / rp23xx-rv) PWM driver, mirroring
the
fix already applied to the ARM variant (arch/arm/rp23xx):
overflowed and lost precision. It is now computed as a 16.16 fixed-point
value (div16) using 64-bit arithmetic and clamped to the valid hardware
range (0x10 .. 0xFFF).
* setup_pulse: the compare value was scaled by TOP instead of 65535,
producing incorrect duty cycles. The formula is now
((duty * (top + 1)) / 65535) with an overflow guard.
* pwm_start: the single-channel access was not updated after the removal of
the PWM_MULTICHAN option (commit 4df80e19). It now uses
info->channels[0].duty instead of info[0].duty.
## Impact
Affects only arch/risc-v/src/rp23xx-rv (Raspberry Pi Pico 2, RISC-V Hazard3
core). No public API change. Before this fix the RP23XX PWM output had
incorrect frequency and duty cycle on the RISC-V build; after it, both
match
the configured values across the full 0..100% range. The change is the
RISC-V counterpart of the equivalent ARM fix.
## Testing
Built for raspberrypi-pico-2-rv:nsh and tested on a Raspberry Pi Pico 2
(RISC-V) driving a 4-wire PWM fan: measured frequency and duty cycle match
the configured values across the full 0..100% range.
Build host: Ubuntu, riscv64-unknown-elf-gcc (RV32, ilp32).
overflowed and lost precision. It is now computed as a 16.16 fixed-point
value (div16) using 64-bit arithmetic and clamped to the valid hardware
range (0x10 .. 0xFFF).
* setup_pulse: the compare value was scaled by TOP instead of 65535,
producing incorrect duty cycles. The formula is now
((duty * (top + 1)) / 65535) with an overflow guard.
* pwm_start: the single-channel access was not updated after the removal of
the PWM_MULTICHAN option (commit 4df80e19). It now uses
info->channels[0].duty instead of info[0].duty.
## Impact
Affects only arch/risc-v/src/rp23xx-rv (Raspberry Pi Pico 2, RISC-V Hazard3
core). No public API change. Before this fix the RP23XX PWM output had
incorrect frequency and duty cycle on the RISC-V build; after it, both
match
the configured values across the full 0..100% range. The change is the
RISC-V counterpart of the equivalent ARM fix.
## Testing
Built for raspberrypi-pico-2-rv:nsh and tested on a Raspberry Pi Pico 2
(RISC-V) driving a 4-wire PWM fan: measured frequency and duty cycle match
the configured values across the full 0..100% range.
Build host: Ubuntu, riscv64-unknown-elf-gcc (RV32, ilp32).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]