V851S I2C/TWI 损坏(xfer 错误)
-
大家好,
我的 V851S (tina-linux) 上的 i2c/twi 总线似乎有问题,每次我尝试使用 i2cdump 或 i2cDetect 等 shell i2C 实用程序时,我都会收到以下错误 (i2cget 和 i2cwrite 也会发生这种情况):root@TinaLinux:/sys/devices/platform/soc/pio/gpiochip0/gpio/gpio8# i2cdetect 1 [ 786.358195] i2c i2c-1: ioctl, cmd=0x705, arg=0xbea72c6c i2cdetect: WARNING! This program can confuse your I2C bus Continue? [y/N] y 0 1 2 3 4 5 6 7 8 [ 789.513384] i2c i2c-1: ioctl, cmd=0x703, arg=0x03 9 a b c d e f 00: [ 789.521510] i2c i2c-1: ioctl, cmd=0x720, arg=0xbea72c4c [ 789.530134] i2c i2c-1: master_xfer[0] W, addr=0x03, len=0 [ 789.536525] twi_start()508 - [i2c1] START can't sendout! [ 789.542553] sunxi_i2c_do_xfer()1951 - [i2c1] twi_regulator: [ 789.549191] twi_start()508 - [i2c1] START can't sendout! [ 789.555137] sunxi_i2c_do_xfer()1951 - [i2c1] twi_regulator: [ 789.561763] twi_start()508 - [i2c1] START can't sendout! [ 789.567722] sunxi_i2c_do_xfer()1951 - [i2c1] twi_regulator: -- [ 789.574219] i2c i2c-1: ioctl, cmd=0x703, arg=0x04 [ 789.579759] i2c i2c-1: ioctl, cmd=0x720, arg=0xbea72c4c [ 789.585615] i2c i2c-1: master_xfer[0] W, addr=0x04, len=0 [ 789.591919] twi_start()508 - [i2c1] START can't sendout! [ 789.597882] sunxi_i2c_do_xfer()1951 - [i2c1] twi_regulator: [ 789.604494] twi_start()508 - [i2c1] START can't sendout! [ 789.610452] sunxi_i2c_do_xfer()1951 - [i2c1] twi_regulator: [ 789.617068] twi_start()508 - [i2c1] START can't sendout! [ 789.623016] sunxi_i2c_do_xfer()1951 - [i2c1] twi_regulator: -- [ 789.629512] i2c i2c-1: ioctl, cmd=0x703, arg=0x05 [ 789.635030] i2c i2c-1: ioctl, cmd=0x720, arg=0xbea72c4c [ 789.640964] i2c i2c-1: master_xfer[0] W, addr=0x05, len=0 [ 789.647206] twi_start()508 - [i2c1] START can't sendout! [ 789.653155] sunxi_i2c_do_xfer()1951 - [i2c1] twi_regulator: [ 789.659783] twi_start()508 - [i2c1] START can't sendout! [ 789.665728] sunxi_i2c_do_xfer()1951 - [i2c1] twi_regulator: [ 789.672352] twi_start()508 - [i2c1] START can't sendout! [ 789.678309] sunxi_i2c_do_xfer()1951 - [i2c1] twi_regulator:
这是我的 I2C 内核配置:
和我的 i2c“menuconfig”:
我知道至少已经有一篇关于此问题的帖子,但这只是一条警告消息,在我的情况下,它无法正常工作,因为我在 I2C 1 的地址 0x36 上有一个未检测到的设备。我怎样才能摆脱这些错误?
我的 twi DTS 配置如下:
twi0_pins_a: twi0@0 { allwinner,pins = "PA16", "PA17"; allwinner,pname = "twi0_scl", "twi0_sda"; allwinner,function = "twi0"; allwinner,muxsel = <4>; allwinner,drive = <0>; allwinner,pull = <1>; }; twi0_pins_b: twi0@1 { allwinner,pins = "PA16", "PA17"; allwinner,function = "io_disabled"; allwinner,muxsel = <0xf>; allwinner,drive = <0>; allwinner,pull = <0>; }; twi1_pins_a: twi1@0 { allwinner,pins = "PA6", "PA7"; allwinner,pname = "twi1_scl", "twi1_sda"; allwinner,function = "twi1"; allwinner,muxsel = <4>; allwinner,drive = <0>; allwinner,pull = <1>; }; twi1_pins_b: twi1@1 { allwinner,pins = "PA6", "PA7"; allwinner,function = "io_disabled"; allwinner,muxsel = <0xf>; allwinner,drive = <0>; allwinner,pull = <0>; }; twi2_pins_a: twi2@0 { allwinner,pins = "PH11", "PH12"; allwinner,pname = "twi2_scl", "twi2_sda"; allwinner,function = "twi2"; allwinner,muxsel = <5>; allwinner,drive = <0>; allwinner,pull = <1>; }; twi2_pins_b: twi2@1 { allwinner,pins = "PH11", "PH12"; allwinner,function = "io_disabled"; allwinner,muxsel = <0xf>; allwinner,drive = <0>; allwinner,pull = <0>; }; twi3_pins_a: twi3@0 { allwinner,pins = "PI3", "PI4"; allwinner,pname = "twi3_scl", "twi3_sda"; allwinner,function = "twi6"; allwinner,muxsel = <6>; allwinner,drive = <0>; allwinner,pull = <1>; }; twi3_pins_b: twi3@1 { allwinner,pins = "PI3", "PI4"; allwinner,function = "io_disabled";//io_disabled allwinner,muxsel = <0xf>; allwinner,drive = <0>; allwinner,pull = <0>; }; twi4_pins_a: twi4@0 { allwinner,pins = "PI1", "PI2"; allwinner,pname = "twi4_scl", "twi4_sda"; allwinner,function = "twi4"; allwinner,muxsel = <5>; allwinner,drive = <0>; allwinner,pull = <1>; }; twi4_pins_b: twi4@1 { allwinner,pins = "PI1", "PI2"; allwinner,function = "io_disabled"; allwinner,muxsel = <0xf>; allwinner,drive = <0>; allwinner,pull = <0>; };
-
twi的配置是怎样的
-
我似乎忘记了i2c上拉电阻(每个人都会遇到哈哈),现在调节器问题消失了,但通信似乎仍然失败:
[ 102.176976] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.184713] i2c i2c-1: master_xfer[0] W, addr=0x60, len=0 [ 102.190934] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x60) (sunxi_i2c_do_xfer) [ 102.202379] i2c i2c-1: ioctl, cmd=0x703, arg=0x61 [ 102.207685] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.213540] i2c i2c-1: master_xfer[0] W, addr=0x61, len=0 [ 102.219770] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x61) (sunxi_i2c_do_xfer) [ 102.231144] i2c i2c-1: ioctl, cmd=0x703, arg=0x62 [ 102.236440] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.242295] i2c i2c-1: master_xfer[0] W, addr=0x62, len=0 [ 102.248581] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x62) (sunxi_i2c_do_xfer) [ 102.259960] i2c i2c-1: ioctl, cmd=0x703, arg=0x63 [ 102.265237] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.271113] i2c i2c-1: master_xfer[0] W, addr=0x63, len=0 [ 102.277333] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x63) (sunxi_i2c_do_xfer) [ 102.288706] i2c i2c-1: ioctl, cmd=0x703, arg=0x64 [ 102.293981] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.299908] i2c i2c-1: master_xfer[0] W, addr=0x64, len=0 [ 102.306117] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x64) (sunxi_i2c_do_xfer) [ 102.317489] i2c i2c-1: ioctl, cmd=0x703, arg=0x65 [ 102.322766] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.328642] i2c i2c-1: master_xfer[0] W, addr=0x65, len=0 [ 102.334848] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x65) (sunxi_i2c_do_xfer) [ 102.346263] i2c i2c-1: ioctl, cmd=0x703, arg=0x66 [ 102.351544] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.357425] i2c i2c-1: master_xfer[0] W, addr=0x66, len=0 [ 102.363631] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x66) (sunxi_i2c_do_xfer) [ 102.374999] i2c i2c-1: ioctl, cmd=0x703, arg=0x67 [ 102.380296] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.386161] i2c i2c-1: master_xfer[0] W, addr=0x67, len=0 [ 102.392361] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x67) (sunxi_i2c_do_xfer) [ 102.403786] i2c i2c-1: ioctl, cmd=0x703, arg=0x68 [ 102.409092] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.414946] i2c i2c-1: master_xfer[0] W, addr=0x68, len=0 [ 102.421170] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x68) (sunxi_i2c_do_xfer) [ 102.432538] i2c i2c-1: ioctl, cmd=0x703, arg=0x69 [ 102.437837] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.443692] i2c i2c-1: master_xfer[0] W, addr=0x69, len=0 [ 102.449969] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x69) (sunxi_i2c_do_xfer) [ 102.461344] i2c i2c-1: ioctl, cmd=0x703, arg=0x6a [ 102.466640] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.472498] i2c i2c-1: master_xfer[0] W, addr=0x6a, len=0 [ 102.478726] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x6a) (sunxi_i2c_do_xfer) [ 102.490089] i2c i2c-1: ioctl, cmd=0x703, arg=0x6b [ 102.495363] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.501290] i2c i2c-1: master_xfer[0] W, addr=0x6b, len=0 [ 102.507517] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x6b) (sunxi_i2c_do_xfer) [ 102.518889] i2c i2c-1: ioctl, cmd=0x703, arg=0x6c [ 102.524165] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.530041] i2c i2c-1: master_xfer[0] W, addr=0x6c, len=0 [ 102.536259] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x6c) (sunxi_i2c_do_xfer) [ 102.547670] i2c i2c-1: ioctl, cmd=0x703, arg=0x6d [ 102.552946] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.558825] i2c i2c-1: master_xfer[0] W, addr=0x6d, len=0 [ 102.565029] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x6d) (sunxi_i2c_do_xfer) [ 102.576442] i2c i2c-1: ioctl, cmd=0x703, arg=0x6e [ 102.581722] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.587602] i2c i2c-1: master_xfer[0] W, addr=0x6e, len=0 [ 102.593808] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x6e) (sunxi_i2c_do_xfer) [ 102.605227] i2c i2c-1: ioctl, cmd=0x703, arg=0x6f [ 102.610530] i2c i2c-1: ioctl, cmd=0x720, arg=0xbeef1c7c [ 102.616399] i2c i2c-1: master_xfer[0] W, addr=0x6f, len=0 [ 102.622606] sunxi_i2c_do_xfer()1974 - [i2c1] incomplete xfer (status: 0x20, dev addr: 0x6f) (sunxi_i2c_do_xfer) 60: -- -- -- -- -- -- -- -- -- -[ 102.634085] i2c i2c-1: ioctl, cmd=0x703, arg=0x70 - -- -- -- -- -- --
0x6C 处应该有一个有效的设备。 从我的示波器中,我清楚地看到该设备正在接收 SCL 和 SDA 信号,但没有读回任何内容......
-
事实证明我缺少这些线路的上拉电阻。 现在它们不再出现“调节器”错误,而是所有地址都超时。 我现在有一个 MPU6050 连接到总线进行测试,这是扫描日志,您可以看到它什么也没发现。 mpu6050的地址应该是0x68或0x69,两者都很清楚:
root@TinaLinux:/# i2cdetect 1 -y [ 26.316647] i2c i2c-1: ioctl, cmd=0x705, arg=0xbebcac8c 0 1 2 3 4 5 6 7 8 [ 26.322650] i2c i2c-1: ioctl, cmd=0x703, arg=0x03 9 a b c d e f 00: [ 26.330781] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 26.339311] i2c i2c-1: master_xfer[0] W, addr=0x03, len=0 [ 31.366572] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x3) -- [ 31.374170] i2c i2c-1: ioctl, cmd=0x703, arg=0x04 [ 31.379777] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 31.385639] i2c i2c-1: master_xfer[0] W, addr=0x04, len=0 ... // 为简洁起见而删减 60: [ 495.059785] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 495.066137] i2c i2c-1: master_xfer[0] W, addr=0x60, len=0 [ 500.086565] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x60) -- [ 500.094231] i2c i2c-1: ioctl, cmd=0x703, arg=0x61 [ 500.099774] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 500.105629] i2c i2c-1: master_xfer[0] W, addr=0x61, len=0 [ 505.126562] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x61) -- [ 505.134222] i2c i2c-1: ioctl, cmd=0x703, arg=0x62 [ 505.139767] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 505.145622] i2c i2c-1: master_xfer[0] W, addr=0x62, len=0 [ 510.166586] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x62) -- [ 510.174251] i2c i2c-1: ioctl, cmd=0x703, arg=0x63 [ 510.179792] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 510.185648] i2c i2c-1: master_xfer[0] W, addr=0x63, len=0 [ 515.206563] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x63) -- [ 515.214226] i2c i2c-1: ioctl, cmd=0x703, arg=0x64 [ 515.219819] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 515.225678] i2c i2c-1: master_xfer[0] W, addr=0x64, len=0 [ 520.246561] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x64) -- [ 520.254226] i2c i2c-1: ioctl, cmd=0x703, arg=0x65 [ 520.259765] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 520.265622] i2c i2c-1: master_xfer[0] W, addr=0x65, len=0 [ 525.286562] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x65) -- [ 525.294226] i2c i2c-1: ioctl, cmd=0x703, arg=0x66 [ 525.299767] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 525.305622] i2c i2c-1: master_xfer[0] W, addr=0x66, len=0 [ 530.326561] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x66) -- [ 530.334223] i2c i2c-1: ioctl, cmd=0x703, arg=0x67 [ 530.339766] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 530.345623] i2c i2c-1: master_xfer[0] W, addr=0x67, len=0 [ 535.366587] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x67) -- [ 535.374251] i2c i2c-1: ioctl, cmd=0x703, arg=0x68 [ 535.379799] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 535.385655] i2c i2c-1: master_xfer[0] W, addr=0x68, len=0 [ 540.406582] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x68) -- [ 540.414247] i2c i2c-1: ioctl, cmd=0x703, arg=0x69 [ 540.419837] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 540.425696] i2c i2c-1: master_xfer[0] W, addr=0x69, len=0 [ 545.446563] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x69) -- [ 545.454231] i2c i2c-1: ioctl, cmd=0x703, arg=0x6a [ 545.459774] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 545.465630] i2c i2c-1: master_xfer[0] W, addr=0x6a, len=0 [ 550.486562] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x6a) -- [ 550.494228] i2c i2c-1: ioctl, cmd=0x703, arg=0x6b [ 550.499769] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 550.505625] i2c i2c-1: master_xfer[0] W, addr=0x6b, len=0 [ 555.526561] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x6b) -- [ 555.534225] i2c i2c-1: ioctl, cmd=0x703, arg=0x6c [ 555.539771] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 555.545628] i2c i2c-1: master_xfer[0] W, addr=0x6c, len=0 [ 560.566588] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x6c) -- [ 560.574248] i2c i2c-1: ioctl, cmd=0x703, arg=0x6d [ 560.579791] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 560.585647] i2c i2c-1: master_xfer[0] W, addr=0x6d, len=0 [ 565.606563] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x6d) -- [ 565.614225] i2c i2c-1: ioctl, cmd=0x703, arg=0x6e [ 565.619817] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 565.625675] i2c i2c-1: master_xfer[0] W, addr=0x6e, len=0 [ 570.646562] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x6e) -- [ 570.654224] i2c i2c-1: ioctl, cmd=0x703, arg=0x6f [ 570.659766] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 570.665623] i2c i2c-1: master_xfer[0] W, addr=0x6f, len=0 [ 575.686561] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x6f) -- [ 575.694255] i2c i2c-1: ioctl, cmd=0x703, arg=0x70 70: [ 575.699777] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 575.706129] i2c i2c-1: master_xfer[0] W, addr=0x70, len=0 [ 580.726587] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x70) -- [ 580.734251] i2c i2c-1: ioctl, cmd=0x703, arg=0x71 [ 580.739800] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 580.745655] i2c i2c-1: master_xfer[0] W, addr=0x71, len=0 [ 585.766565] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x71) -- [ 585.774229] i2c i2c-1: ioctl, cmd=0x703, arg=0x72 [ 585.779823] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 585.785682] i2c i2c-1: master_xfer[0] W, addr=0x72, len=0 [ 590.806562] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x72) -- [ 590.814226] i2c i2c-1: ioctl, cmd=0x703, arg=0x73 [ 590.819771] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 590.825626] i2c i2c-1: master_xfer[0] W, addr=0x73, len=0 [ 595.846562] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x73) -- [ 595.854226] i2c i2c-1: ioctl, cmd=0x703, arg=0x74 [ 595.859773] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 595.865630] i2c i2c-1: master_xfer[0] W, addr=0x74, len=0 [ 600.886561] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x74) -- [ 600.894216] i2c i2c-1: ioctl, cmd=0x703, arg=0x75 [ 600.899762] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 600.905618] i2c i2c-1: master_xfer[0] W, addr=0x75, len=0 [ 605.926601] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x75) -- [ 605.934261] i2c i2c-1: ioctl, cmd=0x703, arg=0x76 [ 605.939803] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 605.945659] i2c i2c-1: master_xfer[0] W, addr=0x76, len=0 [ 610.966564] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x76) -- [ 610.974220] i2c i2c-1: ioctl, cmd=0x703, arg=0x77 [ 610.979815] i2c i2c-1: ioctl, cmd=0x720, arg=0xbebcac6c [ 610.985675] i2c i2c-1: master_xfer[0] W, addr=0x77, len=0 [ 616.006564] sunxi_i2c_do_xfer()1967 - [i2c1] xfer timeout (dev addr:0x77)
所以这里还是有些不对劲...
-
@yuzukitsuru 这是我的 TWI 配置:
&twi0 { clock-frequency = <400000>; pinctrl-0 = <&twi0_pins_a>; pinctrl-1 = <&twi0_pins_b>; pinctrl-names = "default", "sleep"; /* For stability and backwards compatibility, we recommend setting ‘twi_drv_used’ to 0 */ twi_drv_used = <0>; twi_pkt_interval = <0>; status = "okay"; }; &twi1 { clock-frequency = <400000>; pinctrl-0 = <&twi1_pins_a>; pinctrl-1 = <&twi1_pins_b>; pinctrl-names = "default", "sleep"; /* For stability and backwards compatibility, we recommend setting ‘twi_drv_used’ to 0 */ twi_drv_used = <0>; twi_pkt_interval = <0>; status = "okay"; }; &twi2 { clock-frequency = <400000>; pinctrl-0 = <&twi2_pins_a>; pinctrl-1 = <&twi2_pins_b>; pinctrl-names = "default", "sleep"; /* For stability and backwards compatibility, we recommend setting ‘twi_drv_used’ to 0 */ twi_drv_used = <0>; twi_pkt_interval = <0>; status = "okay"; }; &twi3 { clock-frequency = <400000>; pinctrl-0 = <&twi3_pins_a>; pinctrl-1 = <&twi3_pins_b>; pinctrl-names = "default", "sleep"; /* For stability and backwards compatibility, we recommend setting ‘twi_drv_used’ to 0 */ twi_drv_used = <0>; twi_pkt_interval = <0>; status = "disabled"; };
但 I2C 总线通常表现得很奇怪,如果我在总线上不放置任何东西,我会得到看起来很糟糕的信号(上升和下降时间长,并且它给我“xfer 不完整”错误),但是如果我在总线上放置一个设备 I2C 总线根本没有发送任何内容(并且我收到 xfer 超时错误)!
考虑到测量的时钟速度,它显然试图在 400khz 下工作,但这个信号看起来仍然很糟糕。 我想知道这是否与 DTS 中的驱动强度设置有关。 -
dmesg -n 1 再运行测试命令
-
@awwwwa 这确实消除了警告,所以感谢这一点,但是 i2cdetect 的结果仍然完全错过了总线上的任何 I2C 设备...所以根本问题仍然存在...
-
我让它工作了!
我必须编辑 DTS 将驱动强度增加到 1,并将 1.8V 总线电压从 1.7V 提高到 2V 才能注册,现在我的相机出现了!
默认的 0 驱动强度永远不会起作用。 编辑 DTS 是关键。
-
66666666
-
@kanken6174 事实上i2c通讯速率不高,但对“沿”的要求非常高,需小于130ns,因此一定程度上可以看做高速信号处理,由于其控制器均为开漏输出,所以上拉电阻与线路寄生电容决定了沿的延迟。此处可以不必提高电压,选择减小上拉电阻是正确的办法。提高驱动能力是变相的减少了上拉电阻阻值。
-
@whycanservice2 我已经将上拉电阻降低到2.5K,但当时仍然不起作用,我想我会尝试1K,看看是否可以降低上拉电压,同时仍然具有I2C功能。
-
@kanken6174 上拉是1.8V吗,还是上拉到3.3v了
-
@kanken6174 我记得在某个摄像头的硬件设计手册中看到过I2C 的上拉电阻典型2.2K.。。
-
@awwwwa 它在端口 A 上,端口 A 仅是 1.8V 逻辑,因此上拉电阻拉至 1.8V。 我确实在某个时候尝试过上拉至 3.3V,但当拉至 1.8V 时却没有任何效果。
-
@kanken6174 在 V851S I2C/TWI 损坏(xfer 错误) 中说:
。
您的波形图上不清楚信号的接地电平在哪里。 无论如何,最后一颗黄色“牙齿”的“低”电平高于其余的电平 冲动。 也就是说,控制器输出“下拉”的强度不够。全志GPIO有一个设置最大输出电流的寄存器:Px_DRVn。 我不知道当选择TWI功能时这个设置是否有效。 尝试在用户空间中通过 mmap 将寄存器地址简单地映射到内存进行试验。
关于上拉电阻。 我在 Omnivision 传感器的文档中没有找到它,但对于 AR0330 传感器,建议值为 1.5 Kom。
我的 A20 和 V3S MCU 上具有此上拉电阻的所有设备都可以与使用的所有传感器配合使用,在 TWI 上没有出现故障。 3.3V 和 1.8V。 -
@alb702 这个问题已经解决了,我只需要使用足够低的上拉电阻,并将DTS中I2C引脚的驱动强度设置为1,就可以正常工作了。 我的主要问题是驱动强度设置
-
@kanken6174 不建议修改引脚驱动能力,因为i2c协议要求总线为弱上拉,提高IO驱动能力会使之变成强上拉
当VCC为1.8V时,上拉电阻应选用2K
当VCC为3.3V时,上拉电阻应选用4.7K若无法正常使用,应排查走线质量与信号干扰。
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号