AnsweredAssumed Answered

Unique ID on Kinetis K22

Question asked by Bruno Albrecht on May 3, 2018
Latest reply on May 3, 2018 by Fang Li

Dear all,

 

I'm playing around with the Unique ID embedded in the microcontrollers to be used as a serial number for my product and I just realized that although the datasheet says it's a 128 bit value, the fsl_sim.c from the SDK2.3 only uses the lower 96 bits (discards the UIDH).

Checking the source files, the use of the highest 32 bit alue depends on the definition of the macro SIM_UIDH, which is not defined anywhere.

 

fsl_sim.c:

void SIM_GetUniqueId(sim_uid_t *uid)
{
#if defined(SIM_UIDH)
uid->H = SIM->UIDH;
#endif
#if (defined(FSL_FEATURE_SIM_HAS_UIDM) && FSL_FEATURE_SIM_HAS_UIDM)
uid->M = SIM->UIDM;
#else
uid->MH = SIM->UIDMH;
uid->ML = SIM->UIDML;
#endif /* FSL_FEATURE_SIM_HAS_UIDM */
uid->L = SIM->UIDL;
}

fsl_sim.h:

/*!@brief Unique ID. */
typedef struct _sim_uid
{
#if defined(SIM_UIDH)
uint32_t H; /*!< UIDH. */
#endif

#if (defined(FSL_FEATURE_SIM_HAS_UIDM) && FSL_FEATURE_SIM_HAS_UIDM)
uint32_t M; /*!< SIM_UIDM. */
#else
uint32_t MH; /*!< UIDMH. */
uint32_t ML; /*!< UIDML. */
#endif /* FSL_FEATURE_SIM_HAS_UIDM */
uint32_t L; /*!< UIDL. */
} sim_uid_t;

 

Changing the #if statements to 

#if defined(SIM_UIDH_UID)

solves the problem.

 

 

Best regards,
Bruno

Outcomes