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

TWI stops working - SDA bus always LOW

Hi!

I'm developing a project with nrf52832 and I'm getting some problems. The micro is only communicating with an accelerometer (MMA8453) and after some time the communication stops. Using a digital analyzer is possible observe that the SDA bus get stuck in LOW. I already tried to change the PULL UP resistors to smaller values (2.74k) and it keeps happening. I tried communicate with other slave and the same happens.

To fix that, I changed the configurations of nrf_drv_twi.c to work in push pull mode instead of pull up mode. I don't know if it is the correct way to do it.

I'm using the pins P02 (SDA) and P03(SCL) and changed the configuration to the following:

nrf_drv_twi_config_t twi_config;
twi_config.scl = CGPIO::I2C_SCL;
twi_config.sda = CGPIO::I2C_SDA;
twi_config.frequency = NRF_TWI_FREQ_250K;
twi_config.interrupt_priority = APP_IRQ_PRIORITY_HIGH;
    
nrf_drv_twi_init(&i2c_instance, &twi_config, NULL, NULL);
nrf_drv_twi_enable(&i2c_instance);

#define SCL_PIN_INIT_CONF     ( (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) \
                              | (GPIO_PIN_CNF_DRIVE_S0S1     << GPIO_PIN_CNF_DRIVE_Pos) \
                              | (GPIO_PIN_CNF_PULL_Pullup    << GPIO_PIN_CNF_PULL_Pos)  \
                              | (GPIO_PIN_CNF_INPUT_Connect  << GPIO_PIN_CNF_INPUT_Pos) \
                              | (GPIO_PIN_CNF_DIR_Input      << GPIO_PIN_CNF_DIR_Pos))
#define SDA_PIN_INIT_CONF        SCL_PIN_INIT_CONF
Related