cancel
Showing results for 
Search instead for 
Did you mean: 

while using I2C, there's any problem if one of the register has the same address than the device ?

ABoya.14
Associate II

Hello !

i'm using I2C communication between a Nucleo-STM32F401RE board and a camera in which there a PIC16F1847 MCU. the application is about to write three bytes in a register in order to make a focus adjustment

the thing is, the device address is 0x30 and the register address goes from 0x2F to 0x31.

unfortunately nothing is working but there's no any error like ACK failure ou something like this.

Note that the same software is used to write 2 bytes in another register which address goes from 0x00 to 0x01 and for this case everything work normally.

Do you think the problem for the first case stems from the address ?

thank you for your help.

PS1: You will find the code as an attachment.

PS2: I'm using HAL library.

4 REPLIES 4

Are you sure you must send just 3 bytes (beside the register byte)? Your comment mentions that you are writing a float value, floats are 4 bytes-long. Maybe the device expectes 5 bytes (1 byte register + 4 bytes float)?

To answer your question, no I2C addresses don't collide with the virtual register addresses.

ABoya.14
Associate II

thank for your answer.

i converted the float into char bytes then i'm only sending the most significant three bytes.

thank for your answer.

i converted the float into char bytes then i'm only sending the most significant three bytes.

A correctly coded slave device shouldn't mismatch on it's own address. I'm not sure auto-incrementing is mandatory, but highly typical, especially when dealing with memory or registers which combine for larger units. Watch endianess.

The ACK from the slave is the normal way of knowing it hasn't broken.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..