I2C failure rate - Raspberry Pi Forums


i have setup raspberry pi 3 , intelligent battery pack. bq40z60 chip of battery pack hooked rpi 3 using i2c.

1 can query current capacity of battery reading register 0x0d @ device 0x0b. unfortunately, failure rate of i2c read operation gets high rp3 becomes busy (running other program, switching windows etc.).

after observing i2c bus own home built logic recorder , i2c sniffer using arduino mega, can see read operations fail under these circumstances.

have written small shell script using i2cget , small c program using wiringpi. both show errors if rpi becomes busy.

shell script:

code: select all

#!/bin/bash echo "starting i2c test" until false   i2cget -y 1 0x0b 0x0d w   sleep 3 done 
c program:

code: select all

#include <stdio.h> #include <unistd.h> #include <wiringpii2c.h>  int main(int argc, char **argv) { 	int i2c_handle = wiringpii2csetup(0x0b); 	printf("handle = %d\n", i2c_handle); 	 	while (1) { 		sleep(3); 		int res = wiringpii2creadreg16(i2c_handle, 0x0d); 		printf("res = %d\n", res); 	} 	return 0; } 
sniffing on i2c bus between 2 devices shows:
@ second half. lines containing 17* failures. corresponding actual transitions of 2 bits of bus shown in first half of printout:

code: select all

i2c sniffer rricharz  acquiring data raw transitions, number of transitions = 1764 each number represents status, bit 1 = sda, bit 0 = clk, start condition = 31 3101010123012323012010101010123230123201 3101010123012323232010201023201023201010101012010101010101010102301 310101012301232301201010101012323012320101010123012323232301 3101010123012323012010101010123230123201 3101010123012323232010201023201023201010101012010101010101010102301 3101010123012323012010101010123230123201 310101012301232323201020102320102320101010101201010101010101010230 3101010123012323012010101010123230123201 3101010123012323232010201023201023201010101012010101010101010102301 310101012301232301201010101012323012320101 31010101230123232320102010232010232010101023012010101010101010102301 3101010123012323012010101010123230123201 3101010123012323232010201023201032010101023012010101010101010102301 31010101230123230120101010101232301232001 31010101230123232320102010232010232010101023012010101010101010102301 310101012301232301201010101012323012320101010123012323232301 310101012301232301201010101012323012320101010123012323232301 310101012301232301201010101012323012320101010123012323232301 3101010123012323012010101010123230123201 31010101230123232320102010232010232010101023012010101010101010102301 3101010123012323012010101010123230123201 31010101230123232320102010232010232010101023012010101010101010102301 310101012301232301201010101012323012320101010123012323232301 3101010123012323012010101010123230123201 31010101230123232320102010232010232010101023012010101010101010102301 3101010123012323012010101010123230123201 31010101230123232320102010232010232010101023012010101010101010102301 3101010123012323012010101010123230123201 31010101230123232320102010232010232010101023012010101010101010102301 310101012301232301201010101012323012320101010123012323232301 3101010123012323012010101010123230123201 3101010123012323232010201023201023201010102301201010101010101010230 3 analyzing data, number of transitions = 1764 i2c bus activity: (* means acqnowledge = 1) dev=0b w data=0d  dev=0b r data=50 00* dev=0b w data=0d 17* dev=0b w data=0d  dev=0b r data=50 00* dev=0b w data=0d  dev=0b r data=50 00* dev=0b w data=0d  dev=0b r data=50 00* dev=0b w data=0d  dev=0b r data=51 00* dev=0b w data=0d  dev=0b r data=51 00* dev=0b w data=0d  dev=0b r data=51 00* dev=0b w data=0d 17* dev=0b w data=0d 17* dev=0b w data=0d 17* dev=0b w data=0d  dev=0b r data=51 00* dev=0b w data=0d  dev=0b r data=51 00* dev=0b w data=0d 17* dev=0b w data=0d  dev=0b r data=51 00* dev=0b w data=0d  dev=0b r data=51 00* dev=0b w data=0d  dev=0b r data=51 00* dev=0b w data=0d 17* dev=0b w data=0d  dev=0b r data=51 00* 
idea on how proceed here appreciated.

i have not noticed similar problems, neither can remember other such posts.

i2c bus speed using?

sort of cpu/network usage reported top?


raspberrypi



Comments