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

nrf_drv_twi_tx & rx with Adafruit PN532

I have the Adafruit PN532 Shield v1.3 mounted to an nRF52840 DK, trying to run the ble_nfc_pairing_reference_c example from SDK 17. With no modification to the example code, I was getting the following output.

  

After some debugging I found the error was returning from the nrf_drv_twi_tx function with these default arguments passed. 

To investigate, I flashed the twi_scanner example and successfully found the PN532 at address 0x24. 

Since this doesn't match the PN532_I2C_ADDRESS being passed in the nfc reference example, I changed (0x48 >> 1) to (0x24). This resulted in the following output. 

The only difference being that the tx function seemed to send data successfully, but the nrf_drv_twi_rx function that passes those same parameters was returning a wild error while trying to read the acknowledgement. 

Since I was getting two different error scenarios, I re-extracted a fresh SDK 17 and tried again, but the exact behavior occurred. Does anyone know what is going on here?

My theory is that either there is something wrong with the Adafruit hardware, or these parameters are not configured correctly, unless I'm missing something. 

Any help here would be much appreciated. 

Thanks in advance!

Sam

  • What happens if you do not have the 1 ms delay in place? Is there an error generated, or is it the same behavior as we have seen before with the IRQ staying high?

    That is correct. Without the delay, IRQ stays high and the ack_read fails. With the delay everything is acknowledged successfully. 

    When you tested this with the adafruit_tag_reader example, did everything work as intended then? Did the board respond anything else than 0x8080808080?

    In the Adafruit Tag Reader example, everything seems to initialize correctly. 

    This happens regardless of the 1ms delay in the ack read function. 

    However, when I run the 10040 adafruit tag reader example with the 1ms added as I've mentioned and changing the IRQ and RESET pins, the PN532 again responds with 0x8080808080 every time. So I'm all but convinced that this is entirely a board migration issue. 

    Are there resources about migrating board support examples from 10040 to 10056 specifically? The settings you posted above don't seem to be entirely up to date. I believe the only changes that were necessary in the sdk_config.h were the IRQ and RESET pins to 35 and 36 respectively. 

    Cheers,

    Sam

Related