Hi all, using an STM32H7 here. Thank you so much for porting stm32duino to this hot-rod hardware.
I would like to configure PWM and trigger an interrupt at the end of each period. (for an H-Bridge driving a speaker(*)).
So far I set them up separately:
- PWM on D6 via analogWrite. This uses TIM1 internally.
- periodic interrupt via HardwareTimer on TIM2.
Both of these have been verified to work with scope and speaker/microphone/spectrogram.
It works ok-ish if the periodic interrupt and PWM period at not synced, but it renders lots of artifacts into the audible waveform, so therefore I'd like to have them synced together, coming from the same timer.
Before I dive too deep into this, are there any examples around? Is there already explicit support for this? I've been peeking at the source for
HardwareTimer, pwm_start, AttachInterrupt, etc. I think I might be able to see how to mix them together, but before engaging at that level, I'd like to see if anyone else has already gone through the effort!
Thank you,
DIYDSP
(*) using an H-Bridge as opposed to a traditional codec + linear amp combo so it works with a wiiide voltage range.
PWM and interrupt on same timer
Post here all questions related to STM32 core if you can't find a relevant section!
Return to “General discussion”
Jump to
- Announcements
- New users start here
- ↳ Forum rules, FAQs and HowTo's
- ↳ Let us know a bit about you and your projects
- Arduino for STM32
- ↳ General discussion
- ↳ Ideas & suggestions
- ↳ Cores
- ↳ STM32 Core
- ↳ Builds and Announcements
- ↳ Code snippets
- ↳ Ideas & suggestions
- ↳ General discussion
- ↳ Installation and OS related
- ↳ Libraries & Hardware
- ↳ PR's bugs and enhancements
- ↳ LibMaple
- ↳ Builds and Announcements
- ↳ Code snippets
- ↳ General discussion
- ↳ Ideas & suggestions
- ↳ Installation and OS related
- ↳ Libraries & Hardware
- ↳ PR's bugs and enhancements
- ↳ Steve's LibMaple core
- ↳ General discussion
- ↳ PR's bugs and enhancements
- ↳ Projects
- ↳ IDE's
- ↳ Off topic
- Arduino for STM8
- ↳ General discussion
- ↳ Cores
- ↳ STM8 Core
- ↳ Other
- Boards
- ↳ Custom design boards
- ↳ Maple & Maple mini etc
- ↳ STM boards (Discovery, Eval, Nucleo, ...)
- ↳ All other boards
- ↳ STM32F0 based boards
- ↳ STM32F1 based boards
- ↳ STM32F2 based boards
- ↳ STM32F3 based boards
- ↳ STM32F4 based boards
- ↳ STM32F7 based boards
- ↳ STM32G0 based boards
- ↳ STM32G4 based boards
- ↳ STM32H7 based boards
- ↳ STM32L0 based boards
- ↳ STM32L1 based boards
- ↳ STM32L4 based boards
- ↳ STM32L5 based boards
- ↳ STM32MP1 based boards
- ↳ STM32WB based boards
- Bootloaders
- ↳ STM32 HID bootloader
- ↳ USB bootloader
- ↳ STM32 SD-Bootloader
- ↳ STM32 USB CDC bootloader
- Uploaders and debuggers
- ↳ STLink
- ↳ USB to Serial adaptors
- ↳ Black Magic Probe & other
- Dead Thread Graveyard
- ↳ Dead Thread Graveyard