cancel
Showing results for 
Search instead for 
Did you mean: 

Using X-CUBE-NFC3 with STM32L475 custom board and SPI2 instead of SPI1

NFerr.1
Associate II

For my first foray into the STM32 world I've been trying to get to read nfc tags with a STM32L475 and ST25R95 custom board. It is taking me a while to get used to the CUBE IDE, since including libraries many times results in errors, specially since I'm coming from the Arduino IDE.

As the title says I'm trying to adapt the included polling example(for the L476 board) to work with a custom board based on the STM32L475. I'm using the SPI2 port which I have inited in the main code, (pins PB12-PB15). I have made the changes in platform.h and st25r95_com.h to change hspi1 to hspi2. But still I always get initialization failed... any more places I should be changing SPI1 to SPI2?

Thank you for your time.

20 REPLIES 20

Hi Nuno,

a framework is provided within our RFAL API.

Basically, you just need to set the discParam.wakeupEnabled to true before calling rfalNfcDiscover(&discParam). For example, it can be set to true in demoIni(). Note: in the polling demo (demo.c), the reader wake up mode is enabled when pressing the user button. The ST25R95 will enter the Wait For Event mode (tag detection) if no tag is present in the operating volume and will exit when a tag is detected.

Once the ST25R95 has entered the tag detection mode, the MCU is notified through the notification function with parameter RFAL_NFC_STATE_WAKEUP_MODE. See demoNotif() in the demo application. The MCU can then enter in low power mode (e.g. with HAL_PWR_EnterSLEEPMode). When a tag is detected, the IRQ_OUT will be go low (falling edge) until the SPI response is read.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Understood! Right now, with just changing     discParam.wakeupEnabled    = true ; I get 1.5mA power consumption while sleeping and waiting for tag. Could I get the parameters for the default wakeupConfig so I can make a custom one based of it? (I'm trying to get the parameters to get around 100uA like you show in Optimization of wake-up time and power consumption on ST25R95 and CR95HF devices Application note, in chapter 3.3).

It feels like I'm one step closer to being able to get what I want so thank you once again for you support Brian.

My best regards,

Nuno

Brian TIDAL
ST Employee

Hi,

can you detail how you measure the power consumption i.e. is it the overall power consumption including the STM32L4 part and the ST25R95 part? To reduce the overall power consumption, make sure to have the STM32L4 being in low power mode and having all unused GPIO being in analog config. STM32L4 has various low power mode (SLEEP, STOP0, STOP1, STOP2). If possible, I would recommend to use STOP2 (HAL_PWREx_EnterSTOP2Mode) which is the most efficient. Note: make sure to properly reconfigure the clocks when exiting from the STOPx mode as all high speed clocks are stopped when entering this mode (use SystemClock_Config(); to reconfigure the clock tree). See STM32L4 online training.

For the ST25R95 part, the SwingsCnt parameter in the Idle command is already set to the recommended 0x3F value (64 pulses per burst) and the WUperiod is set to 0x24 (~300 ms between 2 detection bursts, see RFAL_ST25R95_IDLE_DEFAULT_WUPERIOD). This can be easily checked with an oscilloscope.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
NFerr.1
Associate II

Hello,

I have two multimeters measuring current. One in the IDD pin, which measures the STM32L475 Power consumption (at the moment hovers around 100uA, but I know its possible to do better, I have tested sketches at around 1-2uA using stop mode). The other one is between the 3.3v of the ST25R95 and the board, to show how much current this board is pulling. At the moment I managed to improve it to around 1.2mA for the ST25R95 part. I'm more concerned with the power draw of the ST25R95 since the project will be installed with batteries, so I would like to get around 100uA if possible. In my understanding the best idea for lowering power consumption would be to increase the WUperiod alongside reducing the number of pulses per burst? I'm worried this will worsen the NFC detection a lot, since it will be the thing waking up our MCU.

Thank you,

Nuno

Brian TIDAL
ST Employee

Hi Nuno,

Can you check with an scope that the HF oscillator (27.12 MHz) is properly switch off and periodically restarted for detection bursts (see yellow signal in AN3433 figure 4)?

Can you check that the detection period is around 304 ms (i.e. time between 2 detections: duration between 2 yellow peak)?

Can you measure the duration of a yellow peak, i.e duration of HF oscillator being ON and system being consuming power

Can you check the detection burst duration (should be 4.7 µs)?

For the ST25R95 part, what is the power consumption in ready mode with Field ON and in ready mode with Field OFF (you can put a breakpoint at the end of functions st25r95FieldOn or st25r95FieldOff, once the ProtocolSelect has been executed)

If I am not wrong, in tag detection mode, the main power consumption contributor is VPS (the peak current on VPS_TX is 100mA but during only swingCount=3Fh i.e. 4.7 µs, therefore the average current on VPS_TX should be neglectable)

Osc Start and Dac Start are maybe a little bit conservative: can you try to reduce from 0x60 to 0x40 in Idle[] = {ST25R95_COMMAND_IDLE, 0x0E, 0x0A, 0x21, 0x00, 0x38, 0x01, 0x18, 0x00, 0x20, 0x60, 0x60, 0x74, 0x84, 0x3F, 0x00}. What is the new power consumption?

RFAL_ST25R95_IDLE_DEFAULT_WUPERIOD is 24h (i.e 304 ms). Can you try to change it to 49h (i.e. 600 ms). What is the new power consumption?

By the way, what is your battery capacity and the expected autonomy?

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello Brian!

I come with some news. With the Stop2 mode my STML475 is consuming around 1.6uA, so the MCU power consumption could be considered negligible by now.

That leaves the ST25R95. Using another Nucleo NFC3 board, I could get around 100-110uA Average with the default wake up parameters and using both tweaks you have mentioned(in the idle command set I put both OSC start and DAC start to 0x40 and put the default wu period from 24h to 49h) I lowered it a bit to around 95uA, which is something, but a bit more than I was expecting. I have to change the WU Period in both the Idle command (in st25r95_com_spi) and in the definition in rfal_rfst25r95 right?

We are dimensioning this project to work with one 3500mAh battery, and we are trying to last for at least a year of operation. This board will also have a modem onboard(NBIOT preferably if the place of installation allows).

Brian TIDAL
ST Employee

Hi Nuno,

actually, st25r95SPIIdle() overwrites the default WUPeriod defined in Idle[] array, so it is only needed to update

RFAL_ST25R95_IDLE_DEFAULT_WUPERIOD in rfal_rfst25r95.

Can you try to keep the OSC start and DAC start to the recommended original value (0x60) and only modify the RFAL_ST25R95_IDLE_DEFAULT_WUPERIOD parameter to 49h and see what is the power consumption? I am just wondering whether OSC start and DAC start has a significant impact on power consumption but I cannot do measurements for the moment on my side.

By the way, is 600ms (WUPeriod= 49h) acceptable for your application?

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
NFerr.1
Associate II

Hello Brian,

Putting the default parameters to the OSC Start and DAC start, seems to have almost no effect in the power consumption, but one thing that is weird is that on my first tests I was able to have around 100uA with the same settings I'm now getting 140-150uA from. I think I really have to get an oscilloscope to see if everything is correct with the bursts.

As for the WUPeriod = 49h, meaning 600ms, its perfectly fine since it is not a time sensitive operation. But I've played with bigger WUPeriods and it did not seem to have a lot of effect in the total power consumption, so it might be due to the LEDs in the nucleo board? Sinking current even when they are not being used. Or maybe even other pins on the Nucleo NFC3 board.

For now this gives us a good battery life, but we are trying to understand if it would be possible to lower it even further. Theoretically the x-nucleo-nfc05a1 would have a lower power consumption in wake up mode, is that correct? From the datasheet I understood that while the idle value without burst for the ST25R95/CR95 is around 60uA, while for the part used in the nfc05a1(ST25R3911B ) this idle current would be around 6uA.

Thank you once again for your amazing support Brian,

My best regards,

Nuno

Brian TIDAL
ST Employee

Hi Nuno,

as far as I remember, in low power mode, the ST25R3911B has a lower power consumption than the ST25R95/CR95HF. For your information, the RFAL API is the same for ST25R3911B, ST253916 and ST25R95/CR95HF. Therefore, you can reuse the same user source code with the different series.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
NFerr.1
Associate II

Thank you Brian, I'll order a nucleo nfc05a1 kit to try it out. But for now everything works under 200uA, which is not bad for a preliminary prototype. Do you have any idea of the absolute lowest consumption the ST25R95/CR95HF could get in wake up mode? I'll tweak with the parameters myself, but it would be nice to have a general idea.

Thank you once again for the attention and support.