manyikaimen 发表于 2013-9-26 11:12:36

LM3Sxxxx如何读取芯片ID这个唯一标示?

如题。具体芯片是LM3S2965,因为项目需要,软件里面要读取它的唯一标示ID,哪位高手知道呢?

mhw 发表于 2013-9-26 11:33:19

读手册,找到地址,当作变量直接读就行了……但它不是唯一的,读了也没啥用。一般也就做bootloader的时候,根据它识别一下flash和ram的范围和扇区大小……

leexy 发表于 2013-9-26 13:45:57

貌似STM32的是唯一ID
ATMEL就不晓得了

manyikaimen 发表于 2013-9-26 17:53:25

正解

HWREG(FLASH_USERREG0) = 0x00000000;

    FlashUsecSet( 50 ); // number of clocks/microsecond (50 MHz)


    HWREG(FLASH_FMA) = 0x80000000;
    HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
    while( ( HWREG(FLASH_FMC) & FLASH_FMC_COMT ) != 0 )
    {
    }
   
    HWREG(FLASH_USERREG1) = 0x00000002;

    FlashUsecSet( 50 ); // number of clocks/microsecond (50 MHz)

    HWREG(FLASH_FMA) = 0x80000001;
    HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
    while( ( HWREG(FLASH_FMC) & FLASH_FMC_COMT ) != 0 )
    {
    }*/
    *pu32byte0 = HWREG(FLASH_USERREG0);
    *pu32byte1 = HWREG(FLASH_USERREG1);

说明:

You can assign a unique id at USER_REG0 or USER_REG1. You can write these registers either through code or using LM Flash Programmer "User Register Programming". Once you commit, your unique id, the user registers cannot be changed after the next power cycle.

millwood0 发表于 2013-9-27 06:49:03

1. Read the datasheet
2. Read inc/hw_sysctl.c/.h files.
页: [1]
查看完整版本: LM3Sxxxx如何读取芯片ID这个唯一标示?