ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
pca9685.h File Reference

NXP PCA9685 16-channel 12-bit PWM / servo driver codec (PROTOCORE_ENABLE_PCA9685). More...

#include "protocore_config.h"

Go to the source code of this file.

Detailed Description

NXP PCA9685 16-channel 12-bit PWM / servo driver codec (PROTOCORE_ENABLE_PCA9685).

The PCA9685 generates sixteen independent 12-bit PWM outputs from a 25 MHz oscillator. The output frequency is set by a PRESCALE register value; each channel is four registers (a 12-bit ON count and a 12-bit OFF count) at 0x06 + 4 * channel. Driving a hobby servo is a matter of turning a pulse width (in microseconds) into an OFF count at the configured frequency.

This codec is pure and host-tested: ::protocore_pca9685_prescale computes the prescale for a frequency, ::protocore_pca9685_us_to_count converts a servo pulse width to a 12-bit count, ::protocore_pca9685_channel_reg gives a channel's register base, and ::protocore_pca9685_set_pwm_bytes emits the 5-byte channel write. On an ESP32 the binding replays those writes over I2C (Wire); only that touches hardware.

A cheap solder-and-bench-test breakout for driving up to 16 servos or LEDs: wire it up, sweep a servo.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file pca9685.h.