Skip to contentSkip to conversation

Possible bug in PCA9685 driver

PCA9685 Patrick Menschel 1 participant 1 message Dec 27, 2023 PWM

lore
Share & tools
lore
#0 lore raw

Hello,

I'd like to report a possible bug in the pca9865 driver.

https://github.com/raspberrypi/linux/blob/rpi-6.1.y/drivers/pwm/pwm-pca9685.c

The resulting frequency is 10% off.

I'm currently using an adafruit pca9685 board to zero-in some servos via SYSFS.

As always, first attempt was a disaster but after that, I started to measure things with a Benning MM 7-1 and when I set the period to 20ms via SysFs, I read 55Hz on the multimeter.

I had to set the period to 22ms to get 49,88Hz.

```
$ cd /sys/class/pwm/pwmchip0/
$ echo 0 > export
$ cd pwm0/

$ echo 20000000 > period
$ echo 11000000 > duty_cycle
$ echo 1 > enable
# results in ~55Hz

$ echo 0 > enable
$ echo 22000000 > period
$ echo 11000000 > duty_cycle
$ echo 1 > enable
# results in ~50Hz, and it's 50% duty cycle to get a symetric signal


$ echo 0 > enable
# after connecting a servo and setting duty to 1-2ms everything works as expected.
$ echo 1 > enable
$ echo 1000000 > duty_cycle
$ echo 1500000 > duty_cycle
$ echo 2000000 > duty_cycle
```

In the end it does not matter to the servo or the application and I'm not sure if I measured correctly.

BR
Patrick Menschel