Making sense of PCA9685 registers

Using an ESP32 to control many PCS9685 LED driver boards. I2C Scan of a single board shows 0x40, 0x70, 0x80, 0xC0 and 0xF0. 0x40 is the main address of the board. 0x70 I presume is the All_Call address although the NKP data sheet says it should be 0xE0.
When I connect an array of sixteen boards I2C Scan finds 0x40 - 0x4F, 0x70, 0x80, 0xC0 - 0xCF and 0xF0.
I believe 0x06 should be software reset. The data sheet says that one is designed to not respond.
What are the purposes of all the extra addresses? Especially the 0xC0 - 0xCF addresses.
Almost none of this matches up to the NKP data sheet.
I'm using Wire.h to control the boards because it's not reasonable to use PCA9685.h to control up to forty eight boards.

That's odd; never noticed that.

That's what, up to 768 individual channels? I guess WS2811/2 wasn't an option?

One? What are you referring to exactly?

NXP?

I have a strong feeling counterfeit PCA9685's are present on the market. It's the one and only chip so far I've ever received an entirely non-functional batch of (Chinese origin).
I'd have to dig up an experimenter board/module to see if I can get those multiple address responses to reproduce on my end, but I don't recall all those other addresses ever popping up on an I2C scan.

If you convert the HEX addresses to binary, you'll see a pattern. It's a pattern that suggests that whoever made these (NXP...or very much someone else?) decided that the two MSB's of the address space were fair game to use for...whatever.

Thanks, yes I meant NXP.
The address designed to not respond should be 0x06, software reset.
I'm using LEDs that are about 1 mm square, and yes, up to 768 LEDs.
Forty eight boards bumps up against the All_Call address.
I could add more but I'm concerned about bus length and practicality.
I may need to build two of these as it likely will not be enough LEDs.
I looked at the chips under a microscope. They have the NXP logo and
PCA9685PW
CXA607 22
TuD1923-
That doesn't mean they're not counterfeit.
I guess I will have to make SWAGs and test each possibility.

The one that is strangest is the 0xC0 to 0xCF. Each board responds in that range. If I add sixteen more boards in the 0x50 to 0x5F range will I also get responses to 0xD0 to 0xDF?

Make sure that the address select pins on the PCA9685 are all connected to + or ground.

If not the pins will float and that will cause the effect you are seeing of multiple addresses for one device.

2 Likes

OK, will you use the SUBx registers to expand the address range? I never tried this (never experienced the need); not sure how it'll work exactly. With 5 address pins, only 32 addresses can be hardwired. I was assuming you were using multiple I2C buses (I also misremembered there were only 4 address pins....) to get to the total of 48 devices.

Good point!

Grumpy,

Thanks for the idea.

I checked the boards.

They all have pull up resistors on A0 - A5.

They proper ones are grounded.

Thanks again.

Rsmis,

I'm using just one I2C bus, the hardware one.

My limited understanding of the SUBx registers is they can be used to isolate groups of LEDs.

Like a group of all red ones, another group of all green and another of all blue.

The registers also allow you to change the All_Call address away from 0x70, or even eliminate it all together.

By also disabling the SUBx addresses it could be possible to use 64 boards on one bus.

I have not looked at that yet. So far I've only constructed one group of 16.

I am now able to write to the Mode1 and Mode2 registers using the All_Call address.

I set Mode1 up to restart, auto increment, respond to All_Call and disable the SUBx addresses.

I set Mode2 up to invert outputs and open drain structure.

I then can read back both of those registers using the individual board addresses.

All the LEDs are wired up common anode with the positives tied to V+, 5.2 volts, and the negative side wired to the individual PWM outputs.

The PCA9685 can run up to 25 ma to each LED in open drain mode, although the current will actually be a bit lower.

I also use a separate 3.3 volt supply for Vcc for the boards and the ESP32 along with its SD card reader and SPI FRAM.

The way I read that spec is that you can create groups of PCA's, not so much groups of LEDs distributed across PCA's. So you can have e.g. 3 PCA's that you make part of one group with one SUB address and you can 'talk to them' all at once.

