P.S. The code that invokes i2c read/write functions in my project is below:

  uint8_t check = 0x0F;
  struct hal_i2c_master_data pwrite = {
    .address = 0x19,
    .len = 1,
    .buffer = &check
  };

  rc = hal_i2c_master_write(0, &pwrite, 500, 1); // always returns -1

  uint8_t readCheck = 0;
  struct hal_i2c_master_data pdata = {
    .address = 0x19,
    .len = 1,
    .buffer = &readCheck
  };

  rc = hal_i2c_master_read(0, &pdata, 500, 1); // always returns -1


And the timeouts are coming from /hw/mcu/nordic/nrf52xxx/src/hal_i2c.c

        while (!regs->EVENTS_TXDSENT && !regs->EVENTS_ERROR) {
            if (os_time_get() - start > timo) {
                regs->TASKS_STOP = 1;
                goto err;
            }
        }

and

        while (!regs->EVENTS_RXDREADY && !regs->EVENTS_ERROR) {
            if (os_time_get() - start > timo) {
                regs->SHORTS = TWI_SHORTS_BB_STOP_Msk;
                goto err;
            }
        }

On Sun, Apr 9, 2017 at 2:57 PM, Łukasz Wolnik <lukasz.wol...@gmail.com>
wrote:

> Hello,
>
> I cannot get I2C working on my RedBear BLE Nano 2 board. I connected an
> accelerometer (LIS3DH) but according to gdb the hal_i2c_master_write/read
> functions just time out.
>
> RedBear BLE Nano 2 pins layout:
>
> https://www.kickstarter.com/projects/redbearinc/bluetooth-
> 5-ready-ble-module-nano-2-and-blend-2#h:nano-2
>
>
> Because rb-nano2's bsp is not configured to support I2C below is what I
> added to mynewt-core:
>
> https://github.com/limal/incubator-mynewt-core/commit/
> 353fcb10368811a7bbe3e2b10f019fb44dc121f7
>
>
> To rule out a possibility that UART_0 is interfering with I2C, that share
> the same pins on rb-nano2, I disabled it and send any logging information
> via Bluetooth to another nano-2 board. Unfortunately the I2C is still
> timing out.
>
> 9100:[ts=71093744ssb, mod=4 level=1] GAP procedure initiated: advertise;
> disc_mode=2 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0
> adv_itvl_min=50 adv_itvl_max=75 adv_data_len=0
> 9817:[ts=76695268ssb, mod=64 level=1] connection established; status=0
> handle=1 our_ota_addr_type=0 our_ota_addr=91:0a:c0:ff:42:57
> our_id_addr_type=0 our_id_addr=91:0a:c0:ff:42:57 peer_ota_addr_type=0
> peer_ota_addr=0f:0f:0a:0a:0a:0a peer_id_addr_type=0
> peer_id_addr=0f:0f:0a:0a:0a:0a conn_itvl=40 conn_latency=0
> supervision_timeout=256 encrypted=0 authenticated=0 bonded=0
> 9827:[ts=76773388ssb, mod=64 level=1]
> 9828:[ts=76781200ssb, mod=64 level=1] (0): open
> 10188:[ts=79593712ssb, mod=64 level=1] (0): read_check: 1111
> 10190:[ts=79609336ssb, mod=64 level=1] (0): hal_write_rc: -1 <-------------
> 10192:[ts=79624960ssb, mod=64 level=1] (0): hal_read_rc: -11 <-------------
> 10829:[ts=84601524ssb, mod=64 level=1] (0): read_check: 1111
> 10830:[ts=84609336ssb, mod=64 level=1] (0): hal_write_rc: -1 <-------------
> 11469:[ts=89601524ssb, mod=64 level=1] (0): read_check: 1111
> 12109:[ts=94601524ssb, mod=64 level=1] (0): read_check: 1111
> 12749:[ts=99601524ssb, mod=64 level=1] (0): read_check: 1111
>
>
> I have tried adding 10k resistors to pull up SDA/SCL lines but to no
> avail. And finally I have also connected the accelerometer to Arduino Uno
> to confirm it's working (I posted Arduino code here:
> http://discuss.redbear.cc/t/i2c-not-working-on-nano2-
> in-arduino-and-apache-mynewt/2106).
>
>
> I'm very satisfied with mynewt but being unable to use I2C renders the
> whole project unusable.
>
> I'd appreciate any help to sort it out and get I2C to work on rb-nano2.
>
> Kind regards,
> Lukasz
>
>
>
>

Reply via email to