PCA9955A and PCA9956A class library. The PCA9955A is a 16-channel and the PCA9956A is a 24-channel Fm+ I2C-bus 57mA/20V constant current LED driver. The PCA9955A has a extended feature which called "Gradation control".

Dependencies:   CompLedDvrCC

Dependents:   PCA9956A_Hello pca9956b_two_demoboards PCA9955A_Gradation_control PCA9955A_Gradation_control ... more

What is this?

Code for PCA9956A and PCA9955A.
24-channel and 16-channel constant current type LED driver component class.

Please refer to the component page for details

PCA9955B and PCA9956B are I²C-bus controlled 16-channel constant current LED driver optimized for dimming and blinking.

High-level API is available

A high-level API that can be used as the "PwmOut" of bed-SDK is available.
This API enables to make instances of each LED output pins and control PWM duty cycle by assignment.
Output current also controllable by API function.
For detail information, refer API document of LedPwmOutCC Class class which is included in PCA995xA class library.

#include "mbed.h"
#include "PCA9956A.h"

PCA9956A    led_cntlr( p28, p27, 0xC4 );  //  SDA, SCL, Slave_address(option)
LedPwmOutCC led( led_cntlr, L0 );

int main()
{
    while( 1 ) {
        for( float p = 0.0f; p < 1.0f; p += 0.1f ) {
            led     = p;
            wait( 0.1 );
        }
    }
}

About the chips

PCA9956A

The PCA9956A is an I2C-bus controlled 24-channel constant current LED driver optimized for dimming and blinking 57 mA LEDs. 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.

Datasheet: http://www.nxp.com/documents/data_sheet/PCA9956A.pdf

PCA9955A

The PCA9955A is an 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 100 % to allow the LED to be set to a specific brightness value.

On addition to this, the PCA9955A has "Gradation control".
The gradation control is a new feature of PCA995xA series. After the register setting and start the control, the PCA9955A performs dimming cycles automatically without MCU intervention.

Datasheet: http://www.nxp.com/documents/data_sheet/PCA9955A.pdf

PCA9952 and PCA9955 (non-A version)

The PCA9955 and PCA9955 (no-A at end of the type number) is not supported by this component class.

PCA9955(non-A)

PCA9955A != PCA9955

PCA9955A is not software compatible to PCA9955(non-A version).
There are several differences between A and non-A versions.
Register mapping is one of the difference. Please make sure you are using PCA9955A.

How the API works?

When the instance is made, all set up for PWM operation are done automatically.
For the operation, user can control the LED brightness in two ways.

  • PWM
  • Current

PCA9955A and PCA9956A have internal 31.25kHz oscillator to generate internal PWM waveform. This signal switchs the output current ON and OFF. The class' function pwm() controls duty-cycle of this output.

Another control is current. Since the PCA9955A and PCA9956A are constant current type LED driver, those have internal current sources. The current source on each channels has independent control of output current. The class' function current() provides interface to current change.

API_and_output

Tips for the chips

PCA995xA family

This PCA995xA components library can be used for both PCA9955A(16-channel) and PCA9956A(24-channel).
If you are using both chips on the I2C bus, those can be operated like..

#include "mbed.h"
 
#include "PCA9955A.h"
#include "PCA9956A.h"

PCA9955A    led0( p28, p27, 0xC0 );    //  SDA, SCL, Slave_address=0xC0 (16-channel chip)
PCA9956A    led1( p28, p27, 0xC2 );    //  SDA, SCL, Slave_address=0xC2 (24-channel chip)
 
int main()
{
    led0.current( ALLPORTS, 1.0 ); //  Set all ports output current 100%
    led1.current( ALLPORTS, 1.0 ); //  Set all ports output current 100%

    led0.pwm( ....    //  PWM control for PCA9955A(16-channel chip)
    led1.pwm( ....    //  PWM control for PCA9956A(24-channel chip)
    ...

Other sample code

For PCA9955A : http://developer.mbed.org/users/nxp_ip/code/PCA9955A_Hello/
For PCA9956A : http://developer.mbed.org/users/nxp_ip/code/PCA9956A_Hello/
For Gradation control of PCA9955A http://developer.mbed.org/users/nxp_ip/code/PCA9955A_Gradation_control/

Revision:
5:cb07190e05e7
Parent:
4:fe221e1d4f44
Child:
9:17dd2d8fb866
--- a/PCA9956A/PCA9956A.h	Thu Mar 19 08:40:03 2015 +0000
+++ b/PCA9956A/PCA9956A.h	Thu Mar 19 10:47:49 2015 +0000
@@ -54,7 +54,7 @@
  *      }
  *  }
  *  @endcode
-  *  
+ *  
  *  The high-level-API:LedPwmOutCC is also available.
  *  It can be used like next sample code.
  *  
@@ -130,27 +130,79 @@
     } LedPinName;
 #endif // DOXYGEN_ONLY
 
