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.

Can the IO-Expander-EVM work as a stand alone?

Other Parts Discussed in Thread: IO-EXPANDER-EVM, TCA9539, TCA6424

   I am attempting to utilize the IO-Expander-EVM to expand GPIO pins of another board. I would like to utilize the I2C capabilities of this board to show that I2C commands can be transmitted to the board and turn on LEDs connected to the GPIO pins. I have read the data sheet (SLVUA59A) and it states in 5.1.2 (pg 4) that the IO Expander EVM can be used separate form the LaunchPad, but I am not understanding how to do this. Could someone please direct me to a resource that will explain this?

  • Hi Brian,

    The SDA and SCL lines for the device are routed to pins 6 and 7 (respectively) of connector J2. They are also broken out on connector J8. If you didn't want to use the LaunchPad, you could connect your I2C master onto either of these connectors to interface it directly with the IO expander.

    Max
  • Max,

    Thank you for the reply. I will try this out and report back results.

    Brian
  • Max,

    After connecting the pins as described above, what do I call the GPIO pins? What are their numbers for C or Python? Or do I use the GUI software set-up (I am attaching it to a Raspberry Pi)?
  • Brian,

    You should look into the documentation for whichever IO expander device is installed on the board and see how its various GPIO ports can be addressed and controlled via the I2C interface. Then, you could program your Raspberry Pi to send the correct I2C commands to access the GPIOs as needed for your application. (This is basically what the GUI does.)

    Max
  • Max

    I have looked into the data sheet and ran on my Raspberry Pi "sudo i2cdetect -y 1" and have two I2C devices with address 0x22 and 0x77. I am utilizing python to write my code and I am not able to access the GPIO. my code is as follows:

    import smbus

    import time

    import sys

    bus = smbus.SMBus(1)

    Device77 =  0x77

    Device22 = 0x22

    bus.write_byte_data(Device77, 0x00, 0xff)

    I used both Device77 and Device22 as well as walked through hex address of pins according to datasheet, but no LEDs lite up. Am I misunderstanding the hex address of the pins or is my code incorrect? Appreciate the assistance with this.

    Brian

  • Max,

    I have figured out the code, now trying to figure out identifying the GPIO pins. The code in python is:

    import smbus
    import time
    import sys

    REG_Input_0 = 0x00 # Input Port 0
    REG_Input_1 = 0x01 # Input Port 1
    REG_Output_0 = 0x02 # Output Port 0
    REG_Output_1 = 0x03 # Output Port 1
    REG_Polarity_0 = 0x04 # Polarity Inversion Port 0
    REG_Polarity_1 = 0x05 # Polarity Inversion Port 1
    REG_Direction_0 = 0x06 # Configuration Port 0
    REG_Direction_1 = 0x07 # Configuration Port 1

    In = 0 # Input
    Out = 1 # Output

    bus = smbus.SMBus(1) # This is the I2C Bus

    Device77 = 0x77 # This is the address of device on U2 (which is TCA9539)
    Device22 = 0x22 # This is the address of device on U1 (Which is TCA6424)

    bus.write_byte_data(Device77, REG_Direction_0, Out)
    bus.write_byte_data(Device77, REG_Polarity_0, 0)
    bus.write_byte_data(Device77, REG_Output_0, 0x02) # This lights up LED on P00

    time.sleep (1)

    bus.write_byte_data(Device77, REG_Polarity_0, 0)
    bus.write_byte_data(Device77, REG_Output_0, 0x01) # This lights up LED on P01

    time.sleep (1)

    bus.write_byte_data(Device77, REG_Polarity_0, 0)
    bus.write_byte_data(Device77, REG_Output_0, 0x07) # This lights up LED on P02

    time.sleep (1)

    bus.write_byte_data(Device77, REG_Polarity_0, 0)
    bus.write_byte_data(Device77, REG_Output_0, 0x0b) # This lights up LED on P03

    time.sleep (1)

    I am attempting to figure out the pattern on which Hex will light up which LED. Do you have any information on this?


    Brian

  • Hi Brian,

    The pin-to-bit mapping is given in Table 1 of the TCA9539 datasheet (see bottom of page 20).

    If you are following this mapping and not getting what you expect, it's probably wise to verify that your write and read functions are working by writing and reading to a read/write register (like 0x06 on TCA9539). You should be able to read back the same value that you wrote.

    Then, you may want to verify that each line of your code is doing what you expect. For example, your first command is:

    bus.write_byte_data(Device77, REG_Direction_0, Out)

    I'm not an expert on Python, but it looks like this will write the value 1 (the "Out" variable) to register 0x06. It seems like this would result in a register value of 00000001, meaning that 7 of 8 total GPIOs on Port 0 wiould be configured as outputs with the last one being an input. Is this correct? If so, is it what you intended?

    I noticed a couple of other things that looked like typos as well:

    REG_Polarity_1 = ox05 # Polarity Inversion Port 1 (o used instead of 0)
    REG_Direction_1 = 0x06 # Configuration Port 1 (should be 0x07).

    Hope this helps! Let me know if you still have problems.

    Regards,
    Max
  • Max,

    Thank you for the assistance. Yes you were correct, by only sending a value of 1 (0b00000001 or 0x01) it did not activate all pins. I have finally completed the code and I am able to activate the various GPIO pins and associated LEDs. As soon as I clean up the code, I will gladly share it here for any in the future to see and use in case they wish to utilize the IO Expander EVM board without the TI MSP430 Launch Pad. Thank you for your assistance and appreciate it.

    Brian
  • Brian,

    Glad to hear everything is working for you!

    Max