PCA9632 very simple operation sample. PCA9632 is 4 channel LED controller from NXP semiconductors.
Simple sample code for PCA9632 : 4-bit Fm+ I2C-bus low power LED driver
This is a simple operation sample code for PCA9632.
The PCA9632 is an I2C-bus controlled 4-bit LED driver optimized for Red/Green/Blue/Amber (RGBA) color mixing applications. The PCA9632 is a drop-in upgrade for the PCA9633 with 40 power reduction. In Individual brightness control mode, each LED output has its own 8-bit resolution (256 steps) fixed frequency Individual PWM controller that operates at 1.5625 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. In group dimming mode, each LED output has its own 6-bit resolution (64 steps) fixed frequency Individual PWM controller that operates at 6.25 kHz with a duty cycle that is adjustable from 0 % to 98.4 % to allow the LED to be set to a specific brightness value. A fifth 4-bit resolution (16 steps) Group PWM controller has a fixed frequency of 190 Hz that is used to dim all the LEDs with the same value.
For more details, please refer.. http:www.nxp.com/documents/data_sheet/PCA9632.pdf.
If you have an evaluation board for PCA9632, please find next picture for wiring.
The evaluation board OM13269's information is available in http:www.nxp.com/documents/user_manual/UM10528.pdf.
main.cpp
- Committer:
- nxp_ip
- Date:
- 2014-01-22
- Revision:
- 0:8726e00b9c04
File content as of revision 0:8726e00b9c04:
/** PCA9632 very simple operation sample * * @author Akifumi (Tedd) OKANO, NXP Semiconductors * @version 1.0 * @date 22-Jan-2014 * * Released under the Apache 2.0 open source licence -- http://opensource.org/licenses/Apache-2.0 * * This sample operates 4 LEDs on the evaluation board (OM13269 -- http://www.nxp.com/documents/user_manual/UM10528.pdf). * LED1(Red), LED2(Green) and LED3(Blue) are PWM controlled from mbed. * LED4 is controlled by group PWM function of PCA9632 */ #include "mbed.h" I2C i2c( p28, p27 ); char data[] = { 0x80, 0x80, 0x21, 0x00, 0x00, 0x00, 0x40, 0x80, 0x02, 0xEA }; char blink_rate[] = { 0x07, 0x00 }; #define I2C_ADDRESS 0xC4 int main() { int count; i2c.write( I2C_ADDRESS, data, sizeof( data ) ); while ( 1 ) { for ( count = 0; count < 12; count++ ) { data[ 3 + ((count + 2) % 3) ] = 0xFF; data[ 3 + ((count + 1) % 3) ] = 0x00; data[ 3 + ((count + 0) % 3) ] = 0x00; data[ 7 ] = 0; data[ 8 ] = 0; i2c.write( I2C_ADDRESS, data, 9 ); wait( 0.25 ); data[ 3 ] = 0x00; data[ 4 ] = 0x00; data[ 5 ] = 0x00; data[ 7 ] = 0; data[ 8 ] = 0; i2c.write( I2C_ADDRESS, data, 9 ); count++; wait( 0.25 ); } for ( count = 0; count < 4096; count++ ) { data[ 3 + (((count >> 8) + 2) % 3) ] = 0xFF - (count & 0xFF); data[ 3 + (((count >> 8) + 1) % 3) ] = 0x00; data[ 3 + (((count >> 8) + 0) % 3) ] = count & 0xFF; data[ 7 ] = 0; data[ 8 ] = 0; i2c.write( I2C_ADDRESS, data, 9 ); count++; wait( 0.002 ); } for ( count = 0; count < 2048; count++ ) { data[ 3 + (((count >> 8) + 2) % 3) ] = 0xFF - (count & 0xFF); data[ 3 + (((count >> 8) + 1) % 3) ] = 0x00; data[ 3 + (((count >> 8) + 0) % 3) ] = count & 0xFF; data[ 7 ] = (count >> 9) & 0x1 ? 0x80 : 0x10; data[ 8 ] = (count >> 10) & 0x1 ? 23 : 2; i2c.write( I2C_ADDRESS, data, 9 ); count++; wait( 0.01 ); } } }