Skip to content

Commit fdc7b55

Browse files
jespinoona-agent
andcommitted
machine/esp32: add PWM support using LEDC peripheral
Add PWM support for ESP32 using the LEDC (LED Control) peripheral. Features: - 4 high-speed timers (PWM0-PWM3) with glitch-free duty updates - Up to 8 channels shared across timers - Configurable duty resolution (1-20 bits) - Flexible frequency control via period setting - Any GPIO can be used via GPIO matrix routing The implementation follows the standard TinyGo PWM interface with Configure, Channel, Set, SetPeriod, Top, and SetInverting methods. Co-authored-by: Ona <no-reply@ona.com>
1 parent 7aca814 commit fdc7b55

File tree

2 files changed

+427
-0
lines changed

2 files changed

+427
-0
lines changed

src/examples/pwm/esp32.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//go:build esp32
2+
// +build esp32
3+
4+
package main
5+
6+
import "machine"
7+
8+
var (
9+
pwm = machine.PWM0 // Use high-speed timer 0
10+
pinA = machine.GPIO2 // Built-in LED on many ESP32 boards
11+
pinB = machine.GPIO4 // Another GPIO for testing
12+
)

0 commit comments

Comments
 (0)