7 Replies Latest reply on Feb 2, 2015 2:38 PM by Jacen

    Help I2C dosen't work with accelerometer ADXL345

    Jacen

      Hi ,

      I got an accelerometer ADXL345 from sparkfun. I want to use i2c to communication.

      I checked almost all posts in this forum, but i  still can't handle my i2c.

      Here is what i did:


      There are three types board available for me  Arduino Uno, Edison with Arduino and Edison with Mini breakout.

      Here is the code I used "i2cdevlib/Arduino/ADXL345 at master · jrowberg/i2cdevlib · GitHub"


      1. This code runs without problem on Arduino Uno,
      2. Then i move on Edison with Arduino, the output is always zero , and system(console) always output this when code is running :

      i2c-designware-pci 0000:00:09.1: i2c_dw_handle_tx_abort: lost arbitration

      [  362.875925] i2c-designware-pci 0000:00:09.1: i2c_dw_handle_tx_abort: lost arbitration

      [  373.128997] i2c-designware-pci 0000:00:09.1: i2c_dw_handle_tx_abort: lost arbitration

      [  389.645830] i2c-designware-pci 0000:00:09.1: i2c_dw_handle_tx_abort: lost arbitration

      [  390.058774] i2c-designware-pci 0000:00:09.1: i2c_dw_handle_tx_abort: lost arbitration

      [  393.061852] i2c-designware-pci 0000:00:09.1: ===== REGISTER DUMP (i2c) =====

      [  393.061951] i2c-designware-pci 0000:00:09.1: DW_IC_CON:               0x65

      [  393.062026] i2c-designware-pci 0000:00:09.1: DW_IC_TAR:               0x53

      [  393.062099] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_HCNT:       0x2f8

      [  393.062172] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_LCNT:       0x37b

      [  393.062244] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_HCNT:       0x87

      [  393.062316] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_LCNT:       0x10a

      [  393.062389] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_STAT:         0x0

      [  393.062460] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_MASK:         0x246

      [  393.062532] i2c-designware-pci 0000:00:09.1: DW_IC_RAW_INTR_STAT:     0x10

      [  393.062604] i2c-designware-pci 0000:00:09.1: DW_IC_RX_TL:             0x20

      [  393.062675] i2c-designware-pci 0000:00:09.1: DW_IC_TX_TL:             0x20

      [  393.062747] i2c-designware-pci 0000:00:09.1: DW_IC_ENABLE:            0x1

      [  393.062818] i2c-designware-pci 0000:00:09.1: DW_IC_STATUS:            0x2

      [  393.062889] i2c-designware-pci 0000:00:09.1: DW_IC_TXFLR:             0x6

      [  393.062960] i2c-designware-pci 0000:00:09.1: DW_IC_RXFLR:             0x0

      [  393.063031] i2c-designware-pci 0000:00:09.1: DW_IC_TX_ABRT_SOURCE:    0x0

      [  393.063102] i2c-designware-pci 0000:00:09.1: DW_IC_DATA_CMD:          0x40

      [  393.063172] i2c-designware-pci 0000:00:09.1: ===============================

      [  393.063275] CPU: 0 PID: 176 Comm: sketch.elf Tainted: G        W  O 3.10.17-poky-edison+ #1

      [  393.063280] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [  393.063287] task: f5fe5e90 ti: f55e4000 task.ti: f55e4000

      [  393.063349] Stack:

      [  393.063416] Call Trace:

      [  393.063751] Code: b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 44 c2 8b 15 54 ab b0 c1 89 82 00 b3 ff ff f7 c6 00 02 00 00 74 14 e8 67 f7 0a 00 56 9d <83> c4 04 5b 5e 5f 5d c3 90 8d 74 26 00 56 9d e8 51 f3 0a 00 83

      [  393.063776] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G        W  O 3.10.17-poky-edison+ #1

      [  393.063781] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [  393.063790] task: f6c83d30 ti: f6e1c000 task.ti: f6e1c000

      [  393.063851] Stack:

      [  393.063918] Call Trace:

      [  393.064123] Code: 8b 42 08 a8 08 75 24 31 c9 8d 42 08 89 ca 0f 01 c8 0f ae f0 89 f6 89 e0 25 00 e0 ff ff 8b 40 08 a8 08 75 07 b1 01 89 f0 0f 01 c9 <85> 1d 58 fd b3 c1 75 0d 8d 55 f0 b8 05 00 00 00 e8 8d 34 d9 ff

      [  393.064760] i2c-6: recovery ignore

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063275] CPU: 0 PID: 176 Comm: sketch.elf Tainted: G        W  O 3.10.17-poky-edison+ #1

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063280] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063287] task: f5fe5e90 ti: f55e4000 task.ti: f55e4000

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063349] Stack:

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063416] Call Trace:

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063751] Code: b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 44 c2 8b 15 54 ab b0 c1 89 82 00 b3 ff ff f7 c6 00 02 00 00 74 14 e8 67 f7 0a 00 56 9d <83> c4 04 5b 5e 5f 5d c3 90 8d 74 26 00 56 9d e8 51 f3 0a 00 83

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063776] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G        W  O 3.10.17-poky-edison+ #1

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063781] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063790] task: f6c83d30 ti: f6e1c000 task.ti: f6e1c000

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063851] Stack:

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:28:56 UTC):

       

       

      kernel[189]: [  393.063918] Call Trace:

      I try to run "i2cdetect -y -r 6" output like this:

           0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

      00:          -- -- -- -- -- -- -- -- -- -- -- -- --

      10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      70: -- -- -- -- -- -- -- --


      i try to run i2cset 6 0x53 0x2D 0 , it likes this

      i2cset 6 0x53 0x2D 0

      WARNING! This program can confuse your I2C bus, cause data loss and worse!

      DANGEROUS! Writing to a serial EEPROM on a memory DIMM

      may render your memory USELESS and make your system UNBOOTABLE!

      I will write to device file /dev/i2c-6, chip address 0x53, data address

      0x2d, data 0x00, mode byte.

      Continue? [y/N] y

      Error: Write failed


      Then i do Shield pin configuration in console:

      echo 28 > /sys/class/gpio/export

      echo 27 > /sys/class/gpio/export

      echo 204 > /sys/class/gpio/export

      echo 205 > /sys/class/gpio/export

      echo 236 > /sys/class/gpio/export

      echo 237 > /sys/class/gpio/export

      echo 14 > /sys/class/gpio/export

      echo 165 > /sys/class/gpio/export

      echo 212 > /sys/class/gpio/export

      echo 213 > /sys/class/gpio/export

      echo 214 > /sys/class/gpio/export

      echo 0 > /sys/class/gpio/gpio214/value

      echo 1 > /sys/class/gpio/gpio204/value

      echo 1 > /sys/class/gpio/gpio205/value

      echo in > /sys/class/gpio/gpio14/direction

      echo in > /sys/class/gpio/gpio165/direction

      echo 0 > /sys/class/gpio/gpio236/value

      echo 0 > /sys/class/gpio/gpio237/value

      echo in > /sys/class/gpio/gpio212/direction

      echo in > /sys/class/gpio/gpio213/direction

      echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux

      echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux

      echo 1 > /sys/class/gpio/gpio214/value


      and refresh program, Yeah ,i got  correct output .

      But i still get system error information ,like this:

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:24:13 UTC):

       

       

      kernel[190]: [  110.103868] Code: b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 44 c2 8b 15 54 ab b0 c1 89 82 00 b3 ff ff f7 c6 00 02 00 00 74 14 e8 67 f7 0a 00 56 9d <83> c4 04 5b 5e 5f 5d c3 90 8d 74 26 00 56 9d e8 51 f3 0a 00 83

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:24:13 UTC):

       

       

      kernel[190]: [  110.103893] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G        W  O 3.10.17-poky-edison+ #1

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:24:13 UTC):

       

       

      kernel[190]: [  110.103898] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:24:13 UTC):

       

       

      kernel[190]: [  110.103907] task: f6c83d30 ti: f6e1c000 task.ti: f6e1c000

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:24:13 UTC):

       

       

      kernel[190]: [  110.103969] Stack:

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:24:13 UTC):

       

       

      kernel[190]: [  110.104036] Call Trace:

       

       

       

       

      Broadcast message from systemd-journald@edison (Thu 2014-10-09 09:24:13 UTC):

       

       

      kernel[190]: [  110.104240] Code: 8b 42 08 a8 08 75 24 31 c9 8d 42 08 89 ca 0f 01 c8 0f ae f0 89 f6 89 e0 25 00 e0 ff ff 8b 40 08 a8 08 75 07 b1 01 89 f0 0f 01 c9 <85> 1d 58 fd b3 c1 75 0d 8d 55 f0 b8 05 00 00 00 e8 8d 34 d9 ff

       

       

      [  113.151806] i2c-designware-pci 0000:00:09.1: ===== REGISTER DUMP (i2c) =====

      [  113.151906] i2c-designware-pci 0000:00:09.1: DW_IC_CON:               0x65

      [  113.151981] i2c-designware-pci 0000:00:09.1: DW_IC_TAR:               0x53

      [  113.152054] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_HCNT:       0x2f8

      [  113.152127] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_LCNT:       0x37b

      [  113.152199] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_HCNT:       0x87

      [  113.152271] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_LCNT:       0x10a

      [  113.152344] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_STAT:         0x0

      [  113.152415] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_MASK:         0x246

      [  113.152487] i2c-designware-pci 0000:00:09.1: DW_IC_RAW_INTR_STAT:     0x10

      [  113.152559] i2c-designware-pci 0000:00:09.1: DW_IC_RX_TL:             0x20

      [  113.152631] i2c-designware-pci 0000:00:09.1: DW_IC_TX_TL:             0x20

      [  113.152703] i2c-designware-pci 0000:00:09.1: DW_IC_ENABLE:            0x1

      [  113.152774] i2c-designware-pci 0000:00:09.1: DW_IC_STATUS:            0x2

      [  113.152845] i2c-designware-pci 0000:00:09.1: DW_IC_TXFLR:             0x1

      [  113.152916] i2c-designware-pci 0000:00:09.1: DW_IC_RXFLR:             0x0

      [  113.152987] i2c-designware-pci 0000:00:09.1: DW_IC_TX_ABRT_SOURCE:    0x0

      [  113.153058] i2c-designware-pci 0000:00:09.1: DW_IC_DATA_CMD:          0xed

      [  113.153129] i2c-designware-pci 0000:00:09.1: ===============================

      [  113.153233] CPU: 0 PID: 249 Comm: sketch.elf Tainted: G        W  O 3.10.17-poky-edison+ #1

      [  113.153238] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [  113.153245] task: f50d8590 ti: f50ca000 task.ti: f50ca000

      [  113.153307] Stack:

      [  113.153374] Call Trace:

      [  113.153859] Code: b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 44 c2 8b 15 54 ab b0 c1 89 82 00 b3 ff ff f7 c6 00 02 00 00 74 14 e8 67 f7 0a 00 56 9d <83> c4 04 5b 5e 5f 5d c3 90 8d 74 26 00 56 9d e8 51 f3 0a 00 83

      [  113.153884] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G        W  O 3.10.17-poky-edison+ #1

      [  113.153889] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [  113.153897] task: f6c83d30 ti: f6e1c000 task.ti: f6e1c000

      [  113.153958] Stack:

      [  113.154026] Call Trace:

      [  113.154230] Code: 8b 42 08 a8 08 75 24 31 c9 8d 42 08 89 ca 0f 01 c8 0f ae f0 89 f6 89 e0 25 00 e0 ff ff 8b 40 08 a8 08 75 07 b1 01 89 f0 0f 01 c9 <85> 1d 58 fd b3 c1 75 0d 8d 55 f0 b8 05 00 00 00 e8 8d 34 d9 ff

      [  113.154868] i2c-6: recovery ignore

        and i run i2cdetect -y -r 6 , even their is correct output from serial ,but this one still no result:

           0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

      00:          -- -- -- -- -- -- -- -- -- -- -- -- --

      10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      70: -- -- -- -- -- -- -- --



      i try  this i2cset 6 0x53 0x2D 0 again , There is one line diff from before

      root@edison:~#  i2cset 6 0x53 0x2D 0

      WARNING! This program can confuse your I2C bus, cause data loss and worse!

      DANGEROUS! Writing to a serial EEPROM on a memory DIMM

      may render your memory USELESS and make your system UNBOOTABLE!

      I will write to device file /dev/i2c-6, chip address 0x53, data address

      0x2d, data 0x00, mode byte.

      Continue? [y/N] y

      [  266.469636] i2c-designware-pci 0000:00:09.1: i2c_dw_handle_tx_abort: lost arbitration

      Error: Write failed

       

      3. then i try Edison with Min breakout

      i use i2c6  J17 9 ---SDA

                     J17 7 ---SCL

                    J20  3 --GUD

                     J19 2 --  VCC

       

      same program ,and their is always zero output, But system(console) do not output any error information.


      i try i2cdetect -y -r 6 , is same like what i got in Edison Arduino:

       

       

           0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

      00:          -- -- -- -- -- -- -- -- -- -- -- -- --

      10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

      70: -- -- -- -- -- -- -- --



      i2cset 6 0x53 0x2D 0 also same:

       

       

       

      WARNING! This program can confuse your I2C bus, cause data loss and worse!

      DANGEROUS! Writing to a serial EEPROM on a memory DIMM

      may render your memory USELESS and make your system UNBOOTABLE!

      I will write to device file /dev/i2c-6, chip address 0x53, data address

      0x2d, data 0x00, mode byte.

      Continue? [y/N] y

      Error: Write failed



      i do Shield pin configuration in console like this :

      echo 28 > /sys/class/gpio/export

      sh: write error: Device or resource busy

      root@JacenEdison:~#  echo 27 > /sys/class/gpio/export

      sh: write error: Device or resource busy

      root@JacenEdison:~#  echo 204 > /sys/class/gpio/export

      sh: write error: No such device

      root@JacenEdison:~#  echo 205 > /sys/class/gpio/export

      sh: write error: No such device

      root@JacenEdison:~#  echo 236 > /sys/class/gpio/export

      sh: write error: No such device

      root@JacenEdison:~#  echo 237 > /sys/class/gpio/export

      sh: write error: No such device

      root@JacenEdison:~#  echo 14 > /sys/class/gpio/export

      sh: write error: Device or resource busy

      root@JacenEdison:~#  echo 165 > /sys/class/gpio/export

      sh: write error: Device or resource busy

      root@JacenEdison:~#  echo 212 > /sys/class/gpio/export

      sh: write error: No such device

      root@JacenEdison:~#  echo 213 > /sys/class/gpio/export

      sh: write error: No such device

      root@JacenEdison:~#  echo 214 > /sys/class/gpio/export

      sh: write error: No such device

      root@JacenEdison:~#  echo 0 > /sys/class/gpio/gpio214/value

      -sh: can't create /sys/class/gpio/gpio214/value: nonexistent directory

      root@JacenEdison:~#  echo 1 > /sys/class/gpio/gpio204/value

      -sh: can't create /sys/class/gpio/gpio204/value: nonexistent directory

      root@JacenEdison:~#  echo 1 > /sys/class/gpio/gpio205/value

      -sh: can't create /sys/class/gpio/gpio205/value: nonexistent directory

      root@JacenEdison:~#  echo in > /sys/class/gpio/gpio14/direction

      root@JacenEdison:~#  echo in > /sys/class/gpio/gpio165/direction

      root@JacenEdison:~#  echo 0 > /sys/class/gpio/gpio236/value

      -sh: can't create /sys/class/gpio/gpio236/value: nonexistent directory

      root@JacenEdison:~#  echo 0 > /sys/class/gpio/gpio237/value

      -sh: can't create /sys/class/gpio/gpio237/value: nonexistent directory

      root@JacenEdison:~#  echo in > /sys/class/gpio/gpio212/direction

      -sh: can't create /sys/class/gpio/gpio212/direction: nonexistent directory

      root@JacenEdison:~#  echo in > /sys/class/gpio/gpio213/direction

      -sh: can't create /sys/class/gpio/gpio213/direction: nonexistent directory

      root@JacenEdison:~#  echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pi

      nmux

      root@JacenEdison:~#  echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pi

      nmux

      root@JacenEdison:~#  echo 1 > /sys/class/gpio/gpio214/value

      -sh: can't create /sys/class/gpio/gpio214/value: nonexistent directory

      The red line doesn't happen in Edison Arduino.


      then i refresh program , still no output ,and also system no error output.


      I don't know what else i could try  ,hope someone could help me to solve this


      Thanks