1) Constructing a new I2C instance does not deinit the previous peripheral.
2) A soft reboot does not deinit the previous HW I2C.
Running latest MicroPython on the Ebyte E73-TBB dev board (E73-2G4M04S1B module)
MicroPython v1.13-221-gc8b055717 on 2020-12-05; E73-Demo with NRF52832
1) Constructing a new I2C instance does not deinit the previous peripheral.
* construct a HW I2C on the wrong pins
* scan() does not find an I2C sensor
* reconstruct on the right pins (pins seem to be ignored)
* scan() does not find an I2C sensor
Code: Select all
>>> from machine import Pin, I2C
>>> i2c = I2C(0, scl=Pin(4), sda=Pin(3)) # oops scl/sda backwards
>>> i2c.scan()
[] # as expected
>>> i2c = I2C(0, scl=Pin(3), sda=Pin(4)) # correct pins
>>> i2c.scan()
[] # was expecting [30]
# hard reset
>>> import machine
>>> machine.reset()
>>> from machine import Pin, I2C
>>> i2c = I2C(0, scl=Pin(3), sda=Pin(4)) # correct pins
>>> i2c.scan()
[30] # as expected
* scan() finds the sensor
* reconstruct on the wrong pins (pins seem to be ignored)
* scan() still finds the sensor (using previous config?)
Code: Select all
>>> from machine import Pin, I2C
>>> i2c = I2C(0, scl=Pin(3), sda=Pin(4)) # correct pins
>>> i2c.scan()
[30] # as expected
# reconstruct
>>> i2c = I2C(0, scl=Pin(4), sda=Pin(3)) # oops scl/sda backwards
>>> i2c.scan()
[30] # was expecting [] - it's using the previous configured pins (scl=3, sda=4)
* construct a HW I2C on the right pins
* scan() finds the sensor
* soft reset
* construct a HW I2C on the wrong pins (pins seem to be ignored)
* scan() still finds the sensor (using previous config?)
Code: Select all
>>> from machine import Pin, I2C
>>> i2c = I2C(0, scl=Pin(3), sda=Pin(4)) # correct pins
>>> i2c.scan()
[30] # as expected
CTRL+D
MPY: soft reboot
>>> from machine import Pin, I2C
>>> i2c = I2C(0, scl=Pin(4), sda=Pin(3)) # oops scl/sda backwards
>>> i2c.scan()
[30] # was expecting [] - it's using the pins defined before the reboot
* scan() does not find the sensor
* hard reset
* construct a HW I2C on the right pins
* scan() finds the sensor
Code: Select all
>>> from machine import Pin, I2C
>>> i2c = I2C(0, scl=Pin(4), sda=Pin(3)) # oops scl/sda backwards
>>> i2c.scan()
[] # as expected
# hard reset
>>> import machine
>>> machine.reset()
>>> from machine import Pin, I2C
>>> i2c = I2C(0, scl=Pin(3), sda=Pin(4)) # correct pins
>>> i2c.scan()
[30] # as expected - the hard reboot cleared the previous incorrect config