-    /** Name of the PCA9956A registers */
+    /** Name of the PCA9956A registers (for direct register access) */
     enum command_reg {
-        MODE1, MODE2,
-        LEDOUT0, LEDOUT1, LEDOUT2, LEDOUT3, LEDOUT4, LEDOUT5,
-        GRPPWM, GRPFREQ,
-        PWM0,   PWM1,   PWM2,   PWM3,  
-        PWM4,   PWM5,   PWM6,   PWM7,
-        PWM8,   PWM9,   PWM10,  PWM11, 
-        PWM12,  PWM13,  PWM14,  PWM15,
-        PWM16,  PWM17,  PWM18,  PWM19, 
-        PWM20,  PWM21,  PWM22,  PWM23,
-        IREF0,  IREF1,  IREF2,  IREF3,  
-        IREF4,  IREF5,  IREF6,  IREF7,
-        IREF8,  IREF9,  IREF10, IREF11, 
-        IREF12, IREF13, IREF14, IREF15,
-        IREF16, IREF17, IREF18, IREF19, 
-        IREF20, IREF21, IREF22, IREF23,
-        OFFSET  = 0x3A,
-        SUBADR1, SUBADR2, SUBADR3, ALLCALLADR,
-        PWMALL, IREFALL,
-        EFLAG0, EFLAG1, EFLAG2, EFLAG3, EFLAG4, EFLAG5,
+        MODE1,          /**< MODE1 register      */
+        MODE2,          /**< MODE2 register      */
+        LEDOUT0,        /**< LEDOUT0 register    */
+        LEDOUT1,        /**< LEDOUT1 register    */
+        LEDOUT2,        /**< LEDOUT2 register    */
+        LEDOUT3,        /**< LEDOUT3 register    */
+        LEDOUT4,        /**< LEDOUT4 register    */
+        LEDOUT5,        /**< LEDOUT5 register    */
+        GRPPWM,         /**< GRPPWM register     */
+        GRPFREQ,        /**< GRPFREQ register    */
+        PWM0,           /**< PWM0 register       */
+        PWM1,           /**< PWM1 register       */
+        PWM2,           /**< PWM2 register       */
+        PWM3,           /**< PWM3 register       */
+        PWM4,           /**< PWM4 register       */
+        PWM5,           /**< PWM5 register       */
+        PWM6,           /**< PWM6 register       */
+        PWM7,           /**< PWM7 register       */
+        PWM8,           /**< PWM8 register       */
+        PWM9,           /**< PWM9 register       */
+        PWM10,          /**< PWM10 register      */
+        PWM11,          /**< PWM11 register      */
+        PWM12,          /**< PWM12 register      */
+        PWM13,          /**< PWM13 register      */
+        PWM14,          /**< PWM14 register      */
+        PWM15,          /**< PWM15 register      */
+        PWM16,          /**< PWM16 register      */
+        PWM17,          /**< PWM17 register      */
+        PWM18,          /**< PWM18 register      */
+        PWM19,          /**< PWM19 register      */
+        PWM20,          /**< PWM20 register      */
+        PWM21,          /**< PWM21 register      */
+        PWM22,          /**< PWM22 register      */
+        PWM23,          /**< PWM23 register      */
+        IREF0,          /**< IREF0 register      */
+        IREF1,          /**< IREF1 register      */
+        IREF2,          /**< IREF2 register      */
+        IREF3,          /**< IREF3 register      */
+        IREF4,          /**< IREF4 register      */
+        IREF5,          /**< IREF5 register      */
+        IREF6,          /**< IREF6 register      */
+        IREF7,          /**< IREF7 register      */
+        IREF8,          /**< IREF8 register      */
+        IREF9,          /**< IREF9 register      */
+        IREF10,         /**< IREF10 register     */
+        IREF11,         /**< IREF11 register     */
+        IREF12,         /**< IREF12 register     */
+        IREF13,         /**< IREF13 register     */
+        IREF14,         /**< IREF14 register     */
+        IREF15,         /**< IREF15 register     */
+        IREF16,         /**< IREF16 register     */
+        IREF17,         /**< IREF17 register     */
+        IREF18,         /**< IREF18 register     */
+        IREF19,         /**< IREF19 register     */
+        IREF20,         /**< IREF20 register     */
+        IREF21,         /**< IREF21 register     */
+        IREF22,         /**< IREF22 register     */
+        IREF23,         /**< IREF23 register     */
+        OFFSET  = 0x3A, /**< OFFSET register     */
+        SUBADR1,        /**< SUBADR1 register    */
+        SUBADR2,        /**< SUBADR2 register    */
+        SUBADR3,        /**< SUBADR3 register    */
+        ALLCALLADR,     /**< ALLCALLADR register */
+        PWMALL,         /**< PWMALL register     */
+        IREFALL,        /**< IREFALL register    */
+        EFLAG0,         /**< EFLAG0 register     */
+        EFLAG1,         /**< EFLAG1 register     */
+        EFLAG2,         /**< EFLAG2 register     */
+        EFLAG3,         /**< EFLAG3 register     */
+        EFLAG4,         /**< EFLAG4 register     */
+        EFLAG5,         /**< EFLAG5 register     */
 
         REGISTER_START          = MODE1,
         LEDOUT_REGISTER_START   = LEDOUT0,
@@ -158,7 +210,7 @@
         IREF_REGISTER_START     = IREF0,
     };
 
-    /** Create a PCA9629A instance connected to specified I2C pins with specified address
+    /** Create a PCA9956A instance connected to specified I2C pins with specified address
      *
      * @param i2c_sda       I2C-bus SDA pin
      * @param i2c_sda       I2C-bus SCL pin
@@ -166,7 +218,7 @@
      */
     PCA9956A( PinName i2c_sda, PinName i2c_scl, char i2c_address = PCA995xA::DEFAULT_I2C_ADDR );
 
-    /** Create a PCA9629A instance connected to specified I2C pins with specified address
+    /** Create a PCA9956A instance connected to specified I2C pins with specified address
      *
      * @param i2c_obj       I2C object (instance)
      * @param i2c_address   I2C-bus address (default: 0xC0)