Why Do I Fail to Switch the LED Colors When I Turn off/on PCA9685?
Ask questions and find answers to many subjects relating to electrics and electrical work

yangsezong
Labourer
Labourer
Posts: 1
Joined: Tue Oct 17, 2017 8:12 am

Why Do I Fail to Switch the LED Colors When I Turn off/on PCA9685?

by yangsezong » Tue Oct 17, 2017 8:38 am

I have a PCA9685 IC connected to I2C of cubieboard like board.

Also OE pin is connected to one GPIO pin. I'm using I2C tools to communicate with PCA9685, I can read/write to registers without any problems, but changes I do to registers does not take effect, LEDs don't change them state.

There are 4 RGB leds connected through a resistor to PCA9685 (as Fig 15 of PCA9685 datasheet:http://www.kynix.com/uploadfiles/pdf65976/PCA9685BS2c118_658254.pdf ), this is, 12 channels are being used. Doesn't matter which value I write to PWM registers, LEDs state are always the same, oddly, colors are not equal to each LED. 1 LED has red, 1 LED has blue, 1 magenta and 1 white. However, colors are not random, always I turn off/on PCA9685 the same colors are assumed by the same LEDs.

I can switch all LEDs on/off by changing OE pin state.

Here is the code I'm using to test.

Code: Select all

#!/bin/bash

set -e

PCA9685_BUS=1
PCA9685_ADDR=0x41
PCA9685_OE="pi15"

# config GPIO as output and set initial state
${PWD}/gpio_config.sh "$PCA9685_OE" "out" "1"

# set output logic as inverted
i2cset -y $PCA9685_BUS $PCA9685_ADDR 0x01 0x10

# restart
i2cset -y $PCA9685_BUS $PCA9685_ADDR 0x00 0x91
sleep 1

# change to normal mode
i2cset -y $PCA9685_BUS $PCA9685_ADDR 0x00 0x01
sleep 1

for (( i = 0x06; i <= 0x45; i++ )); do
    i2cset -y $PCA9685_BUS $PCA9685_ADDR $i 0x0F
done
Running I2Cdump I can see registers were changed.
[root@board test]# i2cdump 1 0x41
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1, address 0x41, mode byte
Continue? [Y/n]
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 01 10 e2 e4 e8 e0 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f    ????????????????
10: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f    ????????????????
20: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f    ????????????????
30: 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f 0f    ????????????????
40: 0f 0f 0f 0f 0f 0f XX XX XX XX XX XX XX XX XX XX    ??????XXXXXXXXXX
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX 00 00 00 00 1e 00    XXXXXXXXXX....?.


I've tried other values than 0x0F, same issue.
Any idea over what can be happening?

It is currently Sun Jan 12, 2025 7:49 am