In my project, I need to make readable 96-bit UID. In STM32F0xx reference manual RM0091 section 33.1 Unique device ID register, it is described how the number is encoded:
struct Uid {
uint16_t X; // x-coordinate
uint16_t Y; // y-coordinate
uint8_t WAF; // Wafer number
char LOT[7]; // Lot number
};
My question is how x and y coordinates are encoded, if 0x0000 is in middle of wafer or one side?
Here are some examples which I see in X-coordinate: 0x0000
, 0x0001
, 0x0006
, 0x8001
, 0x8004
, 0x801f
, .... some numbers have the MSB bit set.
In Y-coordinate I always see numbers where MSB is NOT set, like: 0x0001
, 0x0003
, 0x0005
, 0x001f
, 0x0030
, 0x003f
, ...
I don't have so many samples to read many numbers and get better statistics of numbering so my question is: what does it mean if a number has the MSB bit set in the coordinate? I think that this is sign, but I'm not sure.
The reason why I am interested about this, is that I need to decrease the size of this number and remove some bits from this UID. My idea is to remove bits 11-14 from each coordinate to keep position and (probably) sign and make this number smaller and still unique. I need to decrease it by 8 bits only.
MCU is STM32F0xx
UPDATE: I have small statistic from 75 pcs of STM32F031 and here are unique values for:
X: 0003, 0008, 0009, 000a, 000b, 000e, 0010, 0013, 0014, 0015, 0016, 0018, 001c, 0021, 0024, 002a, 8001, 8002, 801b, 801c, 801d, 8020
Y: 0003, 0005, 0006, 0007, 000c, 000f, 0010, 0011, 0013, 0014, 0016, 0017, 0018, 0019, 001a, 001b, 001e, 001f, 0020, 0022, 0024, 0028, 0029, 002a, 002c, 002d, 002e, 0030, 0032, 0033, 0034, 0035, 0037, 0038, 0039, 003a, 003c, 003f, 0042, 0044, 0045, 0046, 0047, 0048, 0049, 004b, 004e
WAF: 0b, 0c, 0d, 0e, 18
Seems that X and Y and WAFER is not BCD but HEX and MSB bit in X coordinate will be probably be sign.
0x801f
can't be right. Also I don't think you can reduce this number and maintain it unique. There is a reason 96 bits were selected. You might be able to compress it though... \$\endgroup\$F
appearing as nimble value hints to 4221 format being used (so F corresponding to 9, E to 8, B to 7 as would D as well). Can anyone confirm? \$\endgroup\$[0-9A-Z]
), so could be considered a base36-encoded number;strtoull
should be fine for decoding as 36^7 fits into 5 bytes -> sparing two bytes already; be aware that there might be leading space, though, which would have to be considered 0... \$\endgroup\$