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.

TCA8418: GPIO Usage

Part Number: TCA8418

I'm working with a design that has several GPIO inputs and outputs connected to a TCA8418. After looking through the datasheet, I have a few questions, and I'd also like to confirm that I'm not misunderstanding anything.

Outputs

Here's my understanding of how to configure/use a GPIO output after a POR:

  1. Write to the GPIO_DIR# registers to configure pins as outputs
  2. Write to the GPIO_DAT_OUT# registers to toggle outputs on/off

That's all I can glean from the datasheet. After POR, every pin defaults to GPIO mode (as per the KP_GPIO# registers), so I don't think there's anything else to do. 

Inputs

I'm trying to configure the inputs as simply as possible — no FIFO, no interrupts, no debounce, nothing like that. Here's what the process seems to be:

  1. Write to the GPIO_PULL# registers to configure pull-ups
  2. Read the GPIO_DAT_STAT# registers to poll input status

Again, this seems simple enough. Pins default to GPIO mode (KP_GPIO#) and interrupts are disabled (GPIO_INT_EN#) on POR, so this seems to be sufficient. 

I'm also curious how to read from the GPIO_DAT_STAT# registers. The datasheet says the following:

These registers show the GPIO state when read for inputs and outputs. Read these twice to clear them.

The last sentence doesn't make sense to me. What does it mean to "clear" this register? To me, this implies that these values latch when set, but I can't find this mentioned anywhere in the datasheet. Do these registers reflect the current state of GPIO inputs? Or do they need to be read twice (cleared) to get the current status?

Thanks!

  • Hello Matthew,

    Let me look at your question and get back to you shortly.

    -Francis Houde

  • Hello Matthew,

    Sorry for the delay.  This post fell off my radar.

    Here is a summary of your questions with my answers in bold:

    Outputs

    Here's my understanding of how to configure/use a GPIO output after a POR:

      1. Write to the GPIO_DIR# registers to configure pins as outputs

    Yes, it configures the GPIOs as either an input (set to 0, low) or to output (set to 1, high). Default is 0, therefore default states are all inputs.

     

      1. Write to the GPIO_DAT_OUT# registers to toggle outputs on/off

    GPIO_DAT_OUT1/2/3 registers set the output to 1 (high) or to 0 (low) for each given IO, but if the IO is set as an input it will do nothing. It must be configured as an output in GPIO_DIR1/2/3 registers.

    That's all I can glean from the datasheet. After POR, every pin defaults to GPIO mode (as per the KP_GPIO# registers), so I don't think there's anything else to do. 

    Inputs

    I'm trying to configure the inputs as simply as possible — no FIFO, no interrupts, no debounce, nothing like that. Here's what the process seems to be:

      1. Write to the GPIO_PULL# registers to configure pull-ups

    By default the GPIO has pull up resistors. If they are setup as inputs you shouldn’t leave them as floating or you could have abnormally high currents due to shoot through.

     

      1. Read the GPIO_DAT_STAT# registers to poll input status

    Yes, this is correct.

    Again, this seems simple enough. Pins default to GPIO mode (KP_GPIO#) and i

    nterrupts are disabled (GPIO_INT_EN#) on POR, so this seems to be sufficient. 

    I'm also curious how to read from the GPIO_DAT_STAT# registers. The datasheet says the following:

    These registers show the GPIO state when read for inputs and outputs. Read these twice to clear them.

    I am not sure if this is a typo. I need to look at this. I don’t know what that means to clear it. I will get back to you shortly with what I figure out.

    The last sentence doesn't make sense to me. What does it mean to "clear" this register? To me, this implies that these values latch when set, but I can't find this mentioned anywhere in the datasheet. Do these registers reflect the current state of GPIO inputs? Or do they need to be read twice (cleared) to get the current status?

    -Francis Houde