Hi,
I have an issue with Arduino SDK I2C library and its reading capability. If I call the Wire.requestFrom(โฆ) function correctly, it is executed without error, but the message datagram requesting byte/bytes does not appear on logic analyzer. The calling of the write function works as expected and logic analyser shows nice write-flagged datagram too. Details are described in GitHub issue below. After I created the issue, I tested it on older Arduino SDKs, but It was the same or it does not work at all on the oldest one.
I created issue on the github, without any reaction. Other issues there are mostly without reaction too and automatically closed because of no activity. This is bug I most probably canโt fix myself without knowledge of the hardware registers and their function. Sadly, I have no I2C device with read write capability to create small usable sample. But It should be easily replicable on other device too. I did not done anything special.
opened 10:29PM - 25 Nov 24 UTC
pending
### Boards
AMB82-mini
### External Hardware
Saleae Logic8 attached to pโฆ in 12, pin 13 (I2C).
### Hardware Configuration
satel-vl53l7cx modified to bypass onboard regulator, so SB1 short and SB2 open, then AVDD=IOVDD (sensor pin - AMB82-mini pin):
- SDA - pin 12
- SCL - pin 13
- GND - GND
- IOVDD - VDD33
(Note: fully functional and tested with a few STM32 boards, ESP32, and similar)
### Version
v4.0.8
### IDE Name
Arduino IDE 2.3.3
### Operating System
WIndows 10, Windows 11, Ubuntu 22.04
### Auto Flash Mode
Disable
### Erase All Flash Memory (16MB)
Disable
### Standard Lib
Arduino_STD_PRINTF
### Upload Speed
2000000
### Description
When I checked If sensor initializes properly, I found, that I2C Write is OK but I2C Read writes only the address but never start read. The read part is totally missing. I do not have other I2C readable sensors that have simple code. So I will not provide code sample to reproduce, but it should be any read attempt.
![image](https://github.com/user-attachments/assets/8aea8a2b-f59f-4b70-8130-4726fcfa0438)
### Sketch
```cpp
//code of functions I will use:
typedef struct
{
TwoWire *port; //== &Wire
uint16_t address; //== 0x52
} VL53L7CX_Platform;
uint8_t VL53L7CX_RdByte(
VL53L7CX_Platform *p_platform,
uint16_t register_address,
uint8_t *p_value)
{
uint8_t status = 0;
p_platform->port->beginTransmission(p_platform->address>>1);
p_platform->port->write(highByte(register_address));
p_platform->port->write(lowByte(register_address));
p_platform->port->endTransmission();
p_platform->port->requestFrom(p_platform->address>>1, 1U);
*p_value = p_platform->port->read();
return status;
}
uint8_t VL53L7CX_WrByte(
VL53L7CX_Platform *p_platform,
uint16_t register_address,
uint8_t value)
{
uint8_t status = 0;
p_platform->port->beginTransmission(p_platform->address>>1);
p_platform->port->write(highByte(register_address));
p_platform->port->write(lowByte(register_address));
p_platform->port->write(value);
status = p_platform->port->endTransmission();
return status;
}
//Initialization send these messages:
...
/* SW reboot sequence */
status |= VL53L7CX_WrByte(&(p_dev->platform), 0x7fff, 0x00);
status |= VL53L7CX_WrByte(&(p_dev->platform), 0x0009, 0x04);
status |= VL53L7CX_WrByte(&(p_dev->platform), 0x000F, 0x40);
status |= VL53L7CX_WrByte(&(p_dev->platform), 0x000A, 0x03);
status |= VL53L7CX_RdByte(&(p_dev->platform), 0x7FFF, &tmp);
status |= VL53L7CX_WrByte(&(p_dev->platform), 0x000C, 0x01);
...
//As seen on the logic analyzator image, there is Write(index,data) [ADDR(W), 0x00, 0x01, 0x03],
//then Write(index)/Read(data) [ADDR(W), 0x7F, 0xFF] but missing Read(data) part which should be
//[ADDR+1(R), DATA]. It continues with another Write(index, data) [ADDR, 0x00, 0x0C, 0x01].
//There is expected missing Read part where data is received from slave buffer.
```
### Error/Debug Message
```plain
== Rtl8735b IoT Platform ==
[Normal mode]
BootFromNORFlash
[Start Boot ROM...]
=== Load PARTBL ===
=== Load Done ===
=== Load ISP_IQ ===
[fcs chk pass]
ISP_IQ @ 0x8461080, 0x14f80, 0x0
mfcs_data version 0x00010001
fcs_data version 0x00010101
=== Process ISP_IQ ===
=== Load Done ===
=== Load BL ===
[Image Start Table @ 0x18200]
=== Load Done ===
== Boot Loader ==
Oct 24 2024:17:41:10
=== Load FCS Para ===
=== Load Done ===
[crc pass]
=== Load ISP_IQ Sensor ===
ISP_IQ @ 0x8461080, 0x14f80
=== Process ISP_IQ ===
=== Load Done ===
=== Load FW1 ===
[Image Start Table @ 0x20106200]
RAM Load @ 0x8061100->0x20106200, 0x5d48
DRAM_TYPE is DDR2 128MB.
ddr_freq = 533
DDR Load @ 0x8067080->0x70100000, 0x2c704
=== FW Load Done ===
Boot Loader <==
== RAM Start ==
Build @ 17:32:16, Oct 24 2024
$8735b>
Lidar Setup Start
```
### Reproduce remarks
_No response_
### I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.
- [X] I confirm I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.
Best regards,
electry
Hi @electry ,
Can you try adding a delay directly after the API call of requestFrom?
Try delay(1);
Thank you.