i2c error recovery

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
shaoziyang
Posts: 278
Joined: Sun Apr 17, 2016 1:55 pm

i2c error recovery

Post by shaoziyang » Mon Jul 08, 2019 7:32 am

I using a i2c sensor in pyboard, and occasionally hardware i2c will timeout. When this happens, i2c will not read sensor anymore, and it can't recover automatic unless reset. If I using software i2c, it will recovery.

Does anyone konw how to recovery hardware i2c when it occur errors?

User avatar
jimmo
Posts: 791
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: i2c error recovery

Post by jimmo » Tue Jul 09, 2019 12:56 am

Out of curiosity, what happens if you re-initialise the I2C? (e.g. by calling .init())

I notice that in the STM32 port that doing this will explicitly reset the I2C peripheral.

shaoziyang
Posts: 278
Joined: Sun Apr 17, 2016 1:55 pm

Re: i2c error recovery

Post by shaoziyang » Tue Jul 09, 2019 2:31 am

re-init I2C has no effect,

Jonwalter
Posts: 9
Joined: Mon Apr 09, 2018 12:41 pm
Contact:

Re: i2c error recovery

Post by Jonwalter » Wed Sep 25, 2019 8:25 am

My general startup/recovery procedure is to set the I2C as I/O lines and send out clock pulses while checking the data line. I wait for ten consecutive ones with no intervening zeroes before I switch (back) to the MSSP.

Post Reply