PCA9685 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Public Attributes | List of all members
pca9685::Config Struct Reference

Everything EnsureInitialized() writes to the chip. More...

#include <pca9685_types.hpp>

Public Attributes

uint32_t pwm_frequency_hz {200}
 
uint32_t oscillator_hz {kInternalOscillatorHz}
 
ClockSource clock {ClockSource::Internal}
 MODE1.EXTCLK. Reset value: internal.
 
OutputDrive output_drive {OutputDrive::TotemPole}
 MODE2.OUTDRV. Reset value: totem pole.
 
bool invert_outputs {false}
 MODE2.INVRT. Reset value: not inverted.
 

Detailed Description

Everything EnsureInitialized() writes to the chip.

The defaults are the reset values of MODE1, MODE2 and PRE_SCALE (tables 5, 6 and 8): 200 Hz from the internal oscillator, totem-pole outputs, not inverted. Fields with a unit carry it as a suffix.

The driver chooses MODE2.OUTNE itself, so that a high OE pin always sets every output to the level of a channel that is off: low when not inverted, high (totem pole) or high impedance (open drain) when inverted (table 11). The driver keeps MODE1.ALLCALL and SUB1 to SUB3 cleared, so no group address can change the chip behind its back. It keeps MODE2.OCH = 0 (the reset value): written channel registers reach the outputs at the I2C STOP, so every byte of one transfer changes together, and the bytes before a NACK at its STOP. OCH = 1 (change on ACK) is not offered: it changes a channel once "all 4 registers" are loaded (section 7.3.2, note 3), and the data sheet leaves open which bytes count after a NACK, so a switch-off could reach the output part-written.

Member Data Documentation

◆ oscillator_hz

uint32_t pca9685::Config::oscillator_hz {kInternalOscillatorHz}

The counter clock, kMinOscillatorHz to kMaxOscillatorHz: 25 MHz typical internal, a measured value to calibrate, or EXTCLK.

◆ pwm_frequency_hz

uint32_t pca9685::Config::pwm_frequency_hz {200}

PWM frequency; PRE_SCALE = round(oscillator / (4096 x f)) - 1 must be 3 to 255 (equation 1). Reset value: 200 Hz (0x1E).


The documentation for this struct was generated from the following file: