Read words in memory bank & bit mask data

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Read words in memory bank & bit mask data

Postby Steven_SS » Thu Jan 24, 2019 7:07 pm

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
Attachments
LocationInUserBank.png
LocationInUserBank.png (32.92 KiB) Viewed 1776 times
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

User avatar
Benj
Matrix Staff
Posts: 14671
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4655 times
Been thanked: 4281 times
Contact:

Re: Read words in memory bank & bit mask data

Postby Benj » Thu Jan 24, 2019 11:05 pm

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
These users thanked the author Benj for the post:
Steven_SS (Fri Jan 25, 2019 1:45 am)
Rating: 5%
 

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: Read words in memory bank & bit mask data

Postby Steven_SS » Fri Jan 25, 2019 5:48 am

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?
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

User avatar
Benj
Matrix Staff
Posts: 14671
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4655 times
Been thanked: 4281 times
Contact:

Re: Read words in memory bank & bit mask data

Postby Benj » Fri Jan 25, 2019 11:59 am

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?

Steven_SS
Posts: 46
Joined: Wed Jul 18, 2018 6:33 pm
Has thanked: 18 times
Been thanked: 3 times
Contact:

Re: Read words in memory bank & bit mask data

Postby Steven_SS » Fri Jan 25, 2019 3:33 pm

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.
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers :)
Steven

User avatar
Benj
Matrix Staff
Posts: 14671
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4655 times
Been thanked: 4281 times
Contact:

Re: Read words in memory bank & bit mask data

Postby Benj » Wed Jan 30, 2019 6:52 pm

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 :D

What about the MFRC522 RFID module that we already support, this is very low cost and works well?
These users thanked the author Benj for the post:
Steven_SS (Wed Feb 06, 2019 5:58 pm)
Rating: 5%