Are there any special conditions for CardEmulation operation?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Are there any special conditions for CardEmulation operation?

1,632 Views
ldw
Contributor I

Hello,

Among the examples provided by the PN5180, I am testing the integration of Ex2 AdvancedDiscoveryLoop and Ex8 HCE_T4T.

The documentation I referenced is the link below.
https://community.nxp.com/message/941308

Here is my scenario:
A. It basically works as a card reader.
B. When external RF signal is detected, it operates as card emulation.
C. After a certain period of time, return to the card reader.

The problem comes from B.

First, when the [PHAC_DISCLOOP_EXTERNAL_RFON] flag occurs, switching to card emulation mode works normally.

However, as explained in the example above
If [PHAC_DISCLOOP_ACTIVATED_BY_PEER] occurs in listen mode, card emulation mode does not work properly. (It enters the card emulation routine, but communication is not possible..)

In the case of iPhone, the scan mode is terminated when another RF signal is encountered during NFC scanning, so the PN5180 may not catch the RFON, which is a problem.

There is another situation,
This is the case when using time division rather than external RF signal detection as a mode switching trigger.
Here is the scenario:

A. Card reader works for 1 second
B. Card emulation mode for 1 second
repeat...


For example, after repeating Polling mode 500 times, and repeating card emulation 500 times,
Card emulation does not work properly.

Can you tell me what I am missing?

Thank you.


additional information...
The following is the method I am using when switching modes.

success:
else if((status & PH_ERR_MASK) == PHAC_DISCLOOP_EXTERNAL_RFON)
{
/*
* If external RF is detected during POLL, return back so that the application
* can restart the loop in LISTEN mode
*/
wEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN;
//Poll to listen
bMode = 1;

/* Switch off RF field */
statustmp = phhalHw_FieldOff(pHal);
CHECK_STATUS (statustmp);

status = phApp_HALConfigAutoColl();
CHECK_STATUS (status);

DEBUG_PRINTF (" \n PHAC_DISCLOOP_EXTERNAL_RFON... \n");
}

failure:

if((status & PH_ERR_MASK) == PHAC_DISCLOOP_ACTIVATED_BY_PEER)
{
//Poll to listen
//bMode = 1;
//wEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_POLL;

wEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN;
//Poll to listen
bMode = 1;

/* Switch off RF field */
statustmp = phhalHw_FieldOff(pHal);
CHECK_STATUS (statustmp);

status = phApp_HALConfigAutoColl();
CHECK_STATUS (status);
DEBUG_PRINTF (" \n Device activated in listen mode... \n");
}

Tags (2)
0 Kudos
9 Replies

423 Views
Matthias-A
Contributor II

Hi Idw, have you been able to make this work. I am also interested in the combination of HCE mode and Reader/writer mode. 

Regards Matthias

0 Kudos

1,458 Views
ldw
Contributor I

Hello.
During the test, a new question is discovered and asked.

In the code that combines Ex2_AdvancedDiscoveryLoop and Ex8, I did the following: (PNEV5180B board)

1. Set the value of LISTEN_PHASE_TIME_MS to 3000.
2. Bring iPhone to the antenna while the BUSY LED and IRQ LED are off.
3. Check external RF ON through phhalHw_EventWait.

External RF generated interrupt normally,
>> wEntryPoint = PHAC_DISCLOOP_ENTRY_POINT_LISTEN;
Changed to the following code.

>>bMode = 1; // If bMode == 1, T4TCardEmulation(); loop
>>phhalHw_FieldOff(pHal);
>>phApp_HALConfigAutoColl();

That is, after the process of 1,2,3, when the external RF signal is detected, the T4TCardEmulation function continues to operate.

But at the beginning of the T4TCardEmulation function,
/* Start discovery loop in listen mode */
>> wDiscLoop_status = phacDiscLoop_Run(
pDiscLoop,
PHAC_DISCLOOP_ENTRY_POINT_LISTEN);
>>if((wDiscLoop_status & PH_ERR_MASK) == PHAC_DISCLOOP_EXTERNAL_RFOFF)

if(.....) is always TRUE.

In short...
Case A.
If T4TCardEmulation is activated when external RF ON is detected in the Polling phase: Success.

Case B.
If T4TCardEmulation is activated when external RF ON is detected in the Listen phase: Failed.

And I don't know if it's the reason for the failure...
In Case B, the status of phacDiscLoop_Run inside T4TCardEmulation is always PHAC_DISCLOOP_EXTERNAL_RFOFF.

I still don't know what I'm missing.
Is there any other way I can try to solve the problem?

Thank you.

0 Kudos

1,458 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

Sorry but it is not quite clear for me, could you please help me clarify ?

Are you trying to have the Read/Write mode and the Card Emulation in the same example ?

pastedImage_1.png

The Advanced Discovery Loop example already shows both poll (read/write mode)  and listen (HCE) .

It might be something related to the layers and the implementation maybe , could you please help me check this webinar for a better understanding on the reader library ?

Regards,

Estephania

0 Kudos

1,458 Views
ldw
Contributor I

