Skip to main content
Anej Knez
Associate II
July 28, 2022
Question

74HC138, One I2C bus - 4 I2C devices

  • July 28, 2022
  • 4 replies
  • 1339 views

Hi,

I am using 4 NFC 4 Clicks in combination with 74HC138 to connect them directly to on I2C bus. Can anyone hep me how do I implement this in my code so that he controller would switch between every I2C device.

Rgrd,

Anej

This topic has been closed for replies.

4 replies

Paul1
Senior III
July 28, 2022

Options:

  • STM32 pin to each CS pin on NFC (4 STM32 GPO pins)
  • STM32 2 pins to 74HC138 Y0-Y3 to 4 NFC CS pins. 74HC138 has active Low outputs, are the NFC CS pins active Low or active Hi? (2 STM32 GPO pins)
  • STM32 SCL pin to 74HC138 E* pin, and Y0..Y3 to SCL of each NFC (2 STM32 GPO pins)

Paul

Javier1
Principal
July 28, 2022

So you are decided to use the SPI interface? do you chose it for the speed?

Do you know that SPI and I2C are different things ,right?

hit me up in https://www.linkedin.com/in/javiermuñoz/
Javier1
Principal
July 28, 2022

I dont have any experience with those modules but it says they can be controlled via I2C.... you only need to connect a I2C bus (two wires + ground +vcc) and forget about the CS

hit me up in https://www.linkedin.com/in/javiermuñoz/
Tesla DeLorean
Guru
July 28, 2022

How's the 74HC138 wired in this contrivance?

Not sure it's something I'd use for I2C, is there some way to set or select I2C slave addresses?

How about sourcing SCL from different pins on the STM32 side, and then cycling who's using which one.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Paul1
Senior III
July 28, 2022

Agree with Javier,

*) CS is for SPI only.

Like Tesla said

a) Configure each NFC for different I2C address (if possible?)

b) Use different I2C ports on MCU for each NFC

or

c) Use the HC138 to fan out the SCK, and use two GPIO pins to control the HC138.