I'm working on TWI with nrf52832 dev board, using examples from SDK 16. Here's the code:
#define I2C_INSTANCE_ID 0 #define I2C_ADDRESS 0x55 #define TWI0_SCL_PIN 23 #devine TWI0_SDA_PIN 22 static const nrfx_twi_t m_twi0 = NRFX_TWI_INSTANCE(I2C_INSTANCE_ID); void twi0_handler(nrfx_twi_evt_t const * p_event, void * p_context) { switch (p_event->type) { case NRFX_TWI_EVT_DONE: m_xfer_done = true; break; default: break; } } void twi0_init(void) { ret_code_t err_code; const nrfx_twi_config_t twi0_config = { .scl = TWI0_SCL_PIN, //Pin 23 .sda = TWI0_SDA_PIN, //Pin 22 .frequency = TWI_DEFAULT_CONFIG_FREQUENCY, //100 kHz .interrupt_priority = TWI_DEFAULT_CONFIG_IRQ_PRIORITY, //6 .hold_bus_uninit = false }; err_code = nrfx_twi_init(&m_twi0, &twi0_config, twi0_handler, NULL); APP_ERROR_CHECK(err_code); nrfx_twi_enable(&m_twi0); } void twi0_data_transfer(void) { APP_ERROR_CHECK(nrfx_twi_tx(&m_twi0, I2C_ADDRESS, m_twi_tx_buf0, m_twi_length0, false)); while (!m_xfer_done); //Wait until the tranfser is done }
I see no activity on the logic analyser and the application gets stuck in the TX while loop.
I get similar results when running the "TWI scanner" example. The example gets stuck at the "while (!nrf_twim_event_check(p_twim, evt_to_wait))", and no activity appears on the logic analyser. The RTT output only gets to "<info> app: TWI scanner started.", but nothing else happens.
What am I doing wrong here?