In addition, I share the method and results I tried.
Maybe this will help me solve my problem.
/////////////////
AdvDiscoveryLoop_Demo
{
   .....
   if(wEntryPoint == PHAC_DISCLOOP_ENTRY_POINT_POLL)
   {
      ...... //Poll phase
   }
   else
   {
   T4TCardEmulation()//Listen phase
   }
}
//////////////////
Changes
1. No change in poll phase based on Ex2 example.
2. T4TCardEmulation is performed during the Listen phase.

First try (default setting)
wEntryPoint starts with PHAC_DISCLOOP_ENTRY_POINT_POLL

result
T4TCardEmulation failed to check external RF.


Second try
wEntryPoint starts with PHAC_DISCLOOP_ENTRY_POINT_LISTEN

result
Successful NDEF exchange in the first Listen phase.
After the Poll phase, if it becomes the Listen phase again, T4TCardEmulation fails to check the external RF.

Regards,
Lee

0 Kudos

1,458 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

By any chance did you make sure that the configuration in the ph_NxpBuild_App.h has all the needed definition and configuration for both functionalities to work ?

Also, the HCE works with semaphores as well, are you sure that you are making use of them  in code?

regards,

Estephania

0 Kudos

1,458 Views
ldw
Contributor I

Hello,

There is one clue to solving my problem.

I said that HCE will fail if it works as a Listen phase after the Poll phase.

However, if the Tag was found in the Poll phase, it was confirmed that the HCE was successful in the Listen phase.

When I switched from the Poll phase to the Listen phase, I thought I would be able to solve something,

so I tried a few things and failed.

-pDiscLoop Initialize
-phhalHw_FieldReset
-phhalHw_Wait: up to 500ms

What else can I try?

When the result of phacDiscLoop_Run(PHAC_DISCLOOP_ENTRY_POINT_POLL) is PHAC_DISCLOOP_NO_TECH_DETECTED,

why does it affect phacDiscLoop_Run(PHAC_DISCLOOP_ENTRY_POINT_LISTEN)?

Regards,


Lee.

0 Kudos

1,458 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello,

 I have been checking the parts of code you are placing in the thread  and your explanation , in the first approach when using the Advanced Discovery loop example as a base for your project you are calling an infinite loop inside another infinite loop, so there is a chance if the second task is not being eliminated that it will never return to the first task .

In the second approach maybe the configuration parameters are not being changed completely or you have the same problem with the task where during the integration the events and tasks are not being initialized and finish in the correct way.

Also you will need to take into account the elements and definitions I mentioned that might be missing between those two examples and the integration of both in  a single project.

Hope this helps

Regards,
Estephania

0 Kudos

1,458 Views
ldw
Contributor I

Hello,

Since I am using a translator, was there a problem with the content delivery?

First of all, HCE is using semaphore. Like it did in Ex8.

Explaining the situation of my project...
-Does AdvancedDiscoveryLoop work?
Yes.

-Is HCE working?
Yes.

-HCE -> AdvancedDiscoveryLoop switching?
Yes.

-AdvancedDiscoveryLoop -> HCE transition?
No. HCE operates only under limited conditions.

-What is a limited condition?

status =phacDiscLoop_Run(pDataParams, PHAC_DISCLOOP_ENTRY_POINT_LISTEN) is called Listen phase,
status =phacDiscLoop_Run(pDataParams, PHAC_DISCLOOP_ENTRY_POINT_POLL) is called Poll phase.

1. When ((status & PH_ERR_MASK) == PHAC_DISCLOOP_EXTERNAL_RFON) in Poll phase, go to Listen phase and HCE operates. --- This is good.

2. If start is Listen phase, HCE is activated. --- I like this too.
 2-1. However, HCE does not work when the Poll phase is executed even once and it returns to the Listen phase.

--- This  is the problem...
Listen -> HCE Success

but
Listen-Poll-Listen -> HCE failed. (no response)


If I delete the below syntax in my project and run it, HCE is 100% working. (Of course, the card reader doesn't work...)
   status = phacDiscLoop_Run(pDataParams, PHAC_DISCLOOP_ENTRY_POINT_POLL);

Regards,
Lee

0 Kudos

1,458 Views
ldw
Contributor I

Hello.
Thanks for the answer.

Let me explain what I am doing.

It works based on Ex2 (AdvancedDiscoveryLoop) and should be switched to Ex8 (HCE_T4T) when external RF is detected.
I know Ex2 has a Listen phase.
But there is no NDEF file configuration, and there is no activating 14443p4mC.
So, I took what I needed from Ex8 and put it in Ex2 with the following structure.
/////////////////
AdvDiscoveryLoop_Demo()
{
   .....
   if(bMode==0) // Reder/Writer MODE
   {
      if(wEntryPoint == PHAC_DISCLOOP_ENTRY_POINT_POLL)
      {
       ....... //Poll phase
      }
      else
      {
       ........//Listen phase
      }
   }
   else //Card emulation MODE
   {
      T4TCardEmulation()  //from Ex8
   }
   .....
}
//////////////////
I hope my intentions are well communicated to you.

When T4TCardEmulation was added to the Listen phase, Card Emulation did not work, so this structure was adopted.

Currently, this structure works limitedly.

If the T4TCardEmulation routine is executed when the external RF is ON in the Poll phase, NDEF communication is successful.

In the Listen phase, the T4TCardEmulation routine does not work regardless of the condition.

Regards,
Lee

0 Kudos