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
Parents
  • Dear @Martin Børs-Lind, thank you for your answer.

    • I already used an oscilloscope to look at the signals. During some tests it seems that, when SDA line is waiting for an SCL variation, that variation never comes up and if I force the SCL pin to LOW/HIGH (deepening on the state it was stuck), the communication start working again. -I already tried with my circuit and also with a nRF52 devkit. The behavior is the same. In another test with a different slave, even if I change the GPIO settings, TWI stops working.
Reply
  • Dear @Martin Børs-Lind, thank you for your answer.

    • I already used an oscilloscope to look at the signals. During some tests it seems that, when SDA line is waiting for an SCL variation, that variation never comes up and if I force the SCL pin to LOW/HIGH (deepening on the state it was stuck), the communication start working again. -I already tried with my circuit and also with a nRF52 devkit. The behavior is the same. In another test with a different slave, even if I change the GPIO settings, TWI stops working.
Children
No Data
Related