This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Regarding User Register 2 and User Register 3 in TM4C129X

Other Parts Discussed in Thread: LMFLASHPROGRAMMER

Hi,

I want to flash a unique number in User Register 2 and User Register 3.

What are assigning and reassigning options for User Register 2 and User Register 3.

Regards,

Satish

  • Hello Satish,

    I am not certain what you mean by "assigning and reassigning options" for the user registers. These are flash registers that can be programmed to a value by changing the 1's to 0's. This means that the initial state of the bits in these registers is erased (1's) and you may program the desired values into the registers when they are in their initial/default state. For example, the default value to start if 0xFFFFFFFF and if you program the register to the value 1, the new value is 0x00000001 where all bits are zero except for bit 0. If you need to write to this same register again, the only possible value to move to would be 0x00000000 since there in only 1 bit left to change to a 0. If, however, you program to 0xFFFFFFFE, you could then progressively change bits to 0 to get many more values from the register.

    Once the values are written into these registers, they may be committed or made permanent by using the COMT bit in the FMC register. Note this bit also impacts the BOOTCFG register so please review and understand fully before committing. Once committed, the registers can only be cleared to their default state of all 1's by using the Recovering a Locked Microcontroller process described in the JTAG section of the datasheet/userguide.

    The registers can be programmed by the application or by an external application over JTAG such as LMFlashProgrammer.
  • HI Chuck,

    Thank you for the detailed mail. On assigning and reassigning options I meant that flashing an unique id (4 byte number) to the target board.
    I am using UserRegisters 2 and UserRegister3 for the same. 
    a) Can you share me the example where I can program the register? Can I use method defined in flash.h ?
    b) Can you suggest any register for Unique Id assignment ? Can I use these registers.
    c) As far as I know, LMFlashProgrammers, I can flash userRegisters 0 & 1 but there is no provision for flashing userRegisters2 &3. Please confirm.

    Regards,

    Satish

  • Hello Satish,

    Satish Kumar50 said:
    a) Can you share me the example where I can program the register? Can I use method defined in flash.h ?

    The TivaWare APIs include a function to write to any of the User Registers. The API function name is FlashAllUserRegisterSet. There is another API function that is used to "commit" the changes so that they are permanent even through a power on reset. This API function is FlashUserSave; however, it only saves User Registers 0 and 1. If you wish to commit the values you write to User Registers 2 and 3, the only option would be for you to write your own code to do the same as is being done in the FlashUserSave function for User Register 0 and 1. This has been noted as a deficiency and will be added to a list of enhancements for a future TivaWare release.

    Satish Kumar50 said:
    b) Can you suggest any register for Unique Id assignment ? Can I use these registers.
    c) As far as I know, LMFlashProgrammers, I can flash userRegisters 0 & 1 but there is no provision for flashing userRegisters2 &3. Please confirm.

    This is generally what the User Registers are intended for so this is the right place to put that information. However, given the issues with the missing API functionality, you could choose to store it in regular emulated EEPROM within the device or in a constant location within the code by "poking in" the serial number into the binary or hex value at the predefined address location in regular flash. I've not known anyone that has done this nor do we have any examples of it but it should be possible.

    In regard to LMFlashProgrammer, I didn't realize at the time it was limited to registers 0 and 1 only so my apologies for suggesting it as an alternative. This is unlikely to change.

    As another possibility, you could use User Registers 0 and 1 for the ID storage if, perhaps, your application doesn't need the MAC address that is stored there when received. It could then also be programmed with LMFlashProgrammer.

  • Satish,

    A colleague was kind enough to send me some code snips of what would be needed to "save" or commit the changes to User Registers 2 and 3. The procedure is as follows:

    // *****************  User Reg 2:
        //
        // Tell the flash controller to write the USER2 Register.
        //
        HWREG(FLASH_FMA) = 0x80000002;
        HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
    
        //
        // Wait until the write has completed.
        //
        while(HWREG(FLASH_FMC) & FLASH_FMC_COMT)
        {
        }
    
    // *****************  User Reg 3:
        //
        // Tell the flash controller to write the USER3 Register.
        //
        HWREG(FLASH_FMA) = 0x80000003;
        HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_COMT;
    
        //
        // Wait until the write has completed.
        //
        while(HWREG(FLASH_FMC) & FLASH_FMC_COMT)
        {
        }
    

  • Thank you so much Chuck for yourhelp. Have a great day.

    Regards,

    Satish