cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass Salve address in HAL_I2C_Master_Transmit ? " The device 7 bits address value in datasheet must be shifted to the left before calling the interface"

SSala.3
Associate III

Hello,

I am configuring KSZ8863 3 port switch over I2C. And the slave address Read/Write address is oxBF/0xBE respectively. In the HAL reference manual it says the address should be shifted left before calling the interface. It's confusing, if I am shifting it (0xBE <<1), the address becomes 0x7C. Or the HAL_I2C transmit will handle the address even if shifted?

Also, should I send the address as 0xBF while using HAL_I2C_Receive ?

Below are the HAL functions used in my code.

HAL_I2C_Master_Transmit(&hi2c1, KSZ8863_WRITE_ADDRESS, buf, 2, HAL_MAX_DELAY);

HAL_I2C_Master_Receive(&hi2c1,KSZ8863_READ_ADDRESS, Data, 1, HAL_MAX_DELAY);

Thanks

2 REPLIES 2
KnarfB
Principal III

This is confusing because sometimes, a 7-bit address is published and sometimes an already shifted 8-bit address. Since 0xBE hat the MSB set, it must be already shifted. This conforms to the data sheet:

Two fixed 8-bit device addresses are used to address KSZ8863MLL/FLL/RLL in I2C Slave mode: one for read operation and the other for write operation. The addresses are as follows:

• 1011_1111 <read>

• 1011_1110 <write>

Pass 0xBE to the HAL functions. HAL will handle the LSB for read/write correctly.

One may also use HAL_I2C_IsDeviceReady to search the I2C bus for responding target devices.

hth

KnarfB

@KnarfB​ Thank you very much for the clarity.