Skip to main content
Visitor II
December 20, 2022
Solved

ST25DV-i2c energy harvesting and GPO with stm32l031k6

  • December 20, 2022
  • 14 replies
  • 6102 views

Hello, I am trying to open a project that can turn on the low power MCU stm32l031 with ANT7-T-25DV64KC while turning high and low periodically for GPO pin of the MCU. I tried many different ways but still not done with any of them (steval code and using NFC4 and 7 provided by stm32cubeide).

Would you please suggest me for any reference or sample for St25DV-i2c?

    This topic has been closed for replies.
    Best answer by Rene Lenerve

    Hi @WPARK.1​,

    Great that you solved your issue, Happy for you.

    • For EH, if you have set the register to the value ST25DVXXKC_EH_ACTIVE_AFTER_BOOT, EH will be always active (when a field is present) until you modify this register. (please read the DataSheet of the ST25DV64KC to have more information on it and other features).

    • For NDEF, NDEF is a file format message described by the standard from NFC Forum specifications, it describes how data are organized in the memory. There are multiple formats defined by NFC Forum, URI is one to store URI information as for this example an URL (could be also phone number, email, ftp, ...). The field information is just additional information used for smart poster (it is an extended format that contains more fields not mandatory to store only an URL). For NDEF Text format you need to use another format than the URI, in the ndef lib you have a file named lib_NDEF_Text that allow you to build such messages. But it is recommended to read the standard or find some resources on google to learn more about NDEF format (This standard is used for applications with NFC but are not NFC spec).

    I hope this can help you.

    Kind Regards.

    14 replies

    ST Employee
    January 3, 2023

    Hello,

    Just to be sure I understand what you want to do:

    • do you want to use the GPO pin of ST25DV to wake-up the STM32 ?
    • do you want to wake up on RF field detection, or on-demand when a RF reader (e.g. smartphone) is sending a special command to toggle the GPO pin ? (the GPO pin can be toggled on a RF command or on some RF events like RF field detection).

    Best regards.

    WPARK.1Author
    Visitor II
    January 4, 2023

    Actually, I donot need any data to read. I want to turn on the MCU using the EH of ST25 and when RF is detected, GPO makes some PWM kind of signal.

    Thank you for reading.

    ST Employee
    January 4, 2023

    Hello,

    There is 2 ways of using EH: on-demand or at boot.

    On demand means that you activate/deactivate it with a command from the reader. For this, you need to write a 1 into the EH_CTRL_Dyn register.

    At boot means that every time the RF field is rising, the EH will be activated automatically. To enable this mode, you need first to set the EH_MODE configuration byte to 0 (you need first to present the RF configuration password to be able to write this).

    Please keep in mind that EH power delivery is small and very dependent on the distance with the reader and on antennas size and coupling. So do not try to power too many thing with this.

    For GPO, there is a RF command to toggle the level of the GPO pin. It is the ManageGPO command. It allows the RF reader to change level of the GPO pin on demand.

    Best regards.

    WPARK.1Author
    Visitor II
    January 4, 2023

    Yes, I am aware of that as I ran this kind of project with Arduino before using ST25 Arduino library. However, I realized that with Arduino, it is not possible to make a batteryless circuit as Atmega328 is not LP MCU. Therefore, I would like to make a project similar with STEVAL-SMARTAG1 with stm32l031. But it is not easy to find any reference project or sample code that can be operated in STM32CubeIDE.

    Thank you for reading.

    ST Employee
    January 4, 2023

    Hi @WPARK.1​,

    Unfortunately we do not have ready to use examples using STM32L031 with STM32CubeIDE.

    I think the best way would be to start a new stm32 project in STM32CubeIDE with the correct MCU selected. And then include source files from NFC7 examples.

    You can also start a new STM32 project using ioc file from SMARTAG1 project (which uses STM32L031) but this project is configure to work with other components (be careful that SMARTAG uses ST25DVxxK and not ST25DVxxKC, they are quite similar but some registers are different and Ref IC is not identical, so you'll need to get ST25DVxxKc component drivers from NFC7 package to use with your ANT7-T-25DV64KC).

    It is not clear what you would like to do, here are some information about feature you mention on previous posts:

    • Energy Harvesting is not managed by MCU, only the activation of this feature can be set with I²C or RF, so the MCU will be power up every time the field is raising. Or you could wake up the MCU using GPO but this needs to connect GPO to a specific MCU pin (to check in MCU DataSheet).
    • GPO cannot be managed as a PWM with I²C, only the RF is able to drive the GPO level (the NFC Reader could toggle the GPO to simulate a PWM but the frequency would be limited due to the NFC commands exchange time).

    Maybe if you could give more information on your project it would be easier to help.

    Kind Regards.

    WPARK.1Author
    Visitor II
    January 4, 2023

    Hello,

    First of all, thank you for your clarification.

    For my project, I want to collect the power from the antenna of the NFC chip (it is the reason why I am mentioning EH of ST25) to turn on the LP MCU (STM32L031). Then, through I2C, I want to make a PWM kind of digital signal at GPO of the NFC chip to periodically turn on and off a simple device (I am thinking of 2 ways actually, by setting a timer I can high and low the GPO of NFC or if the power collected by the antenna is enough, I can directly use LP MCU digital pin to do it).

    Actually, I tried NFC7 package before, but I failed to modify code for STM32L031 (the original sample code triggered by reading button input so I tried to make it always on when MCU is booted but after modification, it cannot escape from a specific code).

    Thank you for reading.

    WPARK.1Author
    Visitor II
    January 4, 2023

    Hello,

    First of all, thank you for your clarification.

    For my project, I want to collect the power from the antenna of the NFC chip (it is the reason why I am mentioning EH of ST25) to turn on the LP MCU (STM32L031). Then, through I2C, I want to make a PWM kind of digital signal at GPO of the NFC chip to periodically turn on and off a simple device (I am thinking of 2 ways actually, by setting a timer I can high and low the GPO of NFC or if the power collected by the antenna is enough, I can directly use LP MCU digital pin to do it).

    Actually, I tried NFC7 package before, but I failed to modify code for STM32L031 (the original sample code triggered by reading button input so I tried to make it always on when MCU is booted but after modification, it cannot escape from a specific code).

    Thank you for reading.

    ST Employee
    January 4, 2023

    Hi,

    "Then, through I2C, I want to make a PWM kind of digital signal at GPO of the NFC chip to periodically turn on and off a simple device (I am thinking of 2 ways actually, by setting a timer I can high and low the GPO of NFC or if the power collected by the antenna is enough, I can directly use LP MCU digital pin to do it)."

    Be aware that it is not possible to make ST25DV's GPO pin toggle from I2C interface of the ST25DV. It is only possible using an RF command or from specific RF events. There is no timer inside the ST25DV to toggle GPO pin like a PWM.

    So you will have to do the PWM from a MCU digital pin.

    Best regards.

    WPARK.1Author
    Visitor II
    January 4, 2023

    Hello,

    I see. So I need to turn on the MCU using antenna first and then, through I2C, I need to do EH for providing stable power for LP MCU, then by setting a timer on MCU, I can make periodic control on the digital pin of MCU.

    Thank you for reading.

    ST Employee
    January 4, 2023

    Hi,

    "I need to turn on the MCU using antenna first and then, through I2C, I need to do EH for providing stable power for LP MCU, "

    This is not how EH works.

    If you have configured the ST25DV (through RF or I2C) to have EH enabled at boot (EM_MODE config byte): it will deliver power to the MCU as soon as the RF field is strong enough.

    If you have not enable EH at boot, you need to enable EH with a RF command sent by the RF reader (write into EH_EN register). Then only the ST25DV will deliver power to the MCU.

    The MCU cannot activate the EH through I2C since it is not powered by EH first.

    Best regards.

    WPARK.1Author
    Visitor II
    January 4, 2023

    Hello,

    Actually, this is not very clear for me. I know that there is a specific register for enabling EH at boot but for my perspective, it was weird that how can I turn on the MCU without enabling EH first.

    Is there any way to internally program ST25 chip or at first, ST25 automatically open EH when strong RF signal is detected.

    As you know, I want to make a batteryless circuit and RF signal for triggering pwm event on MCU side (NFC chip is only to provide stable 3.3V for MCU).

    Thank you for reading.

    ST Employee
    January 4, 2023

    Hi,

    "Is there any way to internally program ST25 chip or at first, ST25 automatically open EH when strong RF signal is detected."

    Yes, this is the EH_MODE regsiter. This is a non-volatile register, meaning that once set to "0x00", the tag will automatically enable EH on strong RF signal ervery time.

    Off course, to write into this register once, you need either to use a RF reader or to write it by I2C with a powered MCU (not powered by EH since at that time EH will not be enabled).

    Best regards.

    WPARK.1Author
    Visitor II
    January 4, 2023

    Hello,

    I think now I can understand the situation, so when I upload the code and run using stlink, if I set the register to 0x00, even though the MCU was off and the register 0x00 is remained as it is non-volatile on st25 chip.

    Thank you for reading.

    ST Employee
    January 23, 2023

    Hi @WPARK.1​,

    In the Smartag1 project, the file TagType5 is located in project folder, and for the NFC7 this file is located in the NDEF middleware (the NDEF lib of NFC7 is in the latest version, so you don't need to get the one from Smartag1). This file is a wrapper between the NDEF lib and ST25DV component. This file is compatible with ST25DV64K or ST25DV64KC.

    I proposed to use the IOC file in order to generate correct project files for the STM32CubeIDE software for your MCU with the smartag1 project (for NFC7 project files for STM32CubeIDE are already available). Now that you have STM32CubeIDE project files you can remove link to source files in the workspace and add the ones provided in Smartag1 and gather NFC7 drivers from the other package.

    The two approach are correct, but of course it will required an adaptation of the source files in both cases.

    I hope this can help you,

    Kind Regards.

    WPARK.1Author
    Visitor II
    January 23, 2023

    Hello,

    Actually, I did similar thing you recommended here.

    1. Opened project with SMARTAG1 IOC.
    2. Substituted ST25DV source and header file to ST25DVxxKC
    3. Redefine address to ST25DVxxKC from ST25DV
    4. 0693W00000Y8uPdQAJ.png0693W00000Y8uQHQAZ.png

    But I still have error like (unknown type name 'NFCTAG_DrvTypeDef') and I could not find the place where NFCTAG_DrvTypeDef is defined.

    Furthermore, should I import all the lib from here?0693W00000Y8uRUQAZ.png 

    It is a bit hard for me to determine which source and header files are required to be imported from different projects. Furthermore, if I use IOC, it shows an error that I2C and some functions are overlapped (Due to the IOC file, they are automatically defined and for BSP file and main.c from the project, they are also defined so it causes crack among them)

    Thank you for reading.

    ST Employee
    January 23, 2023

    Hi @WPARK.1​,

    I was trying to port it to STM32CubeIDE on my side, and at the end I got the following message :region `FLASH' overflowed by 9836 bytes (with max optimization).

    Then reading the readme file of the project, I found this information :

     - When the source code get compiled through the STM32CubeIDE toolchain it slightly overcome the maximum available memory.
     
     For that reason the related project is excluded from the package. 
     
     - debug mode is not available.

    So it seems that with STM32CubeIDE it is not possible to compile this project for that MCU.

    Keil has a free license for compiling binaries under 32KB . The binary for this project is 30KB so you should be able to compile it, but adding code will lead to license problem.

    Kind regards

    WPARK.1Author
    Visitor II
    January 23, 2023

    Hello,

    Yes, I am aware of this information. That is the reason why I would like to remove other SPI and I2C sensors (to reduce source code size) and connect ST25DV64KC (boot EH mode) to STM32L031K6 for triggering periodically HIGH a digital pin of the MCU.

    What I need is the method for connecting STM32L031K6 and ST25DV64KC through I2C for activating EH mode and some NDEF message transmitted from ST25DV64KC side.

    I bought ST25DV64KC-DISCO actually, and I found out that it is totally useless in my case as I want a customized board connected with ST25 NFC chip. I even don't really understand what is the point of the discovery board if I use your software and buttons for control. (Is it just for fun or really meaningful to develop something new? As I believe most embedded engineers like me want to make a customized board, need to modify the internal code myself. But no mooc or other things to learn the I2C connection. And I am not very professional and have not enough time to finish them.)

    As a result, at the end, I actually want to have a MOOC, tutorial, or source code with some explanation for learning it.

    So, I want to ask you about any recommended way to learn I2C connection with ST25?

    Thank you for reading.

    ST Employee
    January 23, 2023

    Hi @WPARK.1​ ,

    So what you need is a nucleo board, with this kit you can build your application more easily (thanks to arduino connectors) than modifying boards like SMARTAG or Discovery boards (They are demo boards and aim to show each features of the component and examples of what we can do with).

    Nucleo boards are development kits ans I think better solution for you. You start with the MCU board (there is a choice of MCU) and you can add expansion boards to have more functionalities (for example NFC4 or NFC7 to have NFC tag). The software package includes simple examples to start your development. For example with the NFC4 and NFC7 you can find a simple example on how to enable the Energy Harvesting on the ST25DVxxK / ST25DVxxKC.

    The communication through I2C is the same as a standard EEPROM memory. BSP drivers are provided with the nucleo package to communicate with our NFC tags.

    I hope this can help you.

    Kind Regards.

    WPARK.1Author
    Visitor II
    January 23, 2023

    Hello,

    The reason why I want to use STM32L031K6 is that it is small and low power MCU. However, I checked that there is no example project built for STM32L031K6 but STM32L053 yes. (As I am working on wearable electronics, the size of the circuit is really critical.)

    So what I can do is that I buy Nucleo board of STM32L053 and X-NUCLEO-NFC07A1 to train with the sample code right? (Actually I tried with STMF4 nucleo and ANT7-T-25DV64KC. I tried to modify MX_NFC7_EH_Process to remove the button function (as I always want it to be on while RF is detected, the code was stuck and cannot operate anymore).

    Thank you for reading.