Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Serial number mapping to a flash memory address

Status
Not open for further replies.

jabidof

Member level 5
Joined
Jul 25, 2003
Messages
80
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
674
serial number flash memory

Hi there,

I have a 16F series microcontroller that receives serial numbers (barcode). All those number are unique and coded on 4 bytes.
I have an external flash memory with 16Mbits. I'd like to find a way to map the barcode serial number to a memory address.
The problem is that the flash memory device (from Atmel) has a particular structure to make the addressing efficient (from memory point of view).

So does anyone have an idea of how to map the BARCODE UID to a FLASH MEMORY ADDRESS using a 16F series microcontroller? I guess some kind of function based on the BARCODE UID will do the job but maybe one of you already solved that problem once :D

Thanks for any hints.
 

GSM Man

Banned
Joined
Apr 15, 2009
Messages
671
Helped
168
Reputation
338
Reaction score
94
Trophy points
1,308
Location
New Jersey, USA
Activity points
0
map address using flash

jabidof said:
I have an external flash memory with 16Mbits. I'd like to find a way to map the barcode serial number to a memory address.
I don't understand! Can you give an example?
 

jabidof

Member level 5
Joined
Jul 25, 2003
Messages
80
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
674
flash code 2009 q3 serial

Sure :)

Imagine you scan a barcode and your MCU gets the following code in HEX:
0xC0 01 67

Now you have an external flash memory IC with 16Mbits of data.

The goal is to map the barcode just scanned (i.e. 0xC0 01 67) to a unique memory address of the flash IC and store a bit there.

Did I make it clearer?
 

future

Newbie level 6
Joined
Dec 20, 2004
Messages
13
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
109
flash memory serial number

Divide the code address by 8 to get the address and get the remainder to address the bit.
 

    jabidof

    points: 2
    Helpful Answer Positive Rating

jabidof

Member level 5
Joined
Jul 25, 2003
Messages
80
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
674
internal structure of flash memory ic

Good idea! What if we want to address 2 bits or more? We divide by 9, 10, etc?
 

kender

Advanced Member level 4
Joined
Jun 19, 2005
Messages
1,422
Helped
138
Reputation
276
Reaction score
38
Trophy points
1,328
Location
Stanford, SF Bay Peninsula, California, Earth, Sol
Activity points
9,968
flash number memory

Could you make one glossary-type clarification. It looks like you have a device under test (DUT), which has the 16F and the Atmel flash.

Q1. One serial number per DUT (e.g. DUT's own serial number of the device) or multiple serial numbers per DUT (e.g. DUT stores serial numbers of other objects)?

Q2. How is the DUT going to use the serial number after is was stored in Flash?

Q3. What do you mean by "mapping"? Usually mapping implies that two values that correspond to each-other have some numeric relationship. Is this interpretation close to yours? If one value is the serial number, than what's the other one?
 

doraemon

Super Moderator
Staff member
Joined
Jun 21, 2009
Messages
1,068
Helped
273
Reputation
554
Reaction score
248
Trophy points
1,343
Location
Japan
Activity points
10,597
how to find sn for my flash memory

Hello!

I don't get it. Let's clarify things.
What do you mean by "map the scanned barcode"? You want to check
if the bar code has already been stored, right? So basically you use the
barcode as an address and you store a bit at this address?

Let's make it clear: you have one MCU, one Atmel flash.
You scan a barcode, you get 0xC0 01 67. What are these spaces. You
meant 0x00C00167, right?

As suggested above, you should divide by 8 (right shift by 3 may be faster).
Let's suppose you have functions to write and also read a single byte to flash
defined as uint8 read_at(uint32 where) and write_at(uint32 where, uint8 what).

- use 2 variables add(21 bits) and val
add = (code >> 3) & 0x001FFFFF; // AND with a 21 bit value, just in case
val = (uint8)(code & 0x00000007); // AND with 0x07 for the 3 last bits.
then transform it to get one bit at the position indicated by val
bitval = 1<<val;

Now if you write val at add, you would do:

write_at(add, bitval).

But id you have 2 values in a sequence (for instance if your codes are
0x00000018 and 0x00000019), you should write bit 0 of byte 3 and bit
1 of byte 3. (0x18 is 00011000 in binary, therefore 00000011 when shifted
by 3).

The solution (supposing you have already written the 0x00000018 code bit:

orgbitval = read_at(3); // Get the value already stored
bitval = orgbitval | (1 << val); // Stores 0x01 | 0x02 = 0x03 in my example
write_at(3, bitval);

Then you will have 2 consecutive bits and the value 0x03 will be written at
byte 3.

That's it! Have fun!

Dora.



jabidof said:
Sure :)

Imagine you scan a barcode and your MCU gets the following code in HEX:
0xC0 01 67

Now you have an external flash memory IC with 16Mbits of data.

The goal is to map the barcode just scanned (i.e. 0xC0 01 67) to a unique memory address of the flash IC and store a bit there.

Did I make it clearer?
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top