<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Embedded Software and Tools Clinic中的主题 PCA9955B led driver with raspberry pi issue</title>
    <link>https://community.nxp.com/t5/Embedded-Software-and-Tools/PCA9955B-led-driver-with-raspberry-pi-issue/m-p/1771537#M434</link>
    <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;I want to Drive led connected to ch0 of PCA9955B (LED driver) with 100% brightness or at least turn ON LED.I'm trying to use PCA9955B LED Driver with an I2C interface.I can't convince any meaningful output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Connections made between led driver IC and the PI are:&lt;BR /&gt;LED driver&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Raspberry pi&lt;BR /&gt;SDA(27)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SDA(GPIO 2)&lt;BR /&gt;SCL(26)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SCL(GPIO 3)&lt;BR /&gt;VDD(28)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.3V(GPIO 1)&lt;BR /&gt;GND(10,19,24)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GND(GPIO39)&lt;BR /&gt;OE pin(5)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;with 10K resistor to&amp;nbsp;GND(GPIO39) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;RESET(25)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; with 10K resistor to 3.3V(GPIO 1)&lt;BR /&gt;REXT(1)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GND&lt;BR /&gt;LED0(6)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LED-&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LED+(3.3V)&lt;/P&gt;&lt;P&gt;AD0,AD1,AD2&amp;nbsp; connected to GND So i am getting I2C address 70.&lt;/P&gt;&lt;P&gt;i am using following code but led not get ON&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"use strict";
// PCA9955 test
const PCA9955 = require("../hardware/led_driver_pca9955b.js");

const I2C_CHANNEL = 1; // SDA1 &amp;amp; SCL1
const I2C_ADDR_PCA9955B = 0x70;
const ledDriver = new PCA9955(I2C_CHANNEL, I2C_ADDR_PCA9955B);
ledDriver.start(); // Initialize I2C communication

ledDriver.selectChannel(0);
ledDriver.setDuty(1.0); // 100% drive&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is&amp;nbsp; "../hardware/led_driver_pca9955b.js")&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// PCA9955B (16ch I2C LED driver)

"use strict";
const rpio = require('rpio');
const raspi = require('raspi');

const i2c = require('i2c-bus');
const DEFAULT_BUS_NUMBER = 1;
const REG_ADDR_LEDOUT0 = 0x02;
const REG_ADDR_LEDOUT1 = 0x03;
const REG_ADDR_LEDOUT2 = 0x04;
const REG_ADDR_LEDOUT3 = 0x05;

const LED_COUNT = 16;

