Skip to main content
Associate II
September 25, 2023
Question

NUCLEO491RE I2C COMMUNICATION WITH TCA9537

  • September 25, 2023
  • 4 replies
  • 3459 views

I am using nucleo491re MCU  to communicate with tca9537 GPIO-Expander . I want to use GPIO  for on/off  in tca9537 based on i2c . IN tca9537 I have four resister 1. Input(read) address( 0x01) 2.output (read/write) address(0x02) 3.polarity address( 0x03) .4.configuration address(0x04). and slave address (0x49).

For changing all pins to output mode .

HAL_I2C_Mem_Write(&hi2c, (slave address<<1), configuration address , 1,(uint8_t*) 0xF0, 1, I2C_TIMEOUT);

FOR making pins to high state .

HAL_I2C_Mem_Write(&hi2c, (slave address<<1), output , 1,(uint8_t*) 0xFF, 1, I2C_TIMEOUT);

 

I am getting only slave address on SDA LINE and IO pins not showing anything not high and not law

anyone tell me how to use GPIO-Expander pins for on/off purpose.

 

TCA1.PNGTCA2.PNGTCA3.PNG

This topic has been closed for replies.

4 replies

Foued_KH
ST Employee
September 25, 2023

Hello @ishu , 

Could you please share a screenshot from the analyzer?

Foued 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ishuAuthor
Associate II
September 25, 2023

analysr.PNG

SDA-YELLOW ,SCL-GREEN,PIN P0 =RED

TDK
Super User
September 25, 2023

> (uint8_t*) 0xF0

This doesn't do what you think it does. Do this instead:

uint8_t data = 0xF0;
HAL_I2C_Mem_Write(&hi2c, (slave address<<1), configuration address, 1, &data, 1, I2C_TIMEOUT);

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
Foued_KH
ST Employee
September 25, 2023

Hi @ishu ,

Do this instead: 

 

#define slave address 0x49 << 1
uint8_t data = 0xF0;
HAL_I2C_Mem_Write(&hi2c, slave address, configuration address , 1,&data , 1, I2C_TIMEOUT);

 

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
David Littell
Senior II
September 25, 2023

Verify the TCA register addresses your using relative to Table 8-2.