2018-12-14 05:35 AM
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.
2018-12-14 05:43 AM
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.
2018-12-14 05:51 AM
thank for your answer.
i converted the float into char bytes then i'm only sending the most significant three bytes.
2018-12-14 05:52 AM
thank for your answer.
i converted the float into char bytes then i'm only sending the most significant three bytes.
2018-12-14 05:54 AM
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.