class PCA9955B {
  /**
   * 
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {(number|i2c-bus)} i2c Number of I2C bus or i2c-bus object
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} address Device address
   */
  constructor (i2c, address) {
    if (typeof(i2c)=="number") {
      console.log("ADC channel is specified by bus number.");
      if ( !(i2c == 1 || i2c == 2)) {
        throw new Error("i2cBusNumber should be 1 or 2.");
      }
      this.i2cBusNumber = i2c;
    } else if (i2c != null) {
      this.i2c = i2c;
    } else {
      this.i2cBusNumber = DEFAULT_BUS_NUMBER;
    }
    this.leds = [];
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds.push(false)
    }
    this.address = address;
  }
  start () {
    if (this.i2c == null) {
      console.log("ADC channel opening: %d", this.i2cBusNumber);
      this.i2c = i2c.openSync(this.i2cBusNumber);  //i2c1 or i2c2
        console.log("ADC channel opened: %d", this.i2cBusNumber);
    }
  }
  // Call this to get ready for blank control (by OD pin)
  setBlankControlMode () {
    // Enable  auto increment
    this.i2c.i2cWriteSync(this.address, 2, Buffer.from([0x00, 0b10001001]));
    this._writeRegisterSeqSameValues(0x18, 0xFF, 16); // Current value
  }

  /**
   * On single channel
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} ch Channel index
   */
  selectChannel (ch) {
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds[i] = (ch == i);
    }
    this._applyLEDSelection();
  }
  /**
   * On multiple channels
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number[]} chs Array of activated channels
   */
  selectChannels (chs) {
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds[i] = false;
    }
    chs.forEach((ch)=&amp;gt;{
      this.leds[ch] = true;
    });
    this._applyLEDSelection();
  }

  /**
   * Set output gain control value for specified channel
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} ch Traget channel (0 - 15)
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} iref IREFn value (0 - 255)
   */
  setIREF (ch, iref) {
    if (ch &amp;lt; 0 || ch &amp;gt; 15) {
      throw "Parameter ch should be within 0-15";
    }
    if (iref &amp;lt; 0 || iref &amp;gt; 255) {
      throw "Parameter iref should be within 0-255";
    }
    const registerAddress = ch + 0x18;
    this._writeRegisterSingle (registerAddress, iref);
  }
  
  /**
   * On all channels
   */
  onAll () {
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds[i] = true;
    }
    this._applyLEDSelection();
  }
  
  /**
   * Off all channels
   */
  offAll () {
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds[i] = false;
    }
    this._applyLEDSelection();
  }
  
  /**
   * Set PWM duty
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} val 
   */
  setDuty (val) {
    if (this.useBlankPWM) {
      this.blank.write(val);
    }
  }
  
  off () {
    this.offAll();
  }

  _writeRegisterSingle (regAddr, value) {
    this.i2c.i2cWriteSync(this.address, 2, Buffer.from([regAddr, value]));
  }
  _writeRegisterSeq (startAddr, values) {
    const firstVal = startAddr | (0b01 &amp;lt;&amp;lt; 7);
    let regValues = [firstVal].concat(values); // Auto-increment + First reg address
    this.i2c.i2cWriteSync(this.address, regValues.length, Buffer.from(regValues));
  }
  _writeRegisterSeqSameValues (startAddr, value, count) {
    const firstVal = startAddr | (0b01 &amp;lt;&amp;lt; 7);
    let regValues = [firstVal];
    for (let i=0; i&amp;lt;count; i++) {
      regValues.push(value);
    }
    this.i2c.i2cWriteSync(this.address, regValues.length, Buffer.from(regValues));
  }
  _applyLEDSelection () {
    let regValues = [];
    for (let groupIndex = 0; groupIndex &amp;lt; LED_COUNT/4; groupIndex++) {
      let regVal = 0b00000000;
      for (let i=0; i&amp;lt;4; i++) {
        let modeVal = (this.leds[groupIndex * 4 + i]) ? 0b01 : 0b00;
        regVal = regVal | (modeVal &amp;lt;&amp;lt; (i*2));
      }
      regValues.push(regVal);
    }
    this._writeRegisterSeq(REG_ADDR_LEDOUT0, regValues);
  }
}
module.exports = PCA9955B;&lt;/LI-CODE&gt;&lt;P&gt;After running code i am not get any output.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 08 Dec 2023 12:40:29 GMT</pubDate>
    <dc:creator>IoTIan</dc:creator>
    <dc:date>2023-12-08T12:40:29Z</dc:date>
    <item>
      <title>PCA9955B led driver with raspberry pi issue</title>
      <link>https://community.nxp.com/t5/Embedded-Software-and-Tools/PCA9955B-led-driver-with-raspberry-pi-issue/m-p/1771537#M434</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;I want to Drive led connected to ch0 of PCA9955B (LED driver) with 100% brightness or at least turn ON LED.I'm trying to use PCA9955B LED Driver with an I2C interface.I can't convince any meaningful output.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Connections made between led driver IC and the PI are:&lt;BR /&gt;LED driver&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Raspberry pi&lt;BR /&gt;SDA(27)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SDA(GPIO 2)&lt;BR /&gt;SCL(26)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SCL(GPIO 3)&lt;BR /&gt;VDD(28)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.3V(GPIO 1)&lt;BR /&gt;GND(10,19,24)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GND(GPIO39)&lt;BR /&gt;OE pin(5)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;with 10K resistor to&amp;nbsp;GND(GPIO39) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt;RESET(25)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; with 10K resistor to 3.3V(GPIO 1)&lt;BR /&gt;REXT(1)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GND&lt;BR /&gt;LED0(6)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LED-&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LED+(3.3V)&lt;/P&gt;&lt;P&gt;AD0,AD1,AD2&amp;nbsp; connected to GND So i am getting I2C address 70.&lt;/P&gt;&lt;P&gt;i am using following code but led not get ON&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;"use strict";
// PCA9955 test
const PCA9955 = require("../hardware/led_driver_pca9955b.js");

const I2C_CHANNEL = 1; // SDA1 &amp;amp; SCL1
const I2C_ADDR_PCA9955B = 0x70;
const ledDriver = new PCA9955(I2C_CHANNEL, I2C_ADDR_PCA9955B);
ledDriver.start(); // Initialize I2C communication

ledDriver.selectChannel(0);
ledDriver.setDuty(1.0); // 100% drive&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is&amp;nbsp; "../hardware/led_driver_pca9955b.js")&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// PCA9955B (16ch I2C LED driver)

"use strict";
const rpio = require('rpio');
const raspi = require('raspi');

const i2c = require('i2c-bus');
const DEFAULT_BUS_NUMBER = 1;
const REG_ADDR_LEDOUT0 = 0x02;
const REG_ADDR_LEDOUT1 = 0x03;
const REG_ADDR_LEDOUT2 = 0x04;
const REG_ADDR_LEDOUT3 = 0x05;

const LED_COUNT = 16;

