TWIS (I2C slave) no IRQ

Hi

I'm trying to use the nrfx TWI Slave function with IRQ (No Poll), but there is no clean code available I found.

I'm using the following code:

const nrfx_twis_t m_twis_1_slave = NRFX_TWIS_INSTANCE(1);    /**< TWIS slave 1 instance */

#define STEINEL_SENSORS_MY_ADDRESS		0x08

const nrfx_twis_config_t twis_config_1 =
{
	.addr = { (STEINEL_SENSORS_MY_ADDRESS >> 1), 0 }, 
    .scl = RJ11_I2C_SCL,
    .sda = RJ11_I2C_SDA,
    .scl_pull = NRF_GPIO_PIN_NOPULL,
    .sda_pull = NRF_GPIO_PIN_NOPULL,
    .interrupt_priority = APP_IRQ_PRIORITY_HIGH
};

NVIC_ClearPendingIRQ(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn);
NVIC_SetPriority(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn, 6);
NVIC_EnableIRQ(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQn);

ret = nrfx_twis_init(&m_twis_1_slave, &twis_config_1, twis_event_handler);

if (NRF_SUCCESS == ret)
	{
		printf("twi slave init success\r\n");
		nrfx_twis_enable(&m_twis_1_slave);
	}

But even if I can see the data on the oscilloscoipe with the address 0x08, the function

static void twis_event_handler(nrfx_twis_evt_t const* const p_event)

never gets triggered. Whats the provblem here? It's not normal to spend hours and days for a I2C slave feature, but without examples its try and error...

Any inputs from Nordic side? Or a example code with IRQ?

Parents Reply Children
  • I just recognized, that the NRF_ERROR_BUSY is in realtion with the TWI instance 0.

    const nrfx_twi_t m_twi_0_master = NRFX_TWI_INSTANCE(0);     /**< TWI master 0 instance */
    const nrfx_twi_t m_twi_1_master = NRFX_TWI_INSTANCE(1);     /**< TWI master 1 instance */

    I need the TWI instance 0 and 1 as master in normal oiperation. After this, I need the TWI 0 as master and TWI1 as slave (TWIS). When I call nrfx_twi_disable(&m_twi_0_master) and nrfx_twi_uninit (&m_twi_0_master) before calling the init for the TWIS i have ret = success.

    conclusion: TWIS and TWI (master and slave) at the same time on different peripherals are not possible?!?

    -> please confirm

    ret = nrfx_twis_init(&m_twis_1_slave, &twis_config_1, twi_slave_event_handler);
    
        /* Init TWIS */
        if (NRFX_SUCCESS == ret)
        {
            nrfx_twis_enable(&m_twis_1_slave);
        }

Related