very simple sample code for PCA9955 (16 channel current control LED driver)

Dependencies:   mbed

What is this?

This is a very simple sample code to operate the PCA9955.
The PCA9955 is a 16-channel Fm+ I2C-bus 57 mA constant current LED driver with independent current control for each channels.

/media/uploads/nxp_ip/_scaled_dsc_0374.jpg

/media/uploads/nxp_ip/pca9955-block.png

Datasheet is available in next URL.
http://www.nxp.com/documents/data_sheet/PCA9952_PCA9955.pdf

/media/uploads/nxp_ip/pca9955-application.png

Chip details

The PCA9952 and PCA9955 are I2C-bus controlled 16-channel constant current LED driver optimized for dimming and blinking 57 mA Red/Green/Blue/Amber (RGBA) LEDs in amusement products. Each LED output has its own 8-bit resolution (256 steps) fixed frequency individual PWM controller that operates at 31.25 kHz with a duty cycle that is adjustable from 0 % to 99.6 % to allow the LED to be set to a specific brightness value. An additional 8-bit resolution (256 steps) group PWM controller has both a fixed frequency of 122 Hz and an adjustable frequency between 15 Hz to once every 16.8 seconds with a duty cycle that is adjustable from 0 % to 99.6 % that is used to either dim or blink all LEDs with the same value.

Each LED output can be off, on (no PWM control), set at its individual PWM controller value or at both individual and group PWM controller values. The PCA9952 and PCA9955 operate with a supply voltage range of 3 V to 5.5 V and the constant current sink LED outputs allow up to 40 V for the LED supply. The output peak current is adjustable with an 8-bit linear DAC from 225 μA to 57 mA.

These devices have built-in open, short load and overtemperature detection circuitry. The error information from the corresponding register can be read via the I2C-bus. Additionally, a thermal shutdown feature protects the device when internal junction temperature exceeds the limit allowed for the process.

The PCA9952 and PCA9955 devices have Fast-mode Plus (Fm+) I2C-bus interface. Fm+ devices offer higher frequency (up to 1 MHz) or more densely populated bus operation (up to 4000 pF).

The PCA9952 is identical to PCA9955 except for the following differences:

  • The PCA9952 has only 3 hardware address pins compared to 4 on PCA9955.
  • The PCA9952 has an output enable pin (OE) and the PCA9955 does not.

The active LOW output enable input pin (OE), available only on PCA9952, blinks all the LED outputs and can be used to externally PWM the outputs, which is useful when multiple devices need to be dimmed or blinked together without using software control.

Software programmable LED Group and three Sub Call I2C-bus addresses allow all or defined groups of PCA9952/55 devices to respond to a common I2C-bus address, allowing for example, all red LEDs to be turned on or off at the same time or marquee chasing effect, thus minimizing I2C-bus commands. On power-up, PCA9952/55 will have a unique Sub Call address to identify it as a 16-channel LED driver. This allows mixing of devices with different channel widths. Four hardware address pins on PCA9955 allow up to 16 devices on the same bus. In the case of PCA9952, three hardware address pins allow up to 8 devices on the same bus.

The Software Reset (SWRST) function allows the master to perform a reset of the PCA9952/55 through the I2C-bus, identical to the Power-On Reset (POR) that initializes the registers to their default state causing the output current switches to be OFF (LED off). This allows an easy and quick way to reconfigure all device registers to the same condition.

Committer:
nxp_ip
Date:
Wed Oct 10 00:48:16 2012 +0000
Revision:
0:3afedead559b
initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 0:3afedead559b 1 /*
nxp_ip 0:3afedead559b 2 * very simple sample code for PCA9955 LPD driver
nxp_ip 0:3afedead559b 3 *
nxp_ip 0:3afedead559b 4 * 10-Oct-2012
nxp_ip 0:3afedead559b 5 * NXP Semiconductors - Interface Products
nxp_ip 0:3afedead559b 6 */
nxp_ip 0:3afedead559b 7
nxp_ip 0:3afedead559b 8 #include "mbed.h"
nxp_ip 0:3afedead559b 9
nxp_ip 0:3afedead559b 10 #define PCA9955_ADDRESS 0xC0
nxp_ip 0:3afedead559b 11
nxp_ip 0:3afedead559b 12 I2C i2c( p28, p27 );
nxp_ip 0:3afedead559b 13
nxp_ip 0:3afedead559b 14 char init_array[] = {
nxp_ip 0:3afedead559b 15 0x80, // Command
nxp_ip 0:3afedead559b 16 0x00, 0x05, // MODE1, MODE2
nxp_ip 0:3afedead559b 17 0xAA, 0xAA, 0xAA, 0xAA, // LEDOUT[3:0]
nxp_ip 0:3afedead559b 18 0x80, 0x00, // GRPPWM, GRPFREQ
nxp_ip 0:3afedead559b 19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // PWM[7:0]
nxp_ip 0:3afedead559b 20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // PWM[15:8]
nxp_ip 0:3afedead559b 21 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // IREF[7:0]
nxp_ip 0:3afedead559b 22 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // IREF[15:8]
nxp_ip 0:3afedead559b 23 0x08 // OFFSET: 1uS offsets
nxp_ip 0:3afedead559b 24 };
nxp_ip 0:3afedead559b 25
nxp_ip 0:3afedead559b 26
nxp_ip 0:3afedead559b 27 int main()
nxp_ip 0:3afedead559b 28 {
nxp_ip 0:3afedead559b 29 char data[ 2 ];
nxp_ip 0:3afedead559b 30 int i = 0;
nxp_ip 0:3afedead559b 31
nxp_ip 0:3afedead559b 32 i2c.write( PCA9955_ADDRESS, init_array, sizeof( init_array ) );
nxp_ip 0:3afedead559b 33
nxp_ip 0:3afedead559b 34 while ( 1 ) {
nxp_ip 0:3afedead559b 35 if ( !(i & 0xFFF) ) {
nxp_ip 0:3afedead559b 36 data[ 0 ] = 0x42;
nxp_ip 0:3afedead559b 37 data[ 1 ] = 0x00;
nxp_ip 0:3afedead559b 38 i2c.write( PCA9955_ADDRESS, data, 2 );
nxp_ip 0:3afedead559b 39
nxp_ip 0:3afedead559b 40 } else {
nxp_ip 0:3afedead559b 41 data[ 0 ] = 0x0A + ((i >> 8) & 0xF);
nxp_ip 0:3afedead559b 42 data[ 1 ] = i & 0xFF;
nxp_ip 0:3afedead559b 43 i2c.write( PCA9955_ADDRESS, data, 2 );
nxp_ip 0:3afedead559b 44
nxp_ip 0:3afedead559b 45 }
nxp_ip 0:3afedead559b 46 wait_ms( 1 );
nxp_ip 0:3afedead559b 47 i++;
nxp_ip 0:3afedead559b 48 }
nxp_ip 0:3afedead559b 49 }
nxp_ip 0:3afedead559b 50