kywwilson11 opened a new pull request, #17239:
URL: https://github.com/apache/nuttx/pull/17239
## Summary
I ported the **STM32H7 PWM lower-half** to the **STM32H5** family and wired
it into the existing H5 RCC/GPIO/TIM layers.
What’s included:
- New files:
- `arch/arm/src/stm32h5/stm32_pwm.c`
- `arch/arm/src/stm32h5/stm32_pwm.h`
- `arch/arm/src/stm32h5/hardware/stm32_pwm.h`
- Kconfig/CMake glue for `CONFIG_STM32H5_PWM` and per-timer enables (e.g.,
TIM1/TIM3/…).
- `STM32_HAVE_IP_TIMERS_V2` enabled for H5 (advanced timers expose CCR5/CCR6
+ GC5Cx).
- Board bits and a simple **test config** that enables the `pwm` example app
and registers `/dev/pwmX`.
- Pin mapping tables for PWM outputs on TIM1/TIM8 and GP timers (CH1..CH4
and CHxN where available).
It’s essentially the H7 driver adapted for H5: I kept the multichannel
`pwm_info_s` behavior (channels don’t need to start at CH1), and left the
advanced-timer scaffolding (BDTR/MOE/dead-time) in place for boards that use
complementary outputs. CH5/CH6 are present as on other “v2” timers but not
exposed as pins; combined-PWM can be added later without changing the API.
## Impact
- **New feature for STM32H5**: PWM support via standard NuttX
upper/lower-half API.
- **Scoped change**: Only touches STM32H5 arch + board files; other SoCs are
unaffected.
- **Build**: New Kconfig options to enable STM32H5 PWM and reserve specific
timers. Off by default.
- **Compatibility**: Works with existing apps (e.g., `apps/examples/pwm`)
and follows `include/nuttx/timers/pwm.h`. No public API changes.
- **Docs**: Updated nucleo-h563zi documentation to include new pwm config
## Testing
**Host:** Ubuntu 24.04
**Toolchain:** arm-none-eabi-gcc (Arm GNU Toolchain 13.3.Rel1 (Build
arm-13.24)) 13.3.1 20240614
**Boards:** nucleo-h563zi
**Procedure:**
- Built the provided test defconfig (enables `CONFIG_STM32H5_PWM` and the
`pwm` example).
- Flashed and booted; confirmed `/dev/pwm0` (and additional `/dev/pwm*`
where configured) are registered.
- Ran the `pwm` example to exercise `PWMIOC_SETCHARACTERISTICS` + start/stop.
- Verified frequency/duty on a scope at several points:
- 1 kHz @ 50%, 10 kHz @ 20%, 20 kHz @ 75% (edge-aligned).
- Checked multiple channels and non-CH1-first ordering to avoid multichannel
regressions.
- Spot-checked an advanced timer (TIM1/TIM8) where pins are available:
- Enabled main outputs (MOE) and verified complementary output routing
(CHx/CHxN) on the board.
- Built with/without `CONFIG_PWM_PULSECOUNT` to ensure the driver compiles
cleanly in both configurations.
**Logs and scope screenshots are attached below.**
<pre>
NuttShell (NSH) NuttX-12.11.0
nsh> pwm -f 1000 -d 50 -t 30
pwm_main: starting output with frequency: 1000 duty: 00007fff
pwm_main: stopping output
nsh>
</pre>
<img width="943" height="610" alt="image"
src="https://github.com/user-attachments/assets/603eb176-6e1e-4559-94ee-e9c43bcb8175"
/>
--
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]