2018-10-19 02:14 AM
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
Solved! Go to Solution.
2018-10-25 09:03 AM
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 :
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...
2018-10-30 10:38 AM
Hi Mathieu,
not sure I do understand:
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.
2018-10-31 02:02 AM
Hi Ulysses,
indeed my Power Down function does :
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 !
2018-11-13 06:23 AM
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.
2018-11-13 06:41 AM
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):
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
2018-11-13 07:02 AM
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
2018-11-13 08:02 AM
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
2018-11-13 11:57 PM
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
2018-11-14 05:26 AM
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
2018-11-21 08:35 AM
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