本帖最后由 ddllxxrr 于 2015-2-25 21:42 编辑
这个例程是读芯片ID,我发现Atmel的ID十分的详细,把型号都可以查到。
首先打开Atmel Studio开发环境,插入开发板。这时弹出对话框可直接打开例程了。
主要是把CHIPID的结构体打印出来:
结构如下:
typedef struct chipid_data {
//! Version of the device
uint32_t ul_version;
//! Embedded processor
uint32_t ul_eproc;
//! Non-volatile program memory size
uint32_t ul_nvpsiz;
//! Second non-volatile program memory size
uint32_t ul_nvpsiz2;
//! Internal SRAM size
uint32_t ul_sramsiz;
//! Architecture identifier
uint32_t ul_arch;
//! Non-volatile program memory type
uint32_t ul_nvptyp;
//! Extension flag
uint32_t ul_extflag;
//! Chip ID extension
uint32_t ul_extid;
} chipid_data_t;
而操作的读函数如下:
uint32_t chipid_read(Chipid *p_chipid, chipid_data_t *p_chipid_data)
{
if (NULL == p_chipid_data) {
return 0xFFFFFFFF;
}
p_chipid_data->ul_version =
(p_chipid->CHIPID_CIDR & CHIPID_CIDR_VERSION_Msk) >>
CHIPID_CIDR_VERSION_Pos;
p_chipid_data->ul_eproc =
(p_chipid->CHIPID_CIDR & CHIPID_CIDR_EPROC_Msk) >>
CHIPID_CIDR_EPROC_Pos;
p_chipid_data->ul_nvpsiz =
(p_chipid->CHIPID_CIDR & CHIPID_CIDR_NVPSIZ_Msk) >>
CHIPID_CIDR_NVPSIZ_Pos;
p_chipid_data->ul_nvpsiz2 =
(p_chipid->CHIPID_CIDR & CHIPID_CIDR_NVPSIZ2_Pos) >>
CHIPID_CIDR_NVPSIZ2_Pos;
p_chipid_data->ul_sramsiz =
(p_chipid->CHIPID_CIDR & CHIPID_CIDR_SRAMSIZ_Msk) >>
CHIPID_CIDR_SRAMSIZ_Pos;
p_chipid_data->ul_arch =
(p_chipid->CHIPID_CIDR & CHIPID_CIDR_ARCH_Msk) >>
CHIPID_CIDR_ARCH_Pos;
p_chipid_data->ul_nvptyp =
(p_chipid->CHIPID_CIDR & CHIPID_CIDR_NVPTYP_Msk) >>
CHIPID_CIDR_NVPTYP_Pos;
p_chipid_data->ul_extflag =
(p_chipid->CHIPID_CIDR & CHIPID_CIDR_EXT) >> 31;
if (p_chipid_data->ul_extflag) {
p_chipid_data->ul_extid =
p_chipid->CHIPID_EXID & CHIPID_EXID_EXID_Msk;
}
return 0;
}
实际的运行结果如下:
|