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

Fatal error in adafruit_pn532_init

Trying to run the experimental nfc pairing reference on a couple of 840 DKs for Bluetooth pairing as it's shipped in SDK 17. 

Successfully compiled the micro-ecc make files for my appropriate boards, and I have the Adafruit PN532 breakout board with headers soldered on it so it will fit the DK (or should I be using the PN532 Adafruit shield specifically?). 

After compiling and flashing the central reference example with no modification, I get a fatal error with no other debug messages. 

After some debugging, I've narrowed it down to the adafruit_pn532_init function and I get this. 

So the error is an NRF_ERROR_INTERNAL, but why no other debug messages from the function? I'm quite confused. 

Here is my main function

int main(void)
{
    NRF_LOG_INFO("Main");
    logs_init();
    NRF_LOG_INFO("logs init");
    timer_init();
    NRF_LOG_INFO("timer init");
    buttons_init();
    NRF_LOG_INFO("buttons init");
    ble_stack_init();
    NRF_LOG_INFO("ble stack init");
    gatt_init();
    NRF_LOG_INFO("gatt init");
    peer_manager_init(false);
    NRF_LOG_INFO("peer manager");
    nfc_init();
    NRF_LOG_INFO("nfc init");
    scan_init();
    NRF_LOG_INFO("scan init");

    NRF_LOG_INFO("NFC Connection Handover BLE Central device example started.");

    while (true)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            nfc_tag_process();
        }
    }
}

And here is the nfc_init function with my debug messages added. 

void nfc_init(void)
{
    NRF_LOG_INFO("NFC INIT FUNCTION");
    ret_code_t err_code = adafruit_pn532_init(false);
    NRF_LOG_INFO("The error code is %d", err_code);
    APP_ERROR_CHECK(err_code);

    nrf_ble_lesc_peer_oob_data_handler_set(nfc_peer_oob_data_get);

    // Register handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, NFC_BLE_PAIR_OBSERVER_PRIO, ble_nfc_pair_handler, NULL);
}

I get the same results even when setting the <force> argument to true. 

Currently I have SEL0 and SEL1 open on the pn532 breakout, so i2c should be enabled, but I can't tell if this is the problem area. 

Again, I haven't touched the Adafruit PN532 library at all since extracting it fresh from SDK 17. 

All I want to do is get a my two 840 DKs to pair over NFC.

Any help would be appreciated!

Thanks!

Sam

Parents Reply
  • Looking at your trace again, I can see that there is actually a second read started here after the stop bit after the first transaction. That read should not occur until irq go low. 

    Can it be a timing issue here of some kind. Can you for test try to add a 100us delay in adafruit_pn532_cmd_send() after adafruit_pn532_command_write() before calling adafruit_pn532_waitready_ms()?

    Edit: The intention of the 100us delay is to ensure that the polling of adafruit_pn532_waitready_ms() does not start before irq go high after the twi address is sent.

    Edit2:

Children
Related