Skip to content

I2C hangs when power removed from bus on nrf52840 #8093

@furbrain

Description

@furbrain

CircuitPython version

8.1.0-beta.1-44
(Running on a Seeed XIAO nrf52840 Sense)

Code/REPL

import board
import busio
import time
from adafruit_lsm6ds.lsm6ds3 import LSM6DS3
import digitalio

# board.IMU_PWR provides the power to both the LSM6DS3 chip and also the pullups to the I2C bus
pwr = digitalio.DigitalInOut(board.IMU_PWR)
pwr.switch_to_output(True)
print("Starting")
time.sleep(5)
print("Connecting to IMU")
with busio.I2C(scl=board.IMU_SCL, sda=board.IMU_SDA) as i2c_bus:
    imu = LSM6DS3(i2c_bus, address=0x6A)
    print("This works")
    print(imu.acceleration)
    time.sleep(1)
    pwr.switch_to_output(False)
    print("This crashes")
    print(imu.acceleration)
    print("We don't get here")

Behavior

The code above gets as far as the second print(imu.acceleration) and then the device hangs and can only be recovered by a manual reset.

Description

No response

Additional information

Debugging with STLINK-V2 identifies that the call to nrfx_twim_xfer in common_hal_busio_i2c_write is where the device hangs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions