PCA9624, PCA9622 and PCA9626 class library. The PCA9624 is a 8-channel, the PCA9622 is a 16-channel and the PCA9956A is a 24-channel Fm+ I2C-bus 100mA/40V LED driver.

Dependencies:   CompLedDvr

Dependents:   PCA9626_Hello PCA9624_Hello PCA9622_Hello

What is this?

Code for PCA9626, PCA9622 and PCA9624.
24-channel, 16-channel and 8-channel PWM output LED driver component class.

Please refer to the component page for details

8, 16 & 24-channel Fm+ I2C-bus 100mA/40 V LED driver

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.
For detail information, refer API document of LedPwmOut Class class which is included in PCA962xA class library.

#include "mbed.h"
#include "PCA9626.h"

PCA9626     led_cntlr( p28, p27, 0xC4 );  //  SDA, SCL, Slave_address(option)
LedPwmOut   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

PCA9626

The PCA9626 is an I2C-bus controlled 24-bit LED driver optimized for voltage switch dimming and blinking 100 mA LEDs. Each LED output has its own 8-bit resolution (256 steps) fixed frequency individual PWM controller that operates at 97 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/PCA9626.pdf

PCA9622

The PCA9622 is an I2C-bus controlled 16-bit LED driver optimized for voltage switch dimming and blinking 100 mA LEDs. Each LED output has its own 8-bit resolution (256 steps) fixed frequency individual PWM controller that operates at 97 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/PCA9622.pdf

PCA9624

The PCA9624 is an I2C-bus controlled 8-bit LED driver optimized for voltage switch dimming and blinking 100 mA Red/Green/Blue/Amber (RGBA) LEDs. Each LED output has its own 8-bit resolution (256 steps) fixed frequency individual PWM controller that operates at 97 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/PCA9624.pdf

How the API works?

When the instance is made, all set up for PWM operation are done automatically.
PCA9626, PCA9624 and PCA9622 have internal 97kHz 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.

API_and_output

Tips for the chips

PCA962x family

This PCA962x components library can be used for all PCA9926(24-channel), PCA9922(16-channel) and PCA9624(8-channel).
If you are using both chips on the I2C bus, those can be operated like..

#include "mbed.h"
 
#include "PCA9622.h"
#include "PCA9626.h"

PCA9622    led0( p28, p27, 0xC0 );    //  SDA, SCL, Slave_address=0xC0 (16-channel chip)
PCA9626    led1( p28, p27, 0xC2 );    //  SDA, SCL, Slave_address=0xC2 (24-channel chip)
 
