2021-04-11 08:41 AM
I am trying to use an STM32-p405 to communicate with another device via I2C. The device has a number of potential addresses so I am sending commands to all of them to see which respond back. It wasn't working, and then I discovered none of the odd numbered addresses were being called.
2021-04-11 09:05 AM
What do you mean by address?
In the I2C realm, there is a longstanding confusion between the 7-bit address, as defined by the I2C standard, and the 8-bit byte, which is transmitted, which, next to the address, includes the Read/Write bit as its LSB. And that, for Write, is zero.
JW
2021-04-11 09:17 AM
The slave device has a data sheet with a list of addresses. One of those is 0x21. When I pass 0x21 into HAL_I2C_Master_Transmit what I pick up on the logic analyzer between my stm32 and the device is a request to transmit to 0x20 and no response. When I shift 0x21 left and pass 0x42 into HAL_I2C_Master_Transmit I pick up a request to transmit to 0x42 and no response.
2021-04-11 10:06 AM
> The slave device has a data sheet with a list of addresses.
Post link.
> what I pick up on the logic analyzer between my stm32 and the device
Show.
JW
2021-04-12 01:33 PM
Device's table of addresses:
Attempt to send to address 0x42:
Attempt to send to address 0x21:
Attempt to send to address 0x20:
2021-04-12 02:28 PM
> Device's table of addresses:
It says that these are 7-bit addresses and the doxygen header to HAL_I2C_Master_Transmit says that 7-bit addresses have to be left-shifted, so you have to use 0x21<<1 as parameter, which your LA incorrectly displays as 0x42 (many LA do so).
However, that table does not indicate that you have a *range* of addresses available from which you can pick one at will. Rather, it indicates that the device has one unique address, determined at its manufacturing time.
JW
2021-05-09 11:21 AM
For the sake of thread resolution and anyone with similar issues: It turns out the address I needed to send to was 0x20 or 0100000 in 7bit binary. However this needed to be left shifted to 1000000 for the STM32 to send out. After that it worked. Thanks JW!