2020-12-22 12:46 AM
Hello everybody!!)) I spent a few days already, try to decide this problem, this reason I decided to ask here.
I can write data to register by command HAL_I2C_Mem_Write, but can not read, because 8 register is low
uint8_t adress_read1 = 0x43;
uint8_t status = 0x1F;
uint8_t status_readed;
HAL_I2C_Mem_Read(&hi2c4, adress_read, status, 1, (int8_t*)&status_readed, 1, 10);
You can see it the photo
I try used differents types for variables, different times, different lengths for variables, different speeds for I2C but the result every rime same.
That interesting, with command HAL_I2C_Master_Receive - works without problem, but with this command, I can only read data and can not read registers. Where can be an error, please help me?
2020-12-22 06:54 AM
What does that bit represent? Why do you think it should be 1?
2020-12-22 10:42 PM
1 - for reading, 0 - for writing
2020-12-23 05:32 AM
The way HAL_I2C_Mem_Read works is it first writes the address of the register it wants to read, then it reads that data. Otherwise how would the chip know which address to send? There should be multiple byte transactions here and you're only showing one of them.
It should be more clear if you look at the datasheet of the device you're interfacing with. Here is a read transaction from a random I2C EEPROM datasheet I found, which shows the R/W bit changing values at different places in the transaction.
2020-12-23 05:40 AM
This is not the bit you identified. The Slave address goes into the High Order 7-bits, you don't need to manage the R/W bit at this level.
2020-12-24 12:09 AM
thank you so much, problem was decided
2020-12-29 08:45 AM
Hi @IRakh.1 ,
If the problem was resolved thanks to the last reply of TDK, please select it as a "Best Answer" so that this request is marked as resolved.
-Amel
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.
2020-12-29 09:17 AM
This Best Answer metric is broken and self-serving. Most places where this works effectively is where the OP states what the remedy turns out to be, and peers vote on which response best identified the cause. Users should not be able to up-vote their own questions, and responses.