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

NRF52840 USB_CDC_ACM + NFC

Hi,

I am currently exploring the USB_CDC_ACM examples as well as the NFC record launch app.

Individually, I can make the examples run fine.

Then, I tried to combine the functionality of the two into a single project without removing any codes whatsoever.

With power supplied to the board, the NFC works without any problems. However, as soon the nRF52840 USB port is connected to the PC, the NFC can no longer trigger my phone to launch the Nordic App. The USB port and firmware is functioning normally as I can see strings being output on my terminal.

Is there a way I can make the USB + NFC to work concurrently, or have I done something wrong somewhere?

I am currently using a custom board, as the PCA10056 PDK I have (V0.9.2) has problems with its nRF USB port.

Thanks in advance.

  • Hello,

    What SDK are you using? I recommend that you use SDK15 as it has some bug fixes for the NFC.

    However, there is a bug in the SDK15 release where the fix is not yet released. It will come in a future release.

     

    I don't know whether you use t4t or t2t, but the bug is present in both. I'll use the t4t to explain. If you are having problems implementing the fix for t2t, let me know.

     

    In the file <SDK15>\components\nfc\t4t_lib\hal_t4t\hal_nfc_t4t.c:

    On the lines around 567 it should look something like this:

     

                    HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG!
                    nrf_drv_clock_hfclk_request(&m_clock_handler_item);
    
    #ifdef HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND
                    /* Begin: Bugfix for FTPAN-190 */
                    if (!is_first_sample)
                    {
                        m_nfc_activate_conditions       = 0;
                        m_nfc_fieldevents_filter_active = true;
    
                        NRF_TIMER4->TASKS_CLEAR = 1;
                        NRF_TIMER4->TASKS_START = 1;
                    }
                    /* END: Bugfix for FTPAN-190 */
    #endif // HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND
    
                    HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG!

     

    The problem is that the hfclk is requested before m_nfc_activate_confitions is set to 0. When the hfclk is started, m_nfc_activate_conditions is incremented, but since it is reset too late, m_nfc_activate_conditions is never reaching the value that is expected.

     

    The fix is to move the nrf_drv_clkock_hfclk_request() to after the

    #ifdef HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND

    ...

    #endif // HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND

     

    It should look something like this:

    #ifdef HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND
                    /* Begin: Bugfix for FTPAN-190 */
                    if (!is_first_sample)
                    {
                        m_nfc_activate_conditions       = 0;
                        m_nfc_fieldevents_filter_active = true;
    
                        NRF_TIMER4->TASKS_CLEAR = 1;
                        NRF_TIMER4->TASKS_START = 1;
                    }
                    /* END: Bugfix for FTPAN-190 */
    #endif // HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND
    
                    HAL_NFC_DEBUG_PIN_SET(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG!
                    nrf_drv_clock_hfclk_request(&m_clock_handler_item);
                    HAL_NFC_DEBUG_PIN_CLEAR(HAL_NFC_HCLOCK_ON_DEBUG_PIN); // DEBUG!

     

    If you use t2t, the fix should be very similar, just in the hal_nfc_t2t.c file.

     

    Try to change that, and see if it works. We have seen that this bug is causing problems when combining USB and NFC before.

     

    Best regards,

    Edvin

     

Related