cancel
Showing results for 
Search instead for 
Did you mean: 

I'm using rfal 1.3.0 and nfcPoller. These work fine on our hardware, but nfcPoller is taking 16% CPU at idle (re: no tech detection).

MHamm.1
Associate II

I'd like to make nfcPoller interrupt driven. I've tried registering a callback so that exampleRfalPollerRun() gets called on interrupts but that didn't seem to do anything. I've also tried a simple loop that does this:

        ret = gpio_init();
        if(ret != ERR_NONE)
            goto error;
        ret = spi_init();
        if(ret != ERR_NONE)
            goto error;
        ret = interrupt_init();
        if (ret != ERR_NONE)
            goto error;
     
        rfalAnalogConfigInitialize();
        rfalInitialize();
        rfalWakeUpModeStart(NULL);
        
        for(;;)
        {
            rfalWorker();
            if ( rfalWakeUpModeHasWoke() )
            {
                printf("Awakened\n");
                rfalWakeUpModeStop(); 
                sleep(1);
                rfalWakeUpModeStart(NULL);
            }
        }

But I don't get the awakened message. In any event, this isn't really interrupt driven anyway since I'm just spinning in a tighter loop. I'd like to be able to poll() on the interrupt line, as is done in pltf_gpio.c:pthread_func(). If I just call my own callback in that function I don't see the wake-up interrupt, suggesting I'm either not using the API correctly or it's not working properly. I don't know how to tell which at the moment.

Is there a methodology I should be using to switch from polling to interrupt driven processing when using the rfal library? We want to handle processing only when a tag is held over the chip instead of constantly polling for available tags in order to reduce CPU overhead.

FYI, I put in a usleep(750) in the deactivate case of exampleRfalPollerRun() (only when no tag had been detected and processed) which reduced cpu usage to about 3% on idle but that seems like an ugly hack.

1 ACCEPTED SOLUTION

Accepted Solutions
Ulysses HERNIOSUS
ST Employee

Hi,

which ST25R device are you actually using?

Looking at your code it seems you are using Linux?!

There are two problems you are somehow mixing here:

  1. ST25R devices are more low level frontends, so they will not perform any RF communication without an MCU initiating it. However there are ways of putting it into a low power tag detection mode (wakeup mode on ST25R3911/16) where it sends small pulses and senses the change in the LC tank. This could be used to achieve something what you are mentioning.
  2. Our Linux demo currently consumes more MCU than necessary. We are working on improving the situation to only needing to run rfalWorker() on Interrupt and timer expire. However for getting this you would need to wait for some weeks and maybe live with the increased MCU consumption in the meantime.

Regards, Ulysses

View solution in original post

3 REPLIES 3
Ulysses HERNIOSUS
ST Employee

Hi,

which ST25R device are you actually using?

Looking at your code it seems you are using Linux?!

There are two problems you are somehow mixing here:

  1. ST25R devices are more low level frontends, so they will not perform any RF communication without an MCU initiating it. However there are ways of putting it into a low power tag detection mode (wakeup mode on ST25R3911/16) where it sends small pulses and senses the change in the LC tank. This could be used to achieve something what you are mentioning.
  2. Our Linux demo currently consumes more MCU than necessary. We are working on improving the situation to only needing to run rfalWorker() on Interrupt and timer expire. However for getting this you would need to wait for some weeks and maybe live with the increased MCU consumption in the meantime.

Regards, Ulysses

Ulysses HERNIOSUS
ST Employee

Hi,

the new version of STSW-ST25R013 is now available on st.com. It makes better usage of CPU now.

BR, Ulrich

zhaocz
Associate II

Hello, did you eventually implement NFC interrupt-driven functionality?
I've recently encountered the same issue as well.