This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

specific unique id for device detection

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

Parents
  • 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;
    }
    
Reply
  • 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;
    }
    
Children
No Data
Related