Skip to content

Commit

Permalink
Merge pull request #77 from b3nn0/pi4-pwm-freq
Browse files Browse the repository at this point in the history
Fixed PI4 PWM frequency setting due to wrong oscillator frequency
  • Loading branch information
drahoslove authored Sep 20, 2021
2 parents 8a909a0 + 43c0fe3 commit 2ab4c04
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2ab4c04

Please sign in to comment.