PCA6416-microtronics: Library for interfacing NXP PCA6416A 16-bit I2C-bus I/O expander with interrupt output

Hello rapidM2M Community,

Sometimes you need more I/Os than your hardware provides. This can be the case if you need several sensors or buttons in your application. The PCA6416A is a simple solution for expanding the I/O interface.

PCA6416A features

  • I2C interface with communication speed up to 400 kHz
  • Two user selectable addresses (chosen by chip pin)
  • Built-in level shifter
  • Interrupt output for indicating that an input state has changed

Features of the PCA6416 Library

  • Provides 16 additional I/Os per PCA6416A
  • Allows to determine the status of the as input configured I/Os by pure polling (no additional IRQ pin required on the controller) or in response to an IRQ, that reported to the controller.
  • You need an I²C interface, optionally also an IRQ pin, if the IRQ function of the PCA6416 is used. This is recommended if a fast reaction to a status change at the inputs of the PCA6416 is required.

The Library is very easy to use. You only need two function calls to read inputs or write outputs (PCA6416_Init and PCA6416_Read or PCA6416_Write). If you use the IRQ you have to add the functions PCA6416_IrqInit and a callback function. To deactivate the IRQ you use the PCA6416_IrqClose function.

With the PCA6416_Com function you can read any data from the chip and send it to the chip. This allows the implementation of any function that is not yet covered by the lib.

The debug functions allow to display various information in the watch window:

  • I²C address of the PCA6416A on each access
  • Direction of the I/O pins
  • Levels for the outputs at the initialisation
  • Content of the input register when calling PCA6416_Read
  • Levels for the output when calling PCA6416_Write

For more Information see PCA6416 Lib

Do you have further questions about the PCA6416 Library? Then do not hesitate to ask them here in forum in this topic?

Kind regards
Microtronics Engineering