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

TWI Scanner doesn't work on one set of gpio pins

Hello,

I've got a simple humidity/temperature sensor I am using, just to test out TWI on the PCA10040 Dev Kit.

When I wire up the sensor to the default SDA and SDCLK pins, I get the expected,  "TWI device detected at address 0x60"

But when I change the default config from:

    const nrf_drv_twi_config_t twi_config = {
       .scl                = ARDUINO_SCL_PIN,
       .sda                = ARDUINO_SDA_PIN,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

To:

    const nrf_drv_twi_config_t twi_config = {
       .scl                = 8,
       .sda                = 6,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

I don't get a  "TWI device detected at address 0x60" response.

But I also don't get a "No device was found." response.

So essentially, the first loop of:

nrf_drv_twi_rx(&m_twi, address, &sample_data, sizeof(sample_data))

returns an NRF_SUCCESS then doesn't log the "TWI device detected at address..." , even though the address of the sensor is 0x60, not 1.

Another weird thing is that if I use the same gpio pins that previously didn't recognize the sensor,

but simply flip the SDA and SDCLK pins like this:

    const nrf_drv_twi_config_t twi_config = {
       .scl                = 6,
       .sda                = 8,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

It again works as expected, returning  "TWI device detected at address 0x60".

So my question is, 

why does this work:

    const nrf_drv_twi_config_t twi_config = {
       .scl                = 6,
       .sda                = 8,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

but not this:

    const nrf_drv_twi_config_t twi_config = {
       .scl                = 8,
       .sda                = 6,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

I don't see how this would conflict with any PCA10040 defaults

Parents Reply Children
No Data
Related