int main()
{
    led0.pwm( ....    //  PWM control for PCA9955A(16-channel chip)
    led1.pwm( ....    //  PWM control for PCA9956A(24-channel chip)
    ...

Sample code for each types

For PCA9624 (8 channel) : http://developer.mbed.org/users/nxp_ip/code/PCA9624_Hello/
For PCA9622 (16 channel) : http://developer.mbed.org/users/nxp_ip/code/PCA9622_Hello/
For PCA9626 (24 channel) : http://developer.mbed.org/users/nxp_ip/code/PCA9626_Hello/

Committer:
nxp_ip
Date:
Thu Mar 19 10:02:57 2015 +0000
Revision:
7:7ebf563f6e6c
Parent:
3:40f83904f0a8
API document update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 0:7a206e6db594 1 /** PCA962x PWM control LED driver family
nxp_ip 0:7a206e6db594 2 *
nxp_ip 0:7a206e6db594 3 * Abstract class for PCA962x family
nxp_ip 0:7a206e6db594 4 * No instance can be made from this class
nxp_ip 0:7a206e6db594 5 *
nxp_ip 7:7ebf563f6e6c 6 * @class PCA962x
nxp_ip 0:7a206e6db594 7 * @author Akifumi (Tedd) OKANO, NXP Semiconductors
nxp_ip 3:40f83904f0a8 8 * @version 0.6
nxp_ip 3:40f83904f0a8 9 * @date 04-Mar-2015
nxp_ip 0:7a206e6db594 10 *
nxp_ip 3:40f83904f0a8 11 * Released under the Apache 2 license License
nxp_ip 0:7a206e6db594 12 */
nxp_ip 0:7a206e6db594 13
nxp_ip 0:7a206e6db594 14 #ifndef MBED_PCA962x
nxp_ip 0:7a206e6db594 15 #define MBED_PCA962x
nxp_ip 0:7a206e6db594 16
nxp_ip 0:7a206e6db594 17 #include "mbed.h"
nxp_ip 3:40f83904f0a8 18 #include "CompLedDvr.h"
nxp_ip 0:7a206e6db594 19
nxp_ip 0:7a206e6db594 20 #define ALLPORTS 0xFF
nxp_ip 0:7a206e6db594 21 #define DEFAULT_PWM 1.0
nxp_ip 0:7a206e6db594 22
nxp_ip 3:40f83904f0a8 23 /** PCA962x class
nxp_ip 3:40f83904f0a8 24 *
nxp_ip 3:40f83904f0a8 25 * Abstract class for PCA962x family
nxp_ip 0:7a206e6db594 26 * No instance can be made from this class
nxp_ip 0:7a206e6db594 27 */
nxp_ip 3:40f83904f0a8 28 class PCA962x : public CompLedDvr
nxp_ip 0:7a206e6db594 29 {
nxp_ip 0:7a206e6db594 30 public:
nxp_ip 0:7a206e6db594 31 PCA962x( PinName i2c_sda, PinName i2c_scl, char i2c_address = DEFAULT_I2C_ADDR );
nxp_ip 0:7a206e6db594 32 PCA962x( I2C &i2c_obj, char i2c_address = DEFAULT_I2C_ADDR );
nxp_ip 0:7a206e6db594 33 virtual ~PCA962x();
nxp_ip 0:7a206e6db594 34
nxp_ip 0:7a206e6db594 35 void reset( void );
nxp_ip 0:7a206e6db594 36
nxp_ip 3:40f83904f0a8 37 virtual void pwm( int port, float v );
nxp_ip 3:40f83904f0a8 38
nxp_ip 0:7a206e6db594 39 void pwm( float *vp );
nxp_ip 0:7a206e6db594 40 virtual int number_of_ports( void ) = 0;
nxp_ip 0:7a206e6db594 41
nxp_ip 0:7a206e6db594 42 void write( char reg_addr, char data );
nxp_ip 0:7a206e6db594 43 void write( char *data, int length );
nxp_ip 0:7a206e6db594 44 char read( char reg_addr );
nxp_ip 0:7a206e6db594 45 void read( char reg_addr, char *data, int length );
nxp_ip 0:7a206e6db594 46
nxp_ip 0:7a206e6db594 47 protected:
nxp_ip 0:7a206e6db594 48 enum {
nxp_ip 0:7a206e6db594 49 DEFAULT_I2C_ADDR = 0xC0,
nxp_ip 0:7a206e6db594 50 AUTO_INCREMENT = 0x80,
nxp_ip 0:7a206e6db594 51 PWMALL = 0xFF
nxp_ip 0:7a206e6db594 52 };
nxp_ip 0:7a206e6db594 53
nxp_ip 0:7a206e6db594 54 private:
nxp_ip 0:7a206e6db594 55 virtual void initialize( void ) = 0;
nxp_ip 0:7a206e6db594 56 virtual char pwm_register_access( int port ) = 0;
nxp_ip 0:7a206e6db594 57
nxp_ip 0:7a206e6db594 58 I2C *i2c_p;
nxp_ip 0:7a206e6db594 59 I2C &i2c;
nxp_ip 0:7a206e6db594 60 char address; // I2C slave address
nxp_ip 0:7a206e6db594 61 }
nxp_ip 0:7a206e6db594 62 ;
nxp_ip 0:7a206e6db594 63
nxp_ip 0:7a206e6db594 64 #endif // MBED_PCA962x