This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Cannot use TWI on nRF51822 with S130-v2.0.1 and nRF_SDK_v12.3

Hi, I’m a newbie of nRF SoC. I have a BLE gadget with nRF51822_xxAC that controls LEDs and obtains data from accelerometers through I2C(TWI) devices. The hex file for the gadget software was originally created using nRF_SDK v8 on S110-v8 and compiled using ArmCC (Kei).

I’m trying to port it to newer version SDK and softdevice, nRF_SDK v12.3 and S130-v2.0.1, using GCC. Most of things go well. But I have a trouble with TWI.

Two I2C devices are connected to the nRF51822 at pin#36(SCL),37(SDA) and pin#32(SCL),31(SDA). pin#36,37 and #32,31 may correspond to P00.09 and P00.10 and P00.28 and P00.29, respectively.

According to some TWI examples, I modified the twi initialization function and the read/write function in the gadget software. The initialization by nrf_drv_twi_init() seems to be succeed (no error code returns). However, Any RX ( and TX) fails owing to address NACK. Of course, exactly the same gadget with original software (SDK v8 and S110) works fine, so this would not be a hardware trouble. The configuration (only P0.09 and P0.10) in the software is as follows:

const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(0);
const nrf_drv_twi_config_t twi_conf = {
    .frequency          = (nrf_twi_frequency_t)TWI_DEFAULT_CONFIG_FREQUENCY,   \
    .scl                = 9,                                                                                           \
    .sda                = 10,                                                                                        \
    .interrupt_priority = TWI_DEFAULT_CONFIG_IRQ_PRIORITY,                              \
    .clear_bus_init     = TWI_DEFAULT_CONFIG_CLR_BUS_INIT,                                \
    .hold_bus_uninit    = TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT,                       \
};

For testing, I checked I2C slave address of those devices using twi_scannar in the SDK_v12.3 example, but I couldn’t any devices at both pin pairs.

What should I do to solve this problem? Any help and suggestions are appreciated!

Related