Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1579

Python • SMBUS2 and usage of General Call Addressing.

$
0
0
Hi all,

This is more of a what i found when trying to actual use the software reset mechanism for a PCA9685 device.
The address of the PCA9685 is 0x40 and it has a bunch of registers associated to it as well. In my attempt to figure out how to perform a software rest on it i encountered a bunch of trial and error and a bunch of misleading info.

In order to execute the SWRST on the PCA9685 you need access to the I2C "General Call Address". That address is 0x00 and in Python would cause an error condition in any attempt to write to it.

Typically you'll see most descriptions of usage of the SMBUS2 class as follows:
import smbus2
...
channel = 0x01 # in this case for the PCA9685 is on /dev/i2c-1
...
bus=smbus2.SMBus(channel)

SWRSTaddress = 0x00
PCA9685ResetReg - 0x06
address = 0x40 # for the PCA9685 during normal I2C access

Any attempt at the following would fail
bus.write_byte( SWRSTaddress, PCA9685ResetReg)

In order to gain access to the General Call Address you need to do the following modifications:
bus=smbus2.SMBus(channel, True) forces the ability to use General Call Address
followed with
bus.write_byte( SWRSTaddress, PCA9685ResetReg, True) @also forcing the the write to this address

Hope this short circuits the time for anyone else trying to find this info.

Statistics: Posted by EM1SSNuke — Tue Dec 30, 2025 10:02 pm



Viewing all articles
Browse latest Browse all 1579

Trending Articles