Skip to main content
MatthieuB
Associate
October 19, 2018
Solved

ST25R3911B + STM32L072 in Standby mode (Very low power)

  • October 19, 2018
  • 25 replies
  • 3644 views

Hi,

I'm working with a ST25R3911B RFID chip associated to a STM32L072 uC.

I use the "STM32CubeExpansion_NFC5_V1.2.0" project, ported from STM32F401 to STM32L072.

This project enables to set the ST25R3911B  in wake-up low power mode.

Now I'm trying to set the STM32L072 in standby mode with the ST25R3911B  using the IRQ.

I can wake-up the STM32 with IRQ generated by ST25R3911B  when a badge is passed but I cannot read the badge.

So my question is : is the "STM32CubeExpansion_NFC5_V1.2.0" project compliant with uC low power mode like standby ?

Regards,

Matthieu

    This topic has been closed for replies.
    Best answer by MatthieuB

    Hi Ulysses,

    now it seems to be clean, I can wake-up the STM32 with ST25R3911B, read a badge and put the ST25R3911B in Wake-up mode again.

    For that I have to :

    • read ISR (st25r3911Isr())
    • Clear ISR (st25r3911ClearInterrupts())
    • Reset ST25R3911_REG_OP_CONTROL to 0
    • Power Down the ST25R3911B (I have created a function for that)
    • Initialize RFal (rfalAnalogConfigInitialize())
    • Initialize the ST25R3911B st25r3911Initialize()
    • Put the ST25R3911B in Wake-up mode (rfalWakeUpModeStart)

    So now the ST25R3911B can detect again badges and generate IRQ on dedicated pin.

    But how to read again badges using your ST functions when an IRQ is catched ?

    Regards,

    Matthieu

    PS : I just have an oscilloscope at office, it will be great to have a logic analyzer...

    25 replies

    Ulysses HERNIOSUS
    ST Technical Moderator
    October 30, 2018

    Hi Mathieu,

    not sure I do understand:

    • What is your Power Down function doing??? Setting ST25R3911_REG_OP_CONTROL to 0 is power down.
    • Instead of st25r3911Initialize() you should call rfalInitialise().
    • You can wake up the STM32 form ST25R3911B, read a card and go back to wakeup mode. So you have everything, what do you mean by "read again badges"?

    Regards, Ulysses

    P.S.: You should really get a logic analyzer. The PC based ones are not too expensive. Logic Analyzer s are IMO an absolute must for any real embedded software developer.

    MatthieuB
    MatthieuBAuthor
    Associate
    October 31, 2018

    Hi Ulysses,

    indeed my Power Down function does :

    • ST25R3911_REG_IO_CONF1 => F
    • ST25R3911_REG_IO_CONF2 => 80
    • ST25R3911_REG_OP_CONTROL => 0
    • ST25R3911_REG_MODE => 08

    I just tried to replace st25r3911Initialize() by  rfalInitialise() and seems to be ok.

    By the way the projet consist on doing other things than RFID reading. I cannot say exactly what it has to do but I cannot go back to wake up mode. But I have to go in sleep mode and low power run mode during product operation.

    So the idea is to do RFID things after wake-up, during normal operation (can be in sleep mode or low power run mode).

    I am trying to add some code in HAL_GPIO_EXTI_Callback, called when an IRQ is detected on PA0.

    But when I try to call RFID functions it doesn't work well.

    Regards,

    Matthieu

    PS: I I will certainly ask for a logic analyzer expense. In the past I use to use this material, very convenient !

    Ulysses HERNIOSUS
    ST Technical Moderator
    November 13, 2018

    Hi Mathieu,

    sorry for the belated answer. Somehow I missed your response.

    HAL_GPIO_EXTI_Callback() is run from ISR context. You cannot call blocking rfal functions from it. Also it is not advisable to call any rfal functions as this potentially opens up race conditions.

    Regards, Ulysses.

    MatthieuB
    MatthieuBAuthor
    Associate
    November 13, 2018

    Hi Ulysses,

    thank you for your answer, I moved forward and I'm still trying to do RFID works fine.

    I have found a STM32 function that enables to call a function when arrives an IRQ :

    HW_GPIO_SetIrq( IRQ_3911_GPIO_PORT, IRQ_3911_PIN, 10, RFID)

    => RFID_buff is the function called when an IRQ arrives on PA0 pin.

    In this function I do nearly the sames things as at the beginning (to wake-up the STM32 from STANDBY mode):

    • rfalAnalogConfigInitialize();
    • st25r3911Isr();
    • st25r3911ClearInterrupts();
    • rfalWorker();
    • demoCycle();
    • st25r3911Isr();
    • st25r3911ClearInterrupts();
    • Reset_ST25R3911_REG_OP_CONTROL();
    • PowerDownMode_ST25R3911B();
    • rfalAnalogConfigInitialize();
    • rfalInitialize();
    • rfalWakeUpModeStart( &ConfDay);

    But it doesn't works fine the second time I pass a RFID badge (MiFare classic).

    Indeed I have found that a difference between wakeping from STANDBY and now is in rfalWorker(), when I wake-up from SATNDBY rfalWorker is in RFAL_STATE_TXRX state and call rfalRunTransceiveWorker() whereas now rfalWorker is in default state so do nothing...

    I don't know what I have to do to have a right state to call rfalRunTransceiveWorker.

    Do you have an idea ?

    Regards,

    Matthieu

    Ulysses HERNIOSUS
    ST Technical Moderator
    November 13, 2018

    Hi Matthieu,

    as no OS is involved I am pretty sure that this function is just again called from ISR context.

    Please move all this functionality to normal task level.

    When you exit the STANDBY mode and enter the main() just look at PA0: HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0)

    Depending on it execute one or the other code sequence. No need to push anything into callbacks. This should make your life much easier and avoid any race conditions / dead locks / etc.

    Regards, Ulysses

    MatthieuB
    MatthieuBAuthor
    Associate
    November 13, 2018

    Hi Ulysses,

    indeed no OS is used for our project.

    The idea is to be careful to the consumption because it is powered with battery.

    So I use STANDBY mode, STOP mode will be used after wake-up of the STM32.

    I don't know if the HAL_GPIO_ReadPin function can exit the STOP mode if it detects a rising edge ?

    I cannot stay in run mode it consums too much power.

    Best regards,

    Matthieu

    Ulysses HERNIOSUS
    ST Technical Moderator
    November 14, 2018

    Hi Matthieu,

    I still don't understand your architecture of using Stop mode. Using Stop mode does not force you to put all your activities into ISRs/callbacks. Just issue the WFI/WFE from task/normal level. When it wakes, call rfalWorker() a few times and do whatever else you want to do.

    IMHO, doing all this while you are doing transactions on NFC/have the NFC field enabled is just futile. Run mode uses maybe 1mA. While at the same time your are blasting 150 to 200mA through the NFC antenna. Maybe it is even more power effective to spend more energy on the MCU to shorten the field-on time. With higher MCU speed the SPI may also run faster, inter-byte delays can be reduced, etc. I think your effort is better invested in optimizing your NFC transfers, see that all the timings are close to their minimum limit.

    Regards, Ulysses

    MatthieuB
    MatthieuBAuthor
    Associate
    November 14, 2018

    Hi Ulysses,

    the architecture I'm trying to do is the following :

    STANDBY mode -> Wake-up with RFID -> Do Radio things -> STOP mode or Low Power Run Mode

    This is simplified but the idea is really to save power in order to have the best autonomy .

    That's why my the idea is to use ISR while being in Low Power modes.

    I have measured about 80mA for RFID when field is ON.

    I try to call rfalWorker() and I put some traces inside.

    The first time (wake-up from STANDBY mode) rfalWorker() is in RFAL_STATE_WUM mode and call rfalRunWakeUpModeWorker(). Then it is in RFAL_STATE_TXRX mode and call rfalRunTransceiveWorker().

    But the second time rfalWorker() is in RFAL_STATE_WUM mode and call rfalRunWakeUpModeWorker() but never pass in RFAL_STATE_TXRX .

    In check the ISR sent from ST25R3911 with oscilloscope and they are not the same between first and second time. Maybe you have an idea what can be wrong ?

    If there is an other way to be in Low Power mode (STM32) and not using ISR it would be great but I have a doubt.

    Best regards,

    Matthieu

    Grégoire Poulain
    ST Employee
    November 21, 2018

    Hi Matthieu,

    When in wake-up mode you should use the method rfalWakeUpModeHasWoke() to check if an wake-up interrupt has been received.

    In your case upon an IRQ you will exit the WFI and anyhow you could call it to ensure that the ST25R3911B was your interrupt source.

    For terminating the wake-up mode the method rfalWakeUpModeStop() must be called to properly terminate this mode and place the ST25R3911B in Ready mode so that you can poll for tags afterwards.

    The state RFAL_STATE_TXRX will only be reached if after wake-up a new transceive is requested, it does not automatically get out of wake-up mode into transceive mode.

    Kind regards

    GP

    MatthieuB
    MatthieuBAuthor
    Associate
    November 23, 2018

    Hi Gregoire,

    Ok so during wake-up from STANDBY mode if I call rfalWakeUpModeHasWoke() after checking PWR_FLAG_WU (for wakeping the STM32) it respond me 0.

    Anyway it works I can read a RFID badge and the STM32 is correctly initialized.

    Then after having read a badge I just reset the ST25R3911_REG_OP_CONTROL.

    After a few time I call rfalWakeUpModeStart(NULL) in order to enable again the wake-up mode.

    And I call a function HW_GPIO_SetIrq(IRQ_3911_GPIO_PORT, IRQ_3911_PIN,10,RFID) which call the function RFID when and IRQ on IRQ_3911_GPIO_PIN arrives. I will add a STOP or OFF mode here.

    Inside the RFID function I do:

    • woke=rfalWakeUpModeHasWoke() => respond 0
    • rfalWakeUpModeStop();
    • rfalInitialize();
    • rfalWorker();
    • demoCycle();

    But this doesnt work, I have an error 3 returned by rfalNfcaPollerTechnologyDetection(RFAL_COMPLIANCE_MODE_NFC, &sensRes);

    The rfalworker seems to work bad at this time, you said it does not automatically get out of wake up mode into transceive mode, but how to do this ?

    Thank you for your precious help.

    Best Regards,

    Matthieu