<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>NFC library code for type 4 NDEF card emulation : cannot disable nfc after enabling, or redo setup to change to (say) type 2 or ADPU handling config without ASSERT()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119883/nfc-library-code-for-type-4-ndef-card-emulation-cannot-disable-nfc-after-enabling-or-redo-setup-to-change-to-say-type-2-or-adpu-handling-config-without-assert</link><description>Smartbadge epaper custom board using nrf5340/nrf7002, with an NFC loop to allow NFC card emulation/communication. Building using NCS2.9 with sysbuild. 
 I want to be able to dynamically change my NFC card emulation under user control, between 
 -off </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Mar 2025 13:30:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119883/nfc-library-code-for-type-4-ndef-card-emulation-cannot-disable-nfc-after-enabling-or-redo-setup-to-change-to-say-type-2-or-adpu-handling-config-without-assert" /><item><title>RE: NFC library code for type 4 NDEF card emulation : cannot disable nfc after enabling, or redo setup to change to (say) type 2 or ADPU handling config without ASSERT()</title><link>https://devzone.nordicsemi.com/thread/528865?ContentTypeID=1</link><pubDate>Tue, 25 Mar 2025 13:30:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e370ce39-3fb8-48e6-a2b0-93a199f26a63</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Noted. Also, if you have the time, please come with any constructive feedback you have on what to improve on our end to make the documentation more understandable. What do you mean by the &amp;quot;only do setup once&amp;quot; flag in your last reply for example?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NFC library code for type 4 NDEF card emulation : cannot disable nfc after enabling, or redo setup to change to (say) type 2 or ADPU handling config without ASSERT()</title><link>https://devzone.nordicsemi.com/thread/528790?ContentTypeID=1</link><pubDate>Tue, 25 Mar 2025 09:53:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ec4f3b5-ccbf-4c02-8701-5c32f62a83a9</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;We can close this case; I would say that the doc could be better to help understand the order dependancies. If I get stuck when I move to raw APDU processing I&amp;#39;ll post a new ticket....&lt;/p&gt;
