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

Error code 3 passed to TWI manager callback

Hi,

I'm trying to connect an NRF52840-DK to a MAX30101 Wing board via I2C/TWI. I've set up the TWI Manager to send a message asking the MAX board for its part ID.

static uint8_t buffer[BUFFER_SIZE];

ret_code_t read_part_id(nrf_twi_mngr_t const * twi_mngr){
    // Read part ID
    // Read register 0xFF
    ret_code_t error;
    
    //static uint8_t buffer[BUFFER_SIZE];
    
    static nrf_twi_mngr_transfer_t const transfers[] = 
    {
        NRF_TWI_MNGR_READ(MAX_ADDR_READ, &buffer[0], 1, 0)
    };

    static nrf_twi_mngr_transaction_t transaction =
    {
        .callback = validate_part_id,
        .p_user_data = &buffer[0],
        .p_transfers = transfers,
        .number_of_transfers = sizeof(transfers) / sizeof(transfers[0]),
        .p_required_twi_cfg = NULL
    };

    error = nrf_twi_mngr_schedule(twi_mngr, &transaction);
    printf("Transaction queued\n");
    return error;
};

static void validate_part_id(ret_code_t result, void * p_user_data){
    if (result != NRF_SUCCESS){
        printf("Transaction failed\n");
        printf("0x%p\n", p_user_data);
        uint8_t temp = *(uint8_t*)p_user_data;
        printf("%d\n", temp);
        printf("read_max10_registers_cb - error: %d\n", (int)result);
    } else {
        printf("Transaction succeded\n");
    }
};

This is the output of the callback function:

Transaction failed
0x20001540
0
read_max10_registers_cb - error: 3

I've had a look and error code 3 is a generic internal error. Does anyone know how to fix this?

PS, I'm developing Segger EM on a Ubuntu Linux computer with SDK version 17.0.2

Parents Reply Children
Related