What this doesn't allow, is to have more than 32 PCA's on a single I2C bus. Give it a thought - even if you could do 'something' with the SUBx registers, you'd have the situation on startup that there are multiple devices with the same hardware I2C address present on the bus. This will evidently not work.

You could use two I2C buses and that way address up to 64 PCA's. Since you're aiming for 48pcs, this would solve your problem. Plenty of microcontrollers have two or more I2C's.

rsmis, I believe your description of the use of SUBx registers is correct.
I do know the SUBx registers can be disabled, which I have done.
I haven't tried more than 16 boards yet. I think I should be able to use board addresses 0x40 through 0x6F on a single I2C bus. This won't interfer with the 0x70 All_Call. That would give me 48 boards. If I disable or move the All_Call address to like 0x30, I wonder if I could use 64 boards on a single I2C bus? When I get further in to this I will be trying that. Thanks

But, but, but.
Wait a moment. The board has 5 Address setting positions, right? You could actually use one address line on all the boards as a 'board enable', tying 16 of those together setting the line low, and talking to them all on the I2C bus at 16 unique addresses. Then, raise that line and similarly treat as many banks of 16 as you wish. Effectively, it's up to you how many such 'banks' you create. At some point, you run into limitations of driving the I2C bus into that many inputs, and you'll have to watch total bus length, but getting around the number of addresses limitation should be simple.

Of course, there's also the TCA9548A I2C mux, if you really, really, want some fun.
There have been a few threads here about that little monster.

1 Like

camsysca, interesting thought! Actually I do have a few i2c eight bus expanders, although I haven't done anything with them yet. The PCA9685 chips have components that clean up the bus signals and can handle higher capacitance.

My question is , how far can the I2C bus be lengthened? I may experiment with this.

A post was split to a new topic: Unspecified code problem

Okay, I think I have figured some of this out.
The board address register is one byte long. Bit zero denotes read/write and is controlled by the Wire/I2C libraries. A 1 is read and a 0 is write. As a programmer you have no control over that bit. For all practical purposes it's invisible to us. In addition bit seven is internally set to 1, this can't be changed.

After leaving out the r/w bit, that leaves the first seven bits for an address, with the highest bit always a 1. We can only choose the lower six bits of this remainder. Those six bits we can use are labeled 5 through 0 in the PCA9685 and on the usual boards that are available. Confusing, yes, but I can see their logic.

Now, if we set bits 5 through 0 low, the seven bit address register will hold 1 0 0 0 0 0 0 which is read as 0x40. Setting the bits to 1 0 0 1 1 1 1, again only seven bits with the first bit always a 1, the address is now 0x4f. Again, setting the seven bits to 1 1 1 0 0 0 0 gives us an address of 0x70, the All_Call address. The highest available address is 0x7F. A total of 64 addresses are possible but that's reduced by the All_Call address and in some way by the Software Reset address. Leaving us room for 62 PCA9685 boards.

Using the SUBx registers can reduce that by up to three more addresses. I have the SUBx registers disabled. I may decide to disable the All_Call register and leave room for 63 PCA9685 boards. The only thing I use All_Call for is to set the Mode1, Mode2 and the Prescale registers. I may be able to set them using All_Call and the last thing would be to set Mode1 to disable All_Call.

Now, to continue keeping it confusing, NXP says the All_Call address is 0xE0. It turns out they are including the r/w bit in that address. So it's 1 1 1 0 0 0 0 0, still the same 0x70 All_Call address, but now with eight bits. Since our libraries don't allow us access to the lowest bit, we use 0x70 instead of 0xE0.

In my original scan of I2C addresses I scanned from 0x00 to 0xFF. I didn't understand the no-access to the r/w bit at that time. I should have scanned from 0x00 to 0x7F.

Okay, maybe the last piece of my puzzle. The Software Reset uses an address of 0x00. The PCA9685 seems to ignore the internal always high address bit 7 in this case. Writing a 0x06 to 0x00 will Software Reset all attached boards. This does not interfere with any other addresses.
It seems now that by disabling the All_Call address and all the SUBx addresses it may actually be possible to use sixty-four boards from 0x40 to 0x7F.
There could still be bus length issues. Eventually I will try this method. It would then allow controlling 1024 LEDs.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.