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

nrf52 NFC with softdevice running

Hi all, Here is my first question on this forum after many hours working with the NRF but for the first time I didn't found the answer :)

My problem is : I would like to run the NFC in ISO/ICE 14443 Type A mode with t4t for reading and writing. For now, it works alone (with some strange behaviours). I'am able to exchange in both ways (read/write) few bytes and that's exactly what I want. The strange behaviour I mentionned above is that after few read/write sequences, it stops working and the callbak given in "nfc_t4t_setup" is no more called (only for NFC_T4T_EVENT_FIELD_OFF event). That is the first point, how could I get status of the nfc lib to monitor and, if needed, restart it?

The next step on which I'm struggling is that I want to use NFC with softdevice enabled and last but not least, in a low power application. Current ble example using NFC are not relevant because it's only for paring. So I initialized NFC as usual but since I go to sleep with "sd_app_evt_wait" it doesn't wake up when I try to use NFC but the power consumption rise up to 5mA instead of 3µA before approaching the smartphone. Is someone could help to, first find a way to use NFC properly with softdevice, and second how to wakeup properly on an event like NFC field or something ?

Last question : NFC callback seems to be timming sensitive (if I print debug in it) It doesn't work properly. Any advice ?

Thanks in advance for your help.

Here the code (all functions begining with Sys are calling our custom code):

int main(void) {

uint32_t err_code;
IS_DBG_Init();

// Set up NFC 
err_code = nfc_t4t_setup(nfc_callback, NULL);

// Start sensing NFC field 
err_code = nfc_t4t_emulation_start();

Sys_Init();

app_timer_init();
ble_stack_init(app_ble_callback);
gap_params_init(DEVICE_NAME,BLE_APPEARANCE_UNKNOWN,TX_POWER_LEVEL,STATIC_PASSKEY);
//gatt_init();
//services_init(&_app);
advertising_init(APP_ADV_INTERVAL, APP_ADV_TIMEOUT_IN_SECONDS);
//conn_params_init(); //need app_timer_init 
peer_manager_init();
advertising_start(true);

//start_scan();

while (1)
{
    if (Sys_Process())
    {
        Sys_Sleep();

        sd_app_evt_wait();

        Sys_Wakeup();
    }
}

}

  • I think I have an answer for my first problem (nfc_lib stops working properly) : Seems that the define HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND helps solving the problem. It's enabled by default when using BOARD_PCA10040 but since I'm on a custom board I had to add it in my own sdk_config.h.

    But still my second problem is there, I can't wake up from sd_app_evt_wait() with NFC field. After many tries, if I comment my Sys_Sleep it works but what I'm doing in here is only disabling UART0 to reach 3µA consumption CODE :

    	nrf_uart_int_disable(NRF_UART0, NRF_UART_INT_MASK_RXDRDY | NRF_UART_INT_MASK_TXDRDY | NRF_UART_INT_MASK_ERROR | NRF_UART_INT_MASK_RXTO);
       	nrf_drv_common_irq_disable(nrf_drv_get_IRQn(NRF_UART0));
    	nrf_uart_disable(NRF_UART0);
    	nrf_uart_txrx_pins_disconnect(NRF_UART0);
    

    Please let me know if you have any idea on this strange behavior...

    EDIT : After many tries and research, I found that it was question of timming. In fact, NFC lib and SoftDevice callback seems to be very sensitive. I had a pulling printf in sys_evt_dispatch callback. Because it was printing on UART at 9600bds I think NFC timming and lib was not guaranteed so it went wrong (I suppose)... Now all seems to be OK

  • If I put a comment on nrf_uart_disable(NRF_UART0); so UART0 stays enable, It wakes up and get out of sd_app_evt_wait(), same behaviour if I replace sd_app_evt_wait() with __WFI(); But what's the link between UART and NFC ? no idea...

    Anyway, this solution is not acceptable because of power consumption...

  • Hi,

    Have you seen the Wake on NFC Example?

    Take a look at the bsp_nfc_sleep_mode_prepare() function.

    So I initialized NFC as usual but since I go to sleep with "sd_app_evt_wait" it doesn't wake up when I try to use NFC but the power consumption rise up to 5mA instead of 3µA before approaching the smartphone.

    You are getting 5mA in sleep mode? and by disabling UART0 you get 3µA?

    Could it be that you are not actually entering sleep mode when the UART0 is enabled, or that you are immediately waking up from sleep mode when UART0 is enabled? And since you have not configured NFC correctly as a wakeup-source, you are only able to use the NFC when UART0 is running(i.e. when you are not in sleep mode) ?

  • Hi Sigurd, I reach 3µA when uart is disabled, and sleep mode is OK. But since I approach my NFC reader the consumption rises to 5mA but I'm still in sd_app_evt_wait()... It's like something happens in the core but no event or interrupt to wakeup. I'm pretty sur that I'm in sleep mode because my debug prints something to tell me when it wakes... I tried to call bsp_nfc_sleep_mode_prepare() but nothing changed.

Related