NFC dysfunctionality

When adding the Nordic SDK NFC example to the QANI-All-FreeRTOS_QNI_3_0_0 project, I noticed that NFC becomes non-functional after running the ‘niq_configure_and_start_uwb’ function in ‘ble_niq.c’ to start UWB.
I suspect that running ‘niq_configure_and_start_uwb’ sets the NFC pins as regular IO, because when I stop UWB and need to re-enable NFC, I have to add the code ‘NRF_UICR->NFCPINS=1’ before NFC initialization to set the NFC dedicated pins and use NFC functionality properly.

I need to be able to use NFC functionality properly even after UWB is started. Could you please advise on how to achieve this? I have also made the following two attempts:

(1) When I place the NFC initialization function after the ‘niq_configure_and_start_uwb’ function, UWB immediately stops, but NFC works.
(2) When I use a software timer to initialize NFC 3 seconds after ‘niq_configure_and_start_uwb’ is executed, the iOS app experiences a delay in distance measurement before resuming normal operation, but NFC remains non-functional.

I hope someone can help me clarify these doubts. Thank you!

Hi @chen !

“niq_configure_and_start_uwb” will call “ResumeUwbTasks()”, which will call “fira_niq_helper()”. I suggest you start a debug session, include the NFC-related registers to the Watch, and put a breakpoint at the beginning of “fira_niq_helper()”.
Probably you will be able to find what action is changing the registers and modify them to work with NFC.

Please come back to share your findings!
Kind regards!

I have reviewed the implementation of the “fira_niq_helper()” function, and I did not find any content related to NFC pin configuration.
As for the implementation of ”niq_configure_and_start_uwb“, I cannot see the specific code. I believe it is a library function within either “libniq-m4-hfp-1.1.0.0.a” or “libniq-m4-sfp-1.1.0.0.a”.
Could you provide more information about “niq_configure_and_start_uwb”?

Thank you!

Hi @chen !

Probably is not going to be a direct assignment to the NFC registers, but an action that has the side effect of affecting these registers or peripherals related to them, this is why it is important to keep watching the registers during execution to figure out what action is causing the issue.

“niq_configure_and_start_uwb()” is a closed function in the niq library and its source is not available. Likely to handle data and call the functions assigned during the library initialization:

    niq_init(ResumeUwbTasks, StopUwbTask, (const void *)nrf_crypto_init,
             (const void *)nrf_crypto_uninit,
             (const void *)nrf_crypto_rng_vector_generate);

Do not expect “niq_configure_and_start_uwb()” to call Nordic-specific functions or write registers. These changes are likely to be made by the functions called after “ResumeUwbTasks()”

Kind regards!

Hi @carlos.silva, due to the need for debugging, I have been starting UWB through my iPhone. However, breakpoints with long pause times always result in exceptions, making my debugging process quite challenging. Nonetheless, I have been able to perform some validation. When I commented out the “fira_niq_app_process_init()” and “fira_niq_app_process_start()” functions in “fira_niq_helper()” and started UWB, the NFC functionality remained unaffected, but the ranging measurements no longer showed any changes.

I believe that NFC being affected might be related to the parameter settings of the structure ‘session_parameters’ in the file fira_helper.h. Unfortunately, I am having difficulty determining it.

I hope you can provide more suggestions on how to ensure normal UWB ranging while keeping NFC unaffected. Thank you!

While using my iPhone to locate an Apple AirTag, I noticed that another phone is able to read the NFC data of the AirTag. How can I resolve the issue of NFC not working? I would greatly appreciate it if you could provide a solution. Thank you so much in advance!

Hi @chen !

When I commented out the “fira_niq_app_process_init()” and “fira_niq_app_process_start()” functions in “fira_niq_helper()” and started UWB, the NFC functionality remained unaffected

This is some good progress, these are the two functions you should dive into! Don’t expect the UWB and NFC to fully work during debugging, it is likely to not match the timings required for the peripherals to work, especially when you include breakpoints. Instead, check which registers are being changed and watch them during the debugging session.

I noticed that another phone is able to read the NFC data of the AirTag

FYI, Airtags use nRF52832, very close to your setup so, no reason to not work for you too.

Kind regards!

Hi @carlos.silva !

I am debugging and monitoring the registers related to NFCT. Apart from the changes in the registers during the initialization of NFC, there have been no changes in the registers during the startup and pause of the UWB session. However, NFC is still not functioning when UWB is activated, and this is causing me significant distress.

Can you provide any further suggestions? Thank you!

Hi @chen !

I think the only tip I can give you now is to set the project Optimization to “Level 0”:
Options → Code Generation → Optimization Level
it may cause the project to fail to meet timing constraints required by UWB, but will give you a better Debugging experience, and may help you find the issue.

Besides this, you have to understand the resources used by the NFC part and monitor them too. As an example, a while ago people here in the forum were having issues with UWB when disconnecting the dev kit from the USB (powering it with a battery). USB was not changing UWB-related functions, but it was stopping the high-speed clock, which is a resource shared by USB and UWB.

Good luck!
Kind regards!