Unique ID on Kinetis K22

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Unique ID on Kinetis K22

1,082 次查看
brunoalbrecht
Contributor III

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

1 回复

785 次查看
miduo
NXP Employee
NXP Employee

Hi,

Yes, the 128-bit unique identification (ID) number are defined with four register, named Unique Identification Register High (SIM_UIDH); Unique Identification Register Mid-High (SIM_UIDMH); Unique Identification Register Mid Low (SIM_UIDML); Unique Identification Register Low (SIM_UIDL); Those four registers are read only register and programmed during manufacturer testing procedure.

Do not know why the SIM_UIDH not been defined, anyway your comments quite helpful.