+ Post New Thread
Results 1 to 7 of 7
  1. #1
    Member level 5
    Points: 2,148, Level: 10

    Join Date
    Jul 2003
    Posts
    80
    Helped
    0 / 0
    Points
    2,148
    Level
    10

    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.

    •   Alt12th July 2009, 09:04

      advertising

        
       

  2. #2
    Banned
    Points: 7,016, Level: 19

    Join Date
    Apr 2009
    Location
    New Jersey, USA
    Posts
    671
    Helped
    170 / 170
    Points
    7,016
    Level
    19

    map address using flash

    Quote Originally Posted by jabidof
    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?



  3. #3
    Member level 5
    Points: 2,148, Level: 10

    Join Date
    Jul 2003
    Posts
    80
    Helped
    0 / 0
    Points
    2,148
    Level
    10

    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?



    •   Alt12th July 2009, 17:29

      advertising

        
       

  4. #4
    Newbie level 6
    Points: 1,740, Level: 9

    Join Date
    Dec 2004
    Posts
    13
    Helped
    1 / 1
    Points
    1,740
    Level
    9

    flash memory serial number

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


    1 members found this post helpful.

  5. #5
    Member level 5
    Points: 2,148, Level: 10

    Join Date
    Jul 2003
    Posts
    80
    Helped
    0 / 0
    Points
    2,148
    Level
    10

    internal structure of flash memory ic

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



    •   Alt14th July 2009, 17:48

      advertising

        
       

  6. #6
    Advanced Member level 4
    Points: 13,903, Level: 28

    Join Date
    Jun 2005
    Location
    Stanford, SF Bay Peninsula, California, Earth, Solar System, Milky Way
    Posts
    1,418
    Helped
    138 / 138
    Points
    13,903
    Level
    28

    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?



  7. #7
    Super Moderator
    Points: 8,139, Level: 21

    Join Date
    Jun 2009
    Location
    Japan
    Posts
    1,054
    Helped
    279 / 279
    Points
    8,139
    Level
    21

    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.



    Quote Originally Posted by jabidof
    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?



--[[ ]]--