Hi
I am looking for unique id of nrf52. is there any to set or generate unique id throughout all nrf52 devices.
Thanks & Regards Paramvir Singh
Hi
I am looking for unique id of nrf52. is there any to set or generate unique id throughout all nrf52 devices.
Thanks & Regards Paramvir Singh
Hi,
You have the DEVICEID registers in FICR(Factory information configuration registers). The 2 DEVICEID registers each contain a 64 bit unique device identifier.
If you want to read and print the DEVICEID in the FICR register, you can do it like this:
NRF_LOG_INFO("DEVICEID0: %08X\n", NRF_FICR->DEVICEID[0]);
NRF_LOG_INFO("DEVICEID1: %08X\n", NRF_FICR->DEVICEID[1]);
The FICR contains one.
// But only use LSB six bytes
define MAX_DEVICE_ID 0xfFfFfFfFfFfF
// FUTURE use a 48-bit bit field
DeviceID myID() {
/*
* NRF_FICR->DEVICEADDR[] is array of 32-bit words.
* NRF_FICR->DEVICEADDR yields type (unit32_t*)
* Cast: (uint64_t*) NRF_FICR->DEVICEADDR yields type (unit64_t*)
* Dereferencing: *(uint64_t*) NRF_FICR->DEVICEADDR yields type uint64_t
*
* Nordic doc asserts upper two bytes read all ones.
*/
uint64_t result = *((uint64_t*) NRF_FICR->DEVICEADDR);
// Mask off upper bytes, to match over-the-air length of 6 bytes.
result = result & MAX_DEVICE_ID;
assert(result <= MAX_DEVICE_ID);
return result;
}
Is there any relation towards the MAC address you see when you use BLE ? Can you also use that as a unique identifer?
Hi Erlot,
The DEVICEADDR registers are used for that(48 bit device address). See this answer on how the MAC address is derived from the DEVICEADDR .
What is the difference between upper and lower case letters in
define MAX_DEVICE_ID 0xfFfFfFfFfFfF
?