2021-12-23 01:35 AM
Unable to access memory bank of the temperature sensor to get the temperature data.
Hi,
I am working on ST25RU3993-EVAL board for reading the temperature from RFM3200-AFR temperature sensor.
I am finding very difficult in reading the temperature code from temperature Sensor tag memory.
Can anyone help me on how can i access a particular memory location using the SDK source code provided by the ST.
Thanks in advance..
Solved! Go to Solution.
2022-02-04 03:11 AM
Hello,
The demo application are generated and tested with VS2017. To open the demo launch ".Applications\STUHFL_demo\STUHFL_demo.sln". This solution has 2 project. The executable demo project STUHFL_demo itself and the STUHFL DLL project. To build use in VS the menu "Build - Rebuild Solution". This first build the stuhfl.lib and dll and then the STUHFL_demo. The STUHFL_demo project reference to the stuhfl.lib file in its linker settings and build only correct when a stuhfl.lib is already generated.
Can you confirm that you are able to read USER memory from the TAGs that are part of the eval kit ?
Are you able to select one of these two TAGs from the kit and read only this, to check that Gen2_Select works for your setup ?
2021-12-23 02:02 AM
Hi LS.7,
I don't know the details of this sensor tag. Where is the sensor data accessible? From user memory?
Any special procedures required?
Any specific place you are struggling?
Best Regards, Ulysses
2021-12-23 07:22 AM
Thank you Ulysses for your reply.
I was able to detect the tag in device mode. When the Tag is detected by the EVAL board, I could only access fewer information related to the tag with the help of the structure mentioned below.
typedef struct {
uint32_t timestamp; /**< O Param: Tag detection time stamp. */
uint8_t antenna; /**< O Param: Antenna at which Tag was detected. */
uint8_t agc; /**< O Param: AGC measured when TAG found. */
uint8_t rssiLogI; /**< O Param: I part of Tag logarithmic RSSI. */
uint8_t rssiLogQ; /**< O Param: Q part of Tag logarithmic RSSI. */
int8_t rssiLinI; /**< O Param: I part of Tag linear RSSI. */
int8_t rssiLinQ; /**< O Param: Q part of Tag linear RSSI. */
uint8_t pc[STUHFL_D_MAX_PC_LENGTH]; /**< O Param: Tag PC. */
STUHFL_T_InventoryTagXPC xpc; /**< O Param: Tag XPC. */
STUHFL_T_InventoryTagEPC epc; /**< O Param: Tag EPC. */
STUHFL_T_InventoryTagTID tid; /**< O Param: Tag TID. */
} STUHFL_T_InventoryTag;
I want the Temperature code. In the application note AN002F38, it is mentioned as below:
"As with the On-Chip RSSI Code, reading the Temperature Code is a two-step process requiring standard UHF Select and Read commands.
1. Send a standard Class-1 Generation-2 UHF Select command with the parameters described in Table 6 to initialize the temperature sensor and calculate a Temperature Code.
2. Send a standard Class-1 Generation-2 UHF Read command to retrieve the Temperature Code from the tag memory at the location given in Table 7."
How can i send select commands and access the particular memory bank so that i can fetch the temperature code and calculate the actual temperature.
How to read a memory bank using SDK source code provided by the ST.
I want to know if a particular API is available to achieve this and in which place in the source code should i use it.
The application note and the related documents are attached below for your reference.
2021-12-23 07:27 AM
2022-01-17 12:49 AM
Hello,
thanks for the application note of the sensor TAG.
according to the application note the sensor TAG needs 3ms continuous wave after the Gen2_Select command before any further command from the reader.
The actual ST25RU3993 do not allow this out of the box. Although, the Gen2_Select command is a separate API calls the FW
collects Gen2_Select commands and send them direct before scanning for TAGs with the Gen2_Query commands.
There is no delay after the Gen2_Select command, as this is not needed under normal conditions.
To add a delay after the Select before the inventory you need to modify the FW first.
The easiest would be to add a HAL_Delay(3); to the functions
static void inventoryGen2(void) in file evalAPI_commands.c
In this function search for "performSelectsGen2();" and add there a delay of 3ms afterwards
With this fix then do the following to select, inventory and read a TAG
To send a Gen2_Select and a following Gen2_Read command please use the following API functions.
NOTE: The Gen2_Select API do not send any command by itself it only store the "select" request(s) in the FW.
The FW executes then all Gen2_Select commands when running an inventory, as discussed above.
-> This means in your case execute an Gen2_Select, followed by an InventoryRunnerStart and when your TAG is found send a Gen2_Read command.
For the Gen2_Select and Gen2_Read please use the following API
1. Select:
STUHFL_DLL_API STUHFL_T_RET_CODE CALL_CONV Gen2_Select(STUHFL_T_Gen2_Select *selData);
with
typedef struct {
uint8_t mode; /**< I Param: Select mode to be applied (CLEAR_LIST, ADD2LIST, CLEAR_AND_ADD). */
uint8_t target; /**< I Param: indicates whether the select modifies a tag's SL flag or its inventoried flag. */
uint8_t action; /**< I Param: Elicit the tag behavior according to Gen2 Select specification. */
uint8_t memoryBank; /**< I Param: Bank (File, EPC, TID, USER) on which apply the select. */
uint8_t mask[STUHFL_D_GEN2_MAX_SELECT_MASK_LENGTH]; /**< I Param: Selection mask. */
uint32_t maskBitPointer; /**< I Param: Bit starting address to which mask is applied (bit address). */
uint8_t maskBitLength; /**< I Param: Mask length in bits. */
uint8_t truncation; /**< I Param: Truncate enabling. Not supported yet, must be set to zero */
} STUHFL_T_Gen2_Select;
The parameter target, action, memoryBank, mask, truncation are as defined in the UIHF Gen2 standard.
Accodring to the application note, in case of temperature measurement with this sensor TAG you could use the default initalization values, except the memoryBank.
eg:
STUHFL_T_Gen2_Select Gen2Select = STUHFL_O_GEN2_SELECT_INIT(); // Set to FW default values
Gen2Select.memoryBank = STUHFL_D_GEN2_MEMORY_BANK_USER; // set memory bank
// mask and maskBitLength is empty by default
// Execute the Gen2_Select command
Gen2_Select(&Gen2Select);
2. Run inventory
or execute the following API to run just one inventory round
STUHFL_DLL_API STUHFL_T_RET_CODE CALL_CONV Gen2_Inventory(STUHFL_T_InventoryOption *invOption, STUHFL_T_InventoryData *invData);
3. Read
For the final Gen2_Read please use the following API
STUHFL_DLL_API STUHFL_T_RET_CODE CALL_CONV Gen2_Read(STUHFL_T_Gen2_Read *readData);
with
typedef struct {
uint32_t wordPtr; /**< I Param: Word address to which read data. */
uint8_t memoryBank; /**< I Param: Bank (File, EPC, TID, USER) to which read data. */
uint8_t numBytesToRead; /**< I Param: Number of bytes to read. */
uint8_t pwd[STUHFL_D_PASSWORD_LEN]; /**< I Param: Password. */
uint8_t numReadBytes; /**< O Param: Number of effectively read bytes. */
uint8_t data[STUHFL_D_MAX_READ_DATA_LEN]; /**< O Param: Read data. */
} STUHFL_T_Read;
In your case the memoryBank must be set to STUHFL_D_GEN2_MEMORY_BANK_RESERVED and the wordPtr must be set to WordAddr 0x0E
BR Nick
2022-01-31 01:49 AM
Hi Nick. Thank you so much for your efforts.
As mentioned by you, I made the changes and called the select api, followed by inventory and read.
But still not getting the temperature data. I am getting only zeroes.
However, I noticed the following:
1. When STUHFL_T_Gen2_Select variable is declared, initialized and Gen2_Select() function is called, Only the first 'if' block inside it is getting executed, as all the parameters are set to default except memory bank.
2. Inside performSelectsGen2() function, the gen2Select() function is not getting called as numSelects value is 0.
/******************************************************************************************************
static void performSelectsGen2(void)
{
for(uint32_t i=0 ; i<numSelects ; i++) {
gen2Select(&selParams[i]);
}
StoreTestData(TEST_ID_GEN2_SELECT_T4MIN, sizeof(uint16_t), (uint8_t*)&gen2Configuration.T4Min);
}
/*****************************************************************************************************/
And moreover selParams will be sent as the argument for gen2Select, which are all zeroes.
I have added the HAL_Delay(3), right below the PerformSelectsGen2() inside inventoryGen2() in evalAPI_commands.c file. That particular part of code is attached below for reference.
/*****************************************************************************************************/
//
// Search for TAGs ..
//
performSelectsGen2();
HAL_Delay(3);
tagCnt = gen2SearchForTags(autoAckMode, &p);
// update counters
increaseRoundCounter();
/****************************************************************************************************/
The While loop inside my main function looks like this.
/****************************************************************************************************/
while(1)
{
STUHFL_T_InventoryOption invOption;
STUHFL_T_InventoryData invData = STUHFL_O_INVENTORY_DATA_INIT();
// apply data storage location, where the found TAGs shall be stored
STUHFL_T_InventoryTag tagData[STUHFL_DEVICE_MODE_MAX_TAGS] = { 0 };
invData.tagList = tagData;
// setup options
invOption.rssiMode = STUHFL_D_RSSI_MODE_2NDBYTE;
invOption.roundCnt = 1;
invOption.inventoryDelay = 0;
invOption.options = 0x00;
// assign correct size of applied tag storage
invData.tagListSizeMax = STUHFL_DEVICE_MODE_MAX_TAGS;
//doInventoryCfg(true, false, STUHFL_D_ANTENNA_1); // single TAG
doInventoryCfg(false, true, STUHFL_D_ANTENNA_2); // multiple TAGs
// Single round inventory with tags post process
Gen2_Inventory(&invOption, &invData);
LOG("Found tags: %d\n",invData.tagListSize);
// Multiple rounds inventory with tags on the run processing
inventoryCycleCbCnt = 0;
Inventory_RunnerStart(&invOption, cbInventoryCycle, NULL, &invData);
/**
* NOTE: Starting the inventory runner is a blocking call. Whenever
* transponders found the STUHFL_T_InventoryCycle callback is called.
* Within this callback processing of the data should take place.
*
* To stop the runner and return from the Inventory_RunnerStart function
* there are 2 possibilities.
*
* 1. A call to Inventory_RunnerStop. Can be called from the callback
* 2. When the number of requested rounds are executed
*
*/
for(int i = 1; i < 16; i++) {
invOption.roundCnt = i;
inventoryCycleCbCnt = 0;
/*1.Configure and call select command*/
STUHFL_T_Gen2_Select Gen2Select = STUHFL_O_GEN2_SELECT_INIT();
Gen2Select.memoryBank = STUHFL_D_GEN2_MEMORY_BANK_USER;
// Gen2Select.maskBitPointer = 0xE0;
Gen2_Select(&Gen2Select);
/*2.start the inventory round*/
Gen2_Inventory(&invOption, &invData);
/*3.Read the TAG*/
STUHFL_T_Gen2_Read readData;
readData.memoryBank = STUHFL_D_GEN2_MEMORY_BANK_RESERVED;
readData.wordPtr = 0x0E;
readData.numBytesToRead = 8;
Gen2_Read(&readData);
}
}
/****************************************************************************************************/
Please tell me if I am doing something wrong.
2022-01-31 02:51 AM
Hi,
browsing through I think there may have been one line missing:
Gen2Select.mode = STUHFL_D_GEN2_SELECT_MODE_CLEAR_AND_ADD;
as the default seems to be STUHFL_D_GEN2_SELECT_MODE_CLEAR_LIST.
BR, Ulysses
2022-01-31 04:21 AM
Ok. Thank you for your quick response.
I will check and update
2022-01-31 04:57 AM
Hello,
When I add the following line,
Gen2Select.mode = STUHFL_D_GEN2_SELECT_MODE_CLEAR_AND_ADD;
The reader is not detecting the tag.
When i comment the line, the reader detects the tag well.
What might be wrong?
2022-02-02 08:50 AM
Hello Lakshmikanth,
User Ulysses is right, the default Gen2Select.mode is STUHFL_D_GEN2_SELECT_MODE_CLEAR_LIST which only clears the internal lists of select commands that
shall be executed before the gen2SearchForTags. The correct Gen2Select.mode is STUHFL_D_GEN2_SELECT_MODE_CLEAR_AND_ADD
Have you tried with some other "standard" Gen2 TAG (use the one that is part of the ST25RU3993 EVAL/HPEV package) to select it and for example read the User memory ?
In the SDK package you find C demo code example to inventory, read and write user memory for 1 selected TAG.
This code is in function "void demo_evalAPI_Gen2RdWr()" in file "STUHFL_demoEvalAPI.c" of the solution ".\Applications\STUHFL_demo\STUHFL_demo.sln"
BR