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

nRF52832 - NFC stops working when SoftDevice is enabled

Hi,

I have a problem making NFC (with a simple text record) work when I enable SoftDevice: I do not receive any NFC event and NFC communication does not work.

I have a working project based on S332 (v5) using both BLE and ANT. The project does not have any know problems. I've added some trivial code for enabling NFC as per NFC text example, and it works only if I disable all SoftDevice related stuff. I've started removing all SD code and re-adding it line by line, and I've found the lines causing the problem are:

ret_code_t err_code = nrf_sdh_enable_request();
APP_ERROR_CHECK(err_code);

Just commenting the lines above and NFC works (obviously BLE/AND do not). I've also tried double checking and copying sdk_config.h but found nothing obvious. I've also tried adding my NFC code to BLE HRS examples and it works, so it must be something related to my project settings. I must be missing something but cant' find what. Any help would be appreciated.

Parents Reply
  • Ok. I see. No, I just wanted to check that you didn't have the HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND enabled, because this workaround contains a bug. 

    Actually, I am not sure exactly why it isn't working, but I know that the NFC has had a large number of bugfixes in the later SDKs. Is it too late for you to port to SDK15? (Preferably 15.2.0). The second option is to port only the NFC libraries to the ones from SDK15.2.0.

    If it is too late, is it possible to send your project, so that I can have a look?

    Best regards,

    Edvin

Children
  • Hi Edvin,

    thanks for helping out. I can't switch to 15.2 since I need S332 and it is not supported in SDK15.x yet. I'll wait for 15.3 due out soon.

    Regarding NFC, what puzzles me is that it should work since I can make my NFC code work with the same SDK and the sample BLE HRS example (featuring S132). The problem is I can't trace any difference between my full project and the examples that can explain. Obviously something is wrong, but considering how sdk_config.h can become bloated, I may have missed something.

    In any case I can provide a sample project for you to examine. Where/how can I share it?

    Thanks a lot!

  • Hello,

    You can share it here. If it is a sample project, I assume it is no problem that it is publicly available. If it isn't suited for public view, just send me a PM, and we can send the files there. Just zip the project folder, and send it here (insert -> insert image/video/file -> From: File Upload and browse to the zip-folder. If it is too large, it may throw an error while uploading. If that happens, just delete the _build folders, which typically takes up most of the space in a project folder. I can build it on my computer when I get it.

    I suspect that it is the NFC library/HAL that has a bug, and if it is softdevice related, it is probably something to do with the timers. 

    As a matter of fact, the S332 v6.1.1 was recently released. It should be compatible with SDK15.2.0, but as of now, there are no examples using it. They will come in SDK15.3.0, as you say, so it may be easier to wait for a bit. The ANT related API should be equal to the previous versions, as far as I understand.

    EDIT: forgot to attach the link to ANT softdevices:
    https://www.thisisant.com/developer/components/nrf52832#tab_protocol_stacks_tab

    BR,

    Edvin

  • Edwin,

    here is the project. It is based on ant_plus/ant_hrm/hrm_tx with slight modification to make it work with S332 just like in my main project. Notice that softdevice is required, but ANT is not relevant since it is not really used. I based off this project since it was the smallest I've found.

    If you run it, it should log "<info> app: NFC Event: Contact ON" and "<info> app: NFC Event: Contact OFF" when a reader is detected.

    Then, just uncommenting main.c lines 415-416 and NFC stops working, also no events are received from NFC.

    I've tried porting to S332 v6 and SDK15 but changes are relevant and require more time I can spend on it right now, I'd prefer to continue with SDK14.

    Thanks a lot!

    TestANTNFC.zip

  • Hello,

    Thanks to  who found the cause of the issue. 

    The issue is that when you enable the softdevice, it will start the HFCLK, which is also required by the NFC peripheral. The issue is that when it is started by the softdevice, the softdevice will receive the HFCLK events. It is the soc_evt_handler that usually forwards these events to the modules that require it, but since it is the softdevice that started the HFCLK, these events are passed directly to the softdevice. Since this project doesn't forward these events, the NFC is never properly started.

    So the fix is easy to implement.

    1. add the SDH (softdevice handler) Soc module to your project. (source file: components\softdevice\common\nrf_sdh_soc.c)
    2. Open your flash_placement.xml file (right click your project as if to open the project settings, and then press "import Section Placement". See the screenshot below)
      Then add this line right before the line line about .log_const_data:
      <ProgramSection alignment="4" keep="Yes" load="Yes" name=".sdh_soc_observers" inputsections="*(SORT(.sdh_soc_observers*))" address_symbol="__start_sdh_soc_observers" end_symbol="__stop_sdh_soc_observers" />

    Now, add the softdevice to your project by uncommenting the lines that you described in the main() function, and test it. It worked when I tested. 

    Best regards,

    Edvin

  • Hi,

    it worked like a charm! It was a newbie mistake, I could have fount it myself since it makes very sense now. In any case, thank you all!

Related