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

NRF_FAULT_ID_SDK_ERROR when running TWI master with nrf_twi_mngr

After init I2C channel
#define TWI_INSTANCE_ID 1 // because SPI0 share same reg add with TWI0 we change and enable TWI1
#define MAX_PENDING_TRANSACTIONS 5
NRF_TWI_MNGR_DEF(m_nrf_twi_mngr, MAX_PENDING_TRANSACTIONS, TWI_INSTANCE_ID);
APP_TIMER_DEF(m_timer);
// TWI=I2C (with transaction manager) initialization.
void twi_config(void)
{
uint32_t err_code;
nrf_drv_twi_config_t const config = {
.scl = ARDUINO_SCL_PIN,
.sda = ARDUINO_SDA_PIN,
.frequency = NRF_DRV_TWI_FREQ_100K,
.interrupt_priority = APP_IRQ_PRIORITY_LOWEST,
.clear_bus_init = false
};
err_code = nrf_twi_mngr_init(&m_nrf_twi_mngr, &config);
APP_ERROR_CHECK(err_code);
}
I call to configure the MAX30205 (temperature sensor close to LM75B) to config reg with all 0. as follow:
#define MAX30205_INIT_TRANSFER_COUNT 1
static uint8_t default_config[] = { MAX30205_REG_CONF, 0 };
nrf_twi_mngr_transfer_t const max30205_init_transfers[MAX30205_INIT_TRANSFER_COUNT] =
{
NRF_TWI_MNGR_WRITE(MAX30205_ADDR, default_config, sizeof(default_config), 0)
};
APP_ERROR_CHECK(nrf_twi_mngr_perform(&m_nrf_twi_mngr, NULL, max30205_init_transfers,
MAX30205_INIT_TRANSFER_COUNT, NULL));
I get into error NRF_FAULT_ID_SDK_ERROR with those parameters:
inside error handle I get error_code 0x3, line_num0x9C, p_file_name0xfff8 and POINTER (*) 0X43
I also run it on the original ex from Nordic (but use MAX30205 compatible to the LM75B).
The SDK I use is : nRF5_SDK_15.2.0_9412b96 and I run on mikro board for MAX30205
Thanks
Bar.
  • Hi Bar,

    I see you got the error code 0x3 (NRF_ERROR_INTERNAL) and line number 0x9c = 156, can you also check the file name? It is a ASCII string pointed to by p_file_name? Which function is called before the error check on that line?

    If we assume that was nrf_twi_mngr_perform(), then this is likely set in twi_event_handler() (and propagated via transaction_end_signal() etc...). Can you debug and see what is the event type in twi_event_handler() in this case?

  • Hi.

    In the twi_event_handler I get p_event 0x2003ff24 which is type NRF_DRV_TWI_EVT_ADDRESS_NACK

    with the *p_file_name I get to function  read_lm75b_registers_cb, in the twi example

    and in my project I the event in read_all_cb 

    They are both the callback function to the TWI transfer

    see the struct here:

    static nrf_twi_mngr_transaction_t NRF_TWI_MNGR_BUFFER_LOC_IND transaction =
    {
    .callback = read_all_cb,
    .p_user_data = NULL,
    .p_transfers = transfers,
    .number_of_transfers = sizeof(transfers) / sizeof(transfers[0])
    };

    Does it mean that the response from the sensor, was abnormal?

  • When I check on the scope I just see the SCL go down but the SDA doesn't. Even if I disconnect it from the other side (maybe it pullup all time) I still get SDA high all time. I am using PCA10056 with SDA,SCL connect to P0.28, P0.27. what could block the I2C operate like this?

    Bar.

  • Hi,

    There are always pull-ups on TWI, both on clock and data.

    Based on the event type, the slave NACKed (which is an error condition). That indicates that the data/command sent to the sensor might not be acceptable for some reason, which you might see by comparing with the MAX30205 datasheet. In that case it makes sense to use a logic analyzer so that you see what is actually happening.

    The slave can do clock stretching if it is busy, holding SCL low. If not, it should be held high by the pullup when there is no ongoing transaction.

Related