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
  • @RK: Where in the documentation does it explicitly say that GPIO settings only matter when the peripheral is disabled? That may not be entirely correct.

    I talked to one of our TWI architects and he said that the GPIO settings actually do influence the pin even when the TWI is enabled. In other words, changing the drive strength from S0D1 to S0S1 will have an effect on the TWI bus. In light of this I suppose OP's issue might be related to the impedance of the TWI lines. The fact that lowering the frequency helps seems to support this.

    @Rafa:

    1. Are you able to look at the signals using an oscilloscope? Maybe the nRF52 struggles to drive the lines to correct voltage levels, and that might be easier to spot using an oscilloscope rather than a logic analyzer.
    2. Have you tried a different nRF52 device?
Reply
  • @RK: Where in the documentation does it explicitly say that GPIO settings only matter when the peripheral is disabled? That may not be entirely correct.

    I talked to one of our TWI architects and he said that the GPIO settings actually do influence the pin even when the TWI is enabled. In other words, changing the drive strength from S0D1 to S0S1 will have an effect on the TWI bus. In light of this I suppose OP's issue might be related to the impedance of the TWI lines. The fact that lowering the frequency helps seems to support this.

    @Rafa:

    1. Are you able to look at the signals using an oscilloscope? Maybe the nRF52 struggles to drive the lines to correct voltage levels, and that might be easier to spot using an oscilloscope rather than a logic analyzer.
    2. Have you tried a different nRF52 device?
Children
No Data
Related