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
Read words in memory bank & bit mask data
-
- 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
- Attachments
-
- LocationInUserBank.png
- (32.92 KiB) Downloaded 1870 times
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Read words in memory bank & bit mask data
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
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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
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?
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
Steven
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Read words in memory bank & bit mask data
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?
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?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- 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
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.Benj wrote:Do you have a library you are using to help you design the code?
I'm just trying to keep learning & growing in a infinite loop... unless I wanna break. Cheers
Steven
Steven
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Read words in memory bank & bit mask data
Hi Steven,
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?
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.how did you come up with those hex values such as " 0x007F" and so on?
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?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel