Hi,
I need to read out the Gyro Data of an LSM6DS3TC-R via I2C/TWI. The xiao nrf board uses an nrf52840 and has the gyro sensor build into it, so I don't have access to the pins with an oscilloscope. I know the connection as it is drawn in the schematic I attached is working, because with the original bootloader by xiao with their own i2c library it is working fine.
There is a little problem I want to point out first: The TWIM driver returns immediately with NRF_SUCCESS when starting a transfer with nrfx_twim_xfer() with the NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER flag enabled. I don't know if that is intended or not, but for me it seems more reasonable to not use the event handler with that flag set, even though during initialisation an event handler was specified.
Now the second problem: When trying to initialise the sensor by reading out the so called "WHO_AM_I" register, sometimes the TWIM driver hangs itself in the nrfx_twim_xfer() function because no event is being set, after the TXSTARTED event. When debugging after the program is stuck in that loop of event checks, lines 538, 544 and 551 of nrfx_twim.c file. I did not manage to reproduce that error in a certain way, sometimes it occurs, sometimes it doesn't and the sensor is working fine, with exactly the same code.
I already tried using the nrfx_twi driver instead or even the nrf_drv_twi but the results were similar. The twi_scanner example sometimes works and sometimes doesn't work, as it hangs itself in the same part of the code. I also tried manually resetting the i2c bus with the nrf_twim_twi_bus_recover function before initialising the twi driver, but that also doen't change anything. I also tried to clone the xiao "Wire_nRF52" lib from the original bootloader but even that resulted in the same problems.
The pins used internally for the Sensor are P0.07/SDA and P0.27/SCL and P0.07 is also used for TRACECLK, is that maybe the problem? Because the only difference there is anymore, is that the original bootloader uses no debugging via the J-Link, but has dfu enabled for the Arduino IDE.
The code I wrote is quite much by now, but if it helps, I could also post it.
I am using: Segger Embedded Studio v5.42a, nRF SDK 17.1.0, Softdevice S212 7.1.0 on an XIAO nRF52840 BLE Sense with a J-Link to flash via SWD.
I am thankful for every answer that could help... Thanks in advance!