Page 1 of 1
Read words in memory bank & bit mask data
Posted: Thu Jan 24, 2019 7:07 pm
by Steven_SS
Hello!
I am trying to read in a 48-bit number in the last four words of the User Memory Bank(Bank 3h-words 8h, 9h, Ah, and Bh) and it then needs to be extracted via bit masking into 5 separate words. The attachment shows what I'm talking about.
Can someone point me in the right direction in Flowcode with simply a)Reading the right word address' in the bank and b)extract via bit masking the data values into registers? Thanks
Re: Read words in memory bank & bit mask data
Posted: Thu Jan 24, 2019 11:05 pm
by Benj
Hi Steven,
What device are you reading?
Looks like you should read registers 0x08 to 0x0B into a uint array and then you can collect the data as follows.
Here is some example code, readregister is a routine to read the 16-bit register value at the supplied address.
data[0] = readregister(0x08)
data[1] = readregister(0x09)
data[2] = readregister(0x0A)
data[3] = readregister(0x0B)
crc = data[0]
code1 = data[1] & 0x0FFF
temp1 = (data[2] & 0x007F) | ((data[1] & 0xF000) >> 5)
code2 = (data[3] & 0x0007) | ((data[2] & 0xFF80 >> 4))
temp2 = (data[3] & 0x3FF8) >> 3
ver = (data[3] & 0xC000) >> 14
Re: Read words in memory bank & bit mask data
Posted: Fri Jan 25, 2019 5:48 am
by Steven_SS
Hey Benj!
Thanks for your response, isn't "readregister" a command/routine from a component though?
The device I'm using an m6e RFID; reading tags. I do not believe there is a built-in component for that particular device.
If I can use that readregister routine, then your provided example would fit in amazingly! But I'm not sure if I can?
Re: Read words in memory bank & bit mask data
Posted: Fri Jan 25, 2019 11:59 am
by Benj
Hello,
ReadRegister probably needs to be a user created macro that communicates to the module and pulls out the 16-bit value from the address specified.
You're right in there is currently no component for that module. Do you have a library you are using to help you design the code?
Re: Read words in memory bank & bit mask data
Posted: Fri Jan 25, 2019 3:33 pm
by Steven_SS
Benj wrote:Do you have a library you are using to help you design the code?
No :/ I do not have a library for that... I do have a module where it reads the data I believe, but do not have it where it reads the specified address' and then specific bits in there.
Re: Read words in memory bank & bit mask data
Posted: Wed Jan 30, 2019 6:52 pm
by Benj
Hi Steven,
how did you come up with those hex values such as " 0x007F" and so on?
This is the mask for the temp1 value. If you look at the register map then you can see that temp1 occupies the lower 7 bits of register 0x0A.
0x007F = 0b0000000001111111
Hence the lower 7 bits.
You seem to be trying to run before you can walk.
Step 1 try and communicate with the RFID module so that you can tell when a card is present or not. You can maybe use the device datasheet or try and follow an existing code library.
Once you know if a card is present you need to read the registers from the card, this can be involved as your talking to the module which is talking to the card. Some RFID modules do a lot of work for you but other do very little and require you to do all the hard work. When I say hard I mean it
What about the MFRC522 RFID module that we already support, this is very low cost and works well?