PCA9632

From Ethersex_Wiki
Revision as of 22:59, 11 May 2013 by Beroot (talk | contribs) (Created page with "{{i18n|PCA9632}} {{Module |NAME=PCA9632 |MENUCONFIG={{I/O}}->{{I2C Master}}->I2C PCA9632 |STATUS={{Experimental}} |PINNING=no |ECMD={{has_ecmd}} |CONTROL6= |DEPENDS=ECMD [[I2…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
PCA9632
Status
Experimental
menuconfig I/O->I2C Master Support->I2C PCA9632
Pinning no
Ecmd yes
Depends on ECMD I2C Master I2C Generic
Requires -
Code https://github.com/ethersex/ethersex/tree/master/hardware/i2c/master

Driver for the PCA9632 4-Bit LED driver I2C-bus chip from NXP.

Please refer to the datasheet for further informations about setting the registers and connecting LEDs to the driver outputs. The dataheet can be fopund here: [1]

Connection

The PCA9632 is connected to the I2C-bus (with pins SDA and SCL). The particular pin numbers depend on the package used (8- or 10-pin).

The device slave address is 0x62 (dec. 98). This address is fixed for the 8-pin version. With this package only one chip can be connected to an i2c-bus. The 10-pin package hat two additional address pins which allow up to 4 chips on one bus.

Configuration

 │ │          Load a Default Configuration  --->
 │ │          General Setup  --->
 │ │          Network --->
 │ │          I/O ---> 
 ...
 │ │               [*] I2C Master Support  --->
 ...
 │ │                       [*]   I2C generic read/write support  --->
 ...
 │ │                       [*]   I2C PCA9632  4-bit LED dimmer


ECMD

PCA9632 implements a ECMD interface for reading and writing the LED status. See ECMD reference.

Provided Functions

hardware/i2c/master/i2c_pca9632.h provides and defines the following functions:

i2c_pca9632_reset() Resets the device to the power-up state values. Returns 0 when ok or 1 if an error occurred.

i2c_pca9632_init(uint8_t address, uint8_t mode1, uint8_t mode2, uint8_t led_out_state) Initializes the "configuration" registers. Address is the slave address of the chip (0x62h). In register MODE1 only bit 4 is essential. After power up the internal oscillator is switched off representing bit is 1 (low power mode). To be able to change the LEDs PWM values the oscillator must be turned on by setting bit 4 to 0. All other bits are for standard applications not relevant. Register MODE2 set open-drain or toem pole structure (bit 2), sets outputs inverted or not (bit 4) and sets the group control to dimming or blinking (bit 5). led_out_state set the LED drivers on, off, by PWM, additional group dimm/blink.

i2c_pca9632_set_blink(uint8_t address, uint8_t grppwm, uint8_t grpfreq) When dimming is set in MODE2 register the grppwm value sets the global dimmimgn of all LEDs. When blinking is set by MODE2 then grppwm sets the duty cycle and grpfreq sets the frequency.

i2c_pca9632_set_led(uint8_t address, uint8_t led_x, uint8_t pwm_x) Sets the individual PWM_x value of LED_x (x from 0 to 3). Corresponds to write the registers 0x02h (LED0) to 0x05h (LED3).

i2c_pca9632_read_led(uint8_t address, uint8_t led_x) Reads and returns the individual PWM value of LED_x (0 to 3).

Register Explanations

MODE1 (register address 0x00h)
bit 4 (SLEEP) has to be set to 0 to start the oscillator and to be able to set LED PWM values.
 
MODE2 (register address 0x01h) (* is default value)
bit  value  description
0    0*     unused
1    1*     unused
2    0*     output open-drain
     1      output totem pole
3    0*     change on STOP
     1      change on ACK (important for synchronizing chips)
4    0*     output NOT inverted
     1      output inverted
5    0*     group control = dimming
     1      group control = blinking
6    0*     reserved
7    0*     reserved

PWM registers 0 to 3 (0x02h to 0x05h) (* is default value)
address  register value
02h      PWM0     00000000*
03h      PWM1     00000000*
04h      PWM2     00000000*
05h      PWM3     00000000*

GRPPWM Group duty cycle register (0x06h)
address  register value
06h      GRPPWM   11111111

GRPFREQ Group frequency register (0x07h)
address  register value
07h      GRPFREQ  00000000*

LED_OUT_STATE (register address 0x08h) (* is default value)
bit  symbol  value
0,1  LDR0    00*
2,3  LDR1    00*
4,5  LDR2    00*
6,7  LDR3    00*

LDRx = 00 LED driver is off
LDRx = 01 LED driver is on
LDRx = 10 LED driver is individually controlled by its PWM
LDRx = 11 LED driver is additionally controlled by group dimming or blinking