This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMDX654IDKEVM: I2C IO expander programming

Part Number: TMDX654IDKEVM
Other Parts Discussed in Thread: TPIC2810, TCA9555

Hi there,

2 Questions at this stage:

I am currently playing around and stuying the I2C API's in order to program IO expansion headers. One goal for example is to program the MCU_UART_IO_EXP_SEL pin so that MCU_Rx data can be obtained from the MCU_UART test header. To study this, I imported the baremetal led_industrial_test files into the CCS baremetal template application, and got it running from there. Here is the project that executes successfully on the EVM: LEDtest.zip

Now I am trying to test some of the API's, of which the Board_i2cIoExpReadPort() API, located at  C:\ti\pdk_am65xx_1_0_5\packages\ti\board\src\evmKeystone3\board_i2c_io_exp.c is one. This API according to me is supposed to get the levels ('1'or '0') of the IO Expander, and store it in a user defined data buffer. However, I do not seem to get this API to retunr the correct values, please refer to my steps below:

- within BoardDiag_i2c_slave_device_led_test() function, I create a buffer in which the API should store the voltage levels of the IO expander:

    uint8_t readRegData[1] = {0};

- then, after the I2C has been initialized and right before I write some data to the I2C expander, I simply call the Board_i2cIoExpReadPort() API to first get the levels of the IO Expander pins:

            ret = Board_i2cIoExpReadPort(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, readRegData);

            ret = Board_i2cIoExpWritePort(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, writeRegData);

- however, I keep getting the same return value from the read API, which just fills the buffer with "1', however that obviously does not correspond to the states of the LED's (Only one LED is on at a certain time):

So my question is, how can I correctly use this API in order to get the levels of a IO expansion header? Maybe I am using this API completely wrong and making a very rooky mistake somewhere.

My other question, is that the IO expansion header which controls the LED's which I am currently testing, is of type TPIC2810D, which only has 8 pins, wereas the IO expansion header on which the MCU_UART_SEL pin is located, is of type TCA9555RTWR and has 16 pins:

Are there driver API's available for the TCA9555RTWR? Can the API's that are used on the TPIC2810 be used on it, and if so, how? Otherwise I guess I would manually have to go and develop driver API's for this IO expansion header in order to program the select pins.

I look forward to any assistance and advise.

I am using: 

- CCS910

- pdk_am65xx_1_0_5

- processor_sdk_rtos_am65xx_6_00_00_07

Kind regards,

Johhny

  • Johnny,

    These are good questions. Please let me research this a bit and get back with you.

    Regards,
    Frank

  • Thanks Franks,

    Here is some more testing I have done. These API's gives some very weird outputs on my end, or I might just be using the API's completely wrong. Here is some code I added in order to attempt to set the level of an individual pin on an IO Expander:

    ret = Board_i2cIoExpWritePort(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, 0b00000000);
    
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_0, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_1, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_2, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_3, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_4, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_5, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_6, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_7, GPIO_SIGNAL_LEVEL_HIGH);
    
                ret = Board_i2cIoExpWritePort(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, 0b00000000);
    
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_0, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_1, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_2, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_3, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_4, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_5, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_6, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(BOARD_I2C_IOEXP_DEVICE1_ADDR, PORTNUM_NONE, PIN_NUM_7, GPIO_SIGNAL_LEVEL_LOW);
    
                ret = Board_i2cIoExpWritePort(0x63, PORTNUM_NONE, 0b00000000);
    
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_0, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_1, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_2, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_3, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_4, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_5, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_6, GPIO_SIGNAL_LEVEL_LOW);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_7, GPIO_SIGNAL_LEVEL_LOW);
    
                ret = Board_i2cIoExpWritePort(0x63, PORTNUM_NONE, 0b00000000);
    
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_0, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_1, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_2, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_3, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_4, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_5, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_6, GPIO_SIGNAL_LEVEL_HIGH);
                ret = Board_i2cIoExpPinLevelSet(0x63, PORTNUM_NONE, PIN_NUM_7, GPIO_SIGNAL_LEVEL_HIGH);

    The above code simply turns of the LED's on the EVM and IDK card off, before attempting to switch on/off individual pins. The expected output when calling the Board_i2cIoExpPinLevelSet() API to set a pin to GPIO_SIGNAL_LEVEL_HIGH, according to me would be that ONLY the pin specified should be toggled on, while the states of the others should stay the same. However, ALL LEDs are turned on. When using PORNUM_0/1, the function never returns and gets stuck in the I2C_v1_waitForPin() function.

    When using the Board_i2cIoExpPinLevelSet() API with GPIO_SIGNAL_LEVEL_LOW, the expected output according to me would be that only the pin specified should be toggled off, while the state of the other pins should stay the same. However, all LEDs are turned on, expect for the pin specified.

    This is some weird behaviour. Its almost as if the Board_i2cIoExpReadPort() (which is called within the above functions as well) sets the pins to high and returns its like that.

    Please let me know when you have some feedback.

    Kind regards,

    Johnny

  • Johnny,

    Is this still an issue for you, or did you resolve the I2C IO expander issues? Unfortunately I haven't had a chance to follow up on this.

    Regards,
    Frank

  • Hi Frank,

    Some of the APIs I still experience issues with, however that was only associated with the TPIC2810 LED driver chip. I thus think that these exact APIs were not developed for this chip, although some APIs can still be used successfully. I have successfully used it on the TCA9555 chip. I believe the issues with the API used with the LED driver chip is the incorrect reading and writing from and to the data shift register.

    Thanks.

    Kind regards,

    Johnny