Hello,
I'm using the sdk v17.0.2 with softdevice s140 with a custom PCB shipping the nrf52840.
I'm facing an issue where I cannot enable NFC and softdevice at the same time.
When the NFC is enabled and the softdevice is not, the my tag can be read from an Android smartphone. But I soon I enable the softdevice (with nrf_sdh_enable_request), the tag cannot be read anymore.
There is my very simple example:
#include "nfc_ndef_msg.h" #include "nfc_t2t_lib.h" #include "nfc_text_rec.h" #include <app_error.h> #include <nrf_log.h> #include <nrf_pwr_mgmt.h> #include <nrf_sdh.h> #include <string.h> #define MAX_REC_COUNT 3 /**< Maximum records count. */ /* Text message in English with its language code. */ /** @snippet [NFC text usage_1] */ static const uint8_t en_payload[] = { 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!'}; static const uint8_t en_code[] = {'e', 'n'}; /** @snippet [NFC text usage_1] */ /* Buffer used to hold an NFC NDEF message. */ uint8_t m_ndef_msg_buf[256]; /** * @brief Callback function for handling NFC events. */ static void nfc_callback(void *p_context, nfc_t2t_event_t event, const uint8_t *p_data, size_t data_length) { (void) p_context; switch (event) { case NFC_T2T_EVENT_FIELD_ON: //bsp_board_led_on(BSP_BOARD_LED_0); NRF_LOG_INFO("NFC Field ON"); break; case NFC_T2T_EVENT_FIELD_OFF: //bsp_board_led_off(BSP_BOARD_LED_0); NRF_LOG_INFO("NFC Field OFF"); break; default: break; } } static ret_code_t welcome_msg_encode(uint8_t *p_buffer, uint32_t *p_len) { /** @snippet [NFC text usage_2] */ ret_code_t err_code; /* Create NFC NDEF text record description in English */ NFC_NDEF_TEXT_RECORD_DESC_DEF(nfc_en_text_rec, UTF_8, en_code, sizeof(en_code), en_payload, sizeof(en_payload)); /** @snippet [NFC text usage_2] */ /* Create NFC NDEF message description, capacity - MAX_REC_COUNT records */ /** @snippet [NFC text usage_3] */ NFC_NDEF_MSG_DEF(nfc_text_msg, MAX_REC_COUNT); /** @snippet [NFC text usage_3] */ /* Add text records to NDEF text message */ /** @snippet [NFC text usage_4] */ err_code = nfc_ndef_msg_record_add(&NFC_NDEF_MSG(nfc_text_msg), &NFC_NDEF_TEXT_RECORD_DESC(nfc_en_text_rec)); VERIFY_SUCCESS(err_code); /** @snippet [NFC text usage_5] */ err_code = nfc_ndef_msg_encode(&NFC_NDEF_MSG(nfc_text_msg), p_buffer, p_len); return err_code; /** @snippet [NFC text usage_5] */ } int main() { uint32_t len = sizeof(m_ndef_msg_buf); ret_code_t err_code = 0; // uncomment this and the NFC won't work anymore err_code = nrf_sdh_enable_request(); APP_ERROR_CHECK(err_code); //Set up NFC err_code = nfc_t2t_setup(nfc_callback, NULL); APP_ERROR_CHECK(err_code); //Encode welcome message err_code = welcome_msg_encode(m_ndef_msg_buf, &len); APP_ERROR_CHECK(err_code); //Set created message as the NFC payload err_code = nfc_t2t_payload_set(m_ndef_msg_buf, len); APP_ERROR_CHECK(err_code); //Start sensing NFC field err_code = nfc_t2t_emulation_start(); APP_ERROR_CHECK(err_code); NRF_LOG_INFO("in done..."); while (1) {} }
I found a similar issue here [1] but the fix doesn't work for me.
There is my linker script file:
/* Linker script to configure memory regions. */ SEARCH_DIR(.) GROUP(-lgcc -lc -lnosys) MEMORY { FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0xc9000 RAM (rwx) : ORIGIN = 0x20002C00, LENGTH = 0x3d400 uicr_bootloader_start_address (r) : ORIGIN = 0x10001014, LENGTH = 0x4 } SECTIONS { . = ALIGN(4); .uicr_bootloader_start_address : { PROVIDE(__start_uicr_bootloader_start_address = .); KEEP(*(SORT(.uicr_bootloader_start_address*))) PROVIDE(__stop_uicr_bootloader_start_address = .); } > uicr_bootloader_start_address } SECTIONS { . = ALIGN(4); .mem_section_dummy_ram : { } .log_dynamic_data : { PROVIDE(__start_log_dynamic_data = .); KEEP(*(SORT(.log_dynamic_data*))) PROVIDE(__stop_log_dynamic_data = .); } > RAM .log_filter_data : { PROVIDE(__start_log_filter_data = .); KEEP(*(SORT(.log_filter_data*))) PROVIDE(__stop_log_filter_data = .); } > RAM .fs_data : { PROVIDE(__start_fs_data = .); KEEP(*(.fs_data)) PROVIDE(__stop_fs_data = .); } > RAM } INSERT AFTER .data; SECTIONS { .mem_section_dummy_rom : { } .sdh_ble_observers : { PROVIDE(__start_sdh_ble_observers = .); KEEP(*(SORT(.sdh_ble_observers*))) PROVIDE(__stop_sdh_ble_observers = .); } > FLASH .sdh_soc_observers : { PROVIDE(__start_sdh_soc_observers = .); KEEP(*(SORT(.sdh_soc_observers*))) PROVIDE(__stop_sdh_soc_observers = .); } > FLASH .pwr_mgmt_data : { PROVIDE(__start_pwr_mgmt_data = .); KEEP(*(SORT(.pwr_mgmt_data*))) PROVIDE(__stop_pwr_mgmt_data = .); } > FLASH .log_const_data : { PROVIDE(__start_log_const_data = .); KEEP(*(SORT(.log_const_data*))) PROVIDE(__stop_log_const_data = .); } > FLASH .sdh_req_observers : { PROVIDE(__start_sdh_req_observers = .); KEEP(*(SORT(.sdh_req_observers*))) PROVIDE(__stop_sdh_req_observers = .); } > FLASH .sdh_state_observers : { PROVIDE(__start_sdh_state_observers = .); KEEP(*(SORT(.sdh_state_observers*))) PROVIDE(__stop_sdh_state_observers = .); } > FLASH .sdh_stack_observers : { PROVIDE(__start_sdh_stack_observers = .); KEEP(*(SORT(.sdh_stack_observers*))) PROVIDE(__stop_sdh_stack_observers = .); } > FLASH .log_backends : { PROVIDE(__start_log_backends = .); KEEP(*(SORT(.log_backends*))) PROVIDE(__stop_log_backends = .); } > FLASH .nrf_balloc : { PROVIDE(__start_nrf_balloc = .); KEEP(*(.nrf_balloc)) PROVIDE(__stop_nrf_balloc = .); } > FLASH } INSERT AFTER .text INCLUDE "nrf_common.ld"
I still do not understand if I need to register soc event with NRF_SDH_BLE_OBSERVER. Do the nfc_t2t handle it?
Best,
Joël