class PCA9955B {
  /**
   * 
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {(number|i2c-bus)} i2c Number of I2C bus or i2c-bus object
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} address Device address
   */
  constructor (i2c, address) {
    if (typeof(i2c)=="number") {
      console.log("ADC channel is specified by bus number.");
      if ( !(i2c == 1 || i2c == 2)) {
        throw new Error("i2cBusNumber should be 1 or 2.");
      }
      this.i2cBusNumber = i2c;
    } else if (i2c != null) {
      this.i2c = i2c;
    } else {
      this.i2cBusNumber = DEFAULT_BUS_NUMBER;
    }
    this.leds = [];
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds.push(false)
    }
    this.address = address;
  }
  start () {
    if (this.i2c == null) {
      console.log("ADC channel opening: %d", this.i2cBusNumber);
      this.i2c = i2c.openSync(this.i2cBusNumber);  //i2c1 or i2c2
        console.log("ADC channel opened: %d", this.i2cBusNumber);
    }
  }
  // Call this to get ready for blank control (by OD pin)
  setBlankControlMode () {
    // Enable  auto increment
    this.i2c.i2cWriteSync(this.address, 2, Buffer.from([0x00, 0b10001001]));
    this._writeRegisterSeqSameValues(0x18, 0xFF, 16); // Current value
  }

  /**
   * On single channel
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} ch Channel index
   */
  selectChannel (ch) {
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds[i] = (ch == i);
    }
    this._applyLEDSelection();
  }
  /**
   * On multiple channels
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number[]} chs Array of activated channels
   */
  selectChannels (chs) {
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds[i] = false;
    }
    chs.forEach((ch)=&amp;gt;{
      this.leds[ch] = true;
    });
    this._applyLEDSelection();
  }

  /**
   * Set output gain control value for specified channel
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} ch Traget channel (0 - 15)
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} iref IREFn value (0 - 255)
   */
  setIREF (ch, iref) {
    if (ch &amp;lt; 0 || ch &amp;gt; 15) {
      throw "Parameter ch should be within 0-15";
    }
    if (iref &amp;lt; 0 || iref &amp;gt; 255) {
      throw "Parameter iref should be within 0-255";
    }
    const registerAddress = ch + 0x18;
    this._writeRegisterSingle (registerAddress, iref);
  }
  
  /**
   * On all channels
   */
  onAll () {
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds[i] = true;
    }
    this._applyLEDSelection();
  }
  
  /**
   * Off all channels
   */
  offAll () {
    for (let i=0; i&amp;lt;LED_COUNT; i++) {
      this.leds[i] = false;
    }
    this._applyLEDSelection();
  }
  
  /**
   * Set PWM duty
   * &amp;lt;li-user uid="197964" login="Param"&amp;gt;&amp;lt;/li-user&amp;gt; {!number} val 
   */
  setDuty (val) {
    if (this.useBlankPWM) {
      this.blank.write(val);
    }
  }
  
  off () {
    this.offAll();
  }

  _writeRegisterSingle (regAddr, value) {
    this.i2c.i2cWriteSync(this.address, 2, Buffer.from([regAddr, value]));
  }
  _writeRegisterSeq (startAddr, values) {
    const firstVal = startAddr | (0b01 &amp;lt;&amp;lt; 7);
    let regValues = [firstVal].concat(values); // Auto-increment + First reg address
    this.i2c.i2cWriteSync(this.address, regValues.length, Buffer.from(regValues));
  }
  _writeRegisterSeqSameValues (startAddr, value, count) {
    const firstVal = startAddr | (0b01 &amp;lt;&amp;lt; 7);
    let regValues = [firstVal];
    for (let i=0; i&amp;lt;count; i++) {
      regValues.push(value);
    }
    this.i2c.i2cWriteSync(this.address, regValues.length, Buffer.from(regValues));
  }
  _applyLEDSelection () {
    let regValues = [];
    for (let groupIndex = 0; groupIndex &amp;lt; LED_COUNT/4; groupIndex++) {
      let regVal = 0b00000000;
      for (let i=0; i&amp;lt;4; i++) {
        let modeVal = (this.leds[groupIndex * 4 + i]) ? 0b01 : 0b00;
        regVal = regVal | (modeVal &amp;lt;&amp;lt; (i*2));
      }
      regValues.push(regVal);
    }
    this._writeRegisterSeq(REG_ADDR_LEDOUT0, regValues);
  }
}
module.exports = PCA9955B;&lt;/LI-CODE&gt;&lt;P&gt;After running code i am not get any output.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 12:40:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Embedded-Software-and-Tools/PCA9955B-led-driver-with-raspberry-pi-issue/m-p/1771537#M434</guid>
      <dc:creator>IoTIan</dc:creator>
      <dc:date>2023-12-08T12:40:29Z</dc:date>
    </item>
  </channel>
</rss>

