From 43c0fe30e3ffdc55da6c65ad29ebf904636e6569 Mon Sep 17 00:00:00 2001 From: Adrian Batzill Date: Mon, 20 Sep 2021 10:59:32 +0200 Subject: [PATCH] Fixed PI4 PWM frequency setting due to wrong oscillator frequency --- rpio.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rpio.go b/rpio.go index 3ff8997..04a42a5 100644 --- a/rpio.go +++ b/rpio.go @@ -546,7 +546,10 @@ func PullMode(pin Pin, pull Pull) { // pwm_clk: pins 12, 13, 18, 19, 40, 41, 45 func SetFreq(pin Pin, freq int) { // TODO: would be nice to choose best clock source depending on target frequency, oscilator is used for now - const sourceFreq = 19200000 // oscilator frequency + sourceFreq := 19200000 // oscilator frequency + if isBCM2711() { + sourceFreq = 52000000 + } const divMask = 4095 // divi and divf have 12 bits each divi := uint32(sourceFreq / freq)