&lt;p&gt;thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NFC library code for type 4 NDEF card emulation : cannot disable nfc after enabling, or redo setup to change to (say) type 2 or ADPU handling config without ASSERT()</title><link>https://devzone.nordicsemi.com/thread/528775?ContentTypeID=1</link><pubDate>Tue, 25 Mar 2025 09:10:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49d592ad-5f2e-48fb-81d1-f08e98723283</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Glad to hear you figured it out Brian. Are there any follow-ups or should we close this case then?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NFC library code for type 4 NDEF card emulation : cannot disable nfc after enabling, or redo setup to change to (say) type 2 or ADPU handling config without ASSERT()</title><link>https://devzone.nordicsemi.com/thread/528585?ContentTypeID=1</link><pubDate>Mon, 24 Mar 2025 11:40:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe612725-538d-4c1e-a957-7f7f4de87f0b</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;Well, for my test I did not enable t2t at all, just switched t4t on and off...&lt;/p&gt;
&lt;p&gt;I think I have found the issue: I had previously had a error return when calling&amp;nbsp;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int ret = nfc_t4t_setup(_nfc_t4t_ndef_cb, &amp;amp;_ctx);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;a second time (in my test of nfc on/nfc off / nfc on / nfc off...)&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;I therefore added a flag to only do the setup first time. Then, my test did:&amp;nbsp;&lt;/div&gt;
&lt;p&gt;1/ Boot&lt;/p&gt;
&lt;p&gt;2/ Nfc on&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;/span&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;nfc_t4t_setup(_nfc_t4t_ndef_cb, &amp;amp;_ctx);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nfc_t4t_ndef_rwpayload_set(ctx-&amp;gt;ndef_buff, MAXLEN_NDEF);&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nfc_t4t_emulation_start();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;-&amp;gt;OK&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;NFC off:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nfc_t4t_emulation_stop();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nfc_t4t_done(); &amp;nbsp; &amp;nbsp; // release NFC periph&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;-&amp;gt;OK&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;NFC on (note: the code has a flag which means it doesnt try to nfc_t4t_setup more than once, so no setup this time)&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;/span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;nfc_t4t_ndef_rwpayload_set(ctx-&amp;gt;ndef_buff,&lt;span&gt;&amp;nbsp;&lt;/span&gt;MAXLEN_NDEF);&lt;span&gt;&amp;nbsp;&lt;/span&gt;//ctx-&amp;gt;ndef_sz);&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;nfc_t4t_emulation_start();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;-&amp;gt;OK&lt;/div&gt;
&lt;p&gt;NFC off&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;nfc_t4t_emulation_stop();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;-&amp;gt; ASSERT in modules/hal/nordic/nrfx/drivers/src/nrfx_nfct.c&lt;br /&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;void nrfx_nfct_disable(void)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; NRFX_ASSERT(m_nfct_cb.state == NRFX_DRV_STATE_INITIALIZED);&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; nrfy_nfct_int_disable(NRF_NFCT, NRF_NFCT_DISABLE_ALL_INT);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; nrfy_nfct_task_trigger(NRF_NFCT, NRF_NFCT_TASK_DISABLE);&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; NRFX_LOG_INFO(&amp;quot;Stop&amp;quot;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;debugger shows m_nfct_cb.state is in fact NRFX_DRV_STATE_UNINITIALIZED.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;It appears this state is set to&amp;nbsp;NRFX_DRV_STATE_INITIALIZED in nrfx_nfct_init() and back to&amp;nbsp;NRFX_DRV_STATE_UNINITIALIZED in nrfx_nfct_uninit().... The call method makes it difficult to work out which nfc_t4t_XXX function actually calls the nrfx_nfct_YYY functions....&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I removed the &amp;#39;only do setup once&amp;#39; flag, and retried: and this time it works -&amp;gt; no assert. So, I guess nfc_t4t_setup() is what calls the nrfx_nfct_init()....&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;And the previous error returned from the setup call was because my code would call the enable() twice (with no disable()) due to a bug : as long as I do the stop before redoing the setup/start, it seems to be ok!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;So:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Start sequence is&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp;nfc_t4t_setup(_nfc_t4t_ndef_cb, &amp;amp;_ctx);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp;// set ndef payload if want NDEF procedures, don&amp;#39;t if want to manage raw APDUs ourselves&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp;nfc_t4t_ndef_rwpayload_set(ctx-&amp;gt;ndef_buff, MAXLEN_NDEF);&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp;nfc_t4t_emulation_start();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:inherit;"&gt;Stop sequence:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp;nfc_t4t_emulation_stop();&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp;nfc_t4t_done();&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:inherit;"&gt;I have added the fix you indicate for the case when I want to do type 2 cards as well, thanks.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:inherit;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NFC library code for type 4 NDEF card emulation : cannot disable nfc after enabling, or redo setup to change to (say) type 2 or ADPU handling config without ASSERT()</title><link>https://devzone.nordicsemi.com/thread/528325?ContentTypeID=1</link><pubDate>Fri, 21 Mar 2025 07:56:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9c4b6bd-846e-432c-9351-b8e1acb2c0f6</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Okay, so you can confirm that there are no calls to&amp;nbsp;&lt;strong&gt;nfc_t4t_done()&amp;nbsp;&lt;/strong&gt;before the emulation_stop() function on your end?&lt;/p&gt;
&lt;p&gt;Then you can try the following. There was an issue that has not yet been added to the upstream SDK it seems where the T2T and T4T libraries weren&amp;#39;t designed to co-exist, so you need to reset the register explicitly to set up NFC for both tag types correctly. Call this after nfc_t2t_setup() and see if that helps:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* Reset the SELRES Protocol field for the T2T platform */

NRF_NFCT-&amp;gt;SELRES = NRF_NFCT-&amp;gt;SELRES &amp;amp; ~NFCT_SELRES_PROTOCOL_Msk;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It might not be relevant to the issue we&amp;#39;re seeing here, but I think you need to do it down the line.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NFC library code for type 4 NDEF card emulation : cannot disable nfc after enabling, or redo setup to change to (say) type 2 or ADPU handling config without ASSERT()</title><link>https://devzone.nordicsemi.com/thread/528268?ContentTypeID=1</link><pubDate>Thu, 20 Mar 2025 15:36:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f08e12cf-68dd-4b0c-99dc-7a052039c3e4</guid><dc:creator>BrianW</dc:creator><description>[quote userid="75734" url="~/f/nordic-q-a/119883/nfc-library-code-for-type-4-ndef-card-emulation-cannot-disable-nfc-after-enabling-or-redo-setup-to-change-to-say-type-2-or-adpu-handling-config-without-assert/528240"]Do you by chance call&amp;nbsp;&lt;span&gt;nfc_t4t_emulation_stop()&amp;nbsp;&lt;strong&gt;after&lt;/strong&gt;&amp;nbsp;nfc_t4t_done()? Since &lt;strong&gt;nfc_t4t_done&lt;/strong&gt;() calls &lt;strong&gt;nrfx_nfct_uninit&lt;/strong&gt;() and that might be why the emulation_stop() calls. Which&amp;nbsp;&lt;strong&gt;nfc_t4t_emulation_stop&lt;/strong&gt;() call is it that returns this assert?&lt;/span&gt;[/quote]
&lt;p&gt;As per the posted code, in nfc_disable:&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; nfc_t4t_emulation_stop();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; nfc_t4t_done(); // release NFC periph&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Its the first call to emulation_stop() that breaks it...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NFC library code for type 4 NDEF card emulation : cannot disable nfc after enabling, or redo setup to change to (say) type 2 or ADPU handling config without ASSERT()</title><link>https://devzone.nordicsemi.com/thread/528240?ContentTypeID=1</link><pubDate>Thu, 20 Mar 2025 13:54:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6218dd6-0b45-4e4a-b959-f212c11cc457</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Do you by chance call&amp;nbsp;&lt;span&gt;nfc_t4t_emulation_stop()&amp;nbsp;&lt;strong&gt;after&lt;/strong&gt;&amp;nbsp;nfc_t4t_done()? Since &lt;strong&gt;nfc_t4t_done&lt;/strong&gt;() calls &lt;strong&gt;nrfx_nfct_uninit&lt;/strong&gt;() and that might be why the emulation_stop() calls. Which&amp;nbsp;&lt;strong&gt;nfc_t4t_emulation_stop&lt;/strong&gt;() call is it that returns this assert?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>