Author Topic: PCA9698 I2C Setting  (Read 2425 times)

Offline ABBASID

  • Newbie
  • *
  • Posts: 13
    • View Profile
PCA9698 I2C Setting
« on: June 21, 2021, 06:05:19 PM »
I am new to I2C protocol and trying to turn LED on/off connected to bank 0, pin 0 in MCUXpresso software by NXP. Would there be any code whihc I can use as reference  for I2C or atleast guide me how to configure PCA9698 for turning LED on/off ? What would be the sequence of device (slave) address, output configuration register and command register for output?
« Last Edit: June 21, 2021, 06:25:36 PM by ABBASID »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: PCA9698 I2C Setting
« Reply #1 on: June 21, 2021, 06:36:45 PM »
Hi

Assuming that the PCA9698 is connected with AD0, AD1 and AD2 at GND its write address is 0x40 and its read address is 0x41.

To configure the first output (only) the transmission sequence is
0x40 0x18 0xfe
which will change it from its default input to output and it will drive '0'

To change it to '1' the transmission sequence is
0x40 0x08 0x01

To change it back to '0' the transmission sequence is
0x40 0x08 0x00

uTasker I2C interface code to do it (on I2C0 at 100kb/s) is:

define I2C_WRITE_ADDRESS   0x40
define I2C_READ_ADDRESS    0x41

    static QUEUE_HANDLE I2CPortID = NO_ID_ALLOCATED;

    static const unsigned char ucConfigureOutput[] = {I2C_WRITE_ADDRESS, 0x18, 0xfe};
    static const unsigned char ucSetOutputHigh[] = {I2C_WRITE_ADDRESS, 0x08, 0x01};
    static const unsigned char ucSetOutputLow[] = {I2C_WRITE_ADDRESS, 0x08, 0x00};

    I2CTABLE tI2CParameters;

    tI2CParameters.Channel = 0;
    tI2CParameters.usSpeed = 100;                                        // 100k
    tI2CParameters.Rx_tx_sizes.TxQueueSize = 64;                         // transmit queue size
    tI2CParameters.Rx_tx_sizes.RxQueueSize = 64;                         // receive queue size
    tI2CParameters.Task_to_wake = 0;                                     // no wake on transmission termination
    I2CPortID = fnOpen(TYPE_I2C, FOR_I_O, &tI2CParameters);
    fnWrite(I2CPortID, (unsigned char *)ucConfigureOutput, sizeof(ucConfigureOutput));
    fnWrite(I2CPortID, (unsigned char *)ucSetOutputHigh, sizeof(ucSetOutputHigh));
    fnWrite(I2CPortID, (unsigned char *)ucSetOutputLow, sizeof(ucSetOutputLow));



Regards

Mark

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: PCA9698 I2C Setting
« Reply #2 on: June 23, 2021, 03:39:23 PM »
Hi

The sources you are using are from the NXP SDK which are not used in the uTasker project. For help solving problems with that code or its use it is best to ask at the NXP SDK user's forum.

Regards

Mark