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
  • That post has nothing at all to do with TWI, that's only concerned with drive strength when the pins are used as normal GPIOs. It doesn't mention TWI at all. So if changing that made a difference it's a total fluke and your bug, whatever it is, still persists.

    The manual is very clear that the GPIO settings ONLY matter when the peripheral is disabled. When the TWI is active, it takes full control of the pins and detaches them entirely from the GPIO system. Also the manual stipulates S0D1 must be used as the drive strength on the pins (for when the TWI is disabled and they are acting as regular GPIOs).

    So you may have masked your problem, but that is not the solution, and you've a fairly good chance it's coming back at some point.

Reply
  • That post has nothing at all to do with TWI, that's only concerned with drive strength when the pins are used as normal GPIOs. It doesn't mention TWI at all. So if changing that made a difference it's a total fluke and your bug, whatever it is, still persists.

    The manual is very clear that the GPIO settings ONLY matter when the peripheral is disabled. When the TWI is active, it takes full control of the pins and detaches them entirely from the GPIO system. Also the manual stipulates S0D1 must be used as the drive strength on the pins (for when the TWI is disabled and they are acting as regular GPIOs).

    So you may have masked your problem, but that is not the solution, and you've a fairly good chance it's coming back at some point.

Children